3

I have a geotiff image that rings in at about 290MB. However, once I smooth it using a gaussian filter I'm unable to get it back to that size, it ends up being 1720MB. The size isn't really the problem so to speak, it's that when I go to use gdal_contour it takes 200x as long to contour the smoothed image.

The reason that I'm smoothing the image to begin with is that gdal_contour on the original DEM/DSM gives me a lot of little islands from noise in the data and very circuitous contour lines. Once I smooth it, the islands disappear and the contour lines are less wild, but the file gets so large that now the contouring takes forever. here are my gdal commands:

Generate contours labeled with elevation at 1m intervals (takes about 90s)

    gdal_contour -a elev -i 1 original-dsm.tif

Generate contours labeled with elevation at 1m intervals (takes about 18000s)

    gdal_contour -a elev -i 1 smoothed-dsm.tif

I thought that maybe I could use

    gdal_translate (with various options such as -co COMPRESS=DEFLATE -ot Int16 and others)

to convert the smoothed tif to a smaller size and thus make the contouring go faster, but I've been unable to find the right combination of compression and bit depth.

I've used imagemagick to inspect the files and the major discrepancy I notice is that the original-dsm.tif file has "Channel depth: gray: 1-bit" whereas the smooth.tif has "Channel depth: gray: 16-bit". I'm pretty sure that this is why it's taking so much longer to process and why the image file is so large. Another way I notice the manifestation of the same problem is that the Base Type of the original file (imagemagick identify command) is Bilevel, but the Base type of the smoothed tif is Grayscale.

Does anyone know how to change the channel depth using gdal_translate or something else? Keep in mind that this is georeferenced, and I can't afford to lose the georeferencing.

  • It sounds like your original raster is binary (each pixel is either on or off), and when you apply the guassian filter, it's creating a higher depth image to allow for more colors. This is necessary, since the guassian filter is just interpolating between the existing values in the image. I'm not sure if it would help the processing time at all, but you could likely significantly reduce the image file size by saving it as an indexed image (with a color pallet). – Evil Genius Aug 26 '15 at 19:19
  • 1
    I do not understand what is a DEM with 1-bit values. Does gdalinfo report it in a similar way? – user30184 Aug 26 '15 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.