[gdal-dev] gdal_contour out of memory

Even Rouault even.rouault at spatialys.com
Thu Apr 7 03:58:50 PDT 2016


Stefan,

> I have problems creating contours with gdal_contour and some tiff files.
> The following command
> 
> gdal_contour -i 1.0 6800_2480.tif out.shp
> 
> ends with "0Killed" after eating all memory and all swap. It happens with
> gdal 1.11 and gdal-master. It did work on a Ubuntu 10.04 machine (as far as
> I remember). Now I'm on Ubuntu 14.04.

Comparing the source code, the algorithm hasn't fundamentaly changed, at least 
since GDAL 1.5. I can reproduce your issue with latest trunk or 1.5.X.
It is related to the fact that your source dataset has floating point values.
An easy workaround is to translate your raster into a Int16 one and contour 
it. I've just tried it and it works. 
Or you could possibly round values to 0.5 precision with gdal_calc.py for 
perhaps a smoother result. But basically the contour alg seems to require a 
lot of memory if every pixel is different from its neighbour (might be an 
approximation of what happens as the algorithm is non trivial and I didn't 
study it in detail).
It might be worth opening a ticket on that.

Even

> 
> Tiff file can be found here:
> http://maps.zh.ch/download/hoehen/2014/dtm/tif/6800_2480.tif
> 
> Any ideas?
> 
> regards
> Stefan

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list