Monday, January 12, 2009

Threat images for Udig 1.1

As some of you might know Udig doesn't threat images very well and loads them directly in memory and... and...

In Italy we have some black & white maps that have a particular compression that doesn't work at all.

Ortophotos are usually large and in jpg format, which in memory expand to infinity. And the OutOfMemory complains.

So what?
Until udig 1.2 wil not be ready we need some workarounds and the gdal friends come and help.

After lots of tests, here is my best bid:

1) If you have a jpg, convert it to geotiff.

2) If the image is black & white, convert it to greyscale (in case of indexed image give you trouble as they did for me)

For these two operations you can use the gimp.


Tile the image and create overviews:

  • gdal_translate -co "TILED=YES" -co "COMPRESS=PACKBITS" imagename.tif finalimagename.tif
  • gdaladdo -r average finalimagename.tif 2 4 8 16 32 64


That should be enough to make things work.
If someone can do it better, let me know. Glad to be corrected.

-------------------------------

UPDATE form comment by Andrea Borruso to do everything in gdal:

To generate 8 bit maps:
gdal_translate -scale in.tif out.tif

To make it again 1 bit and viewable in uDig:
gdal_merge -co NBITS=1 -o dst.tif src.tif

Post a Comment