[gdal-dev] Memory error for gdal_grid if using nearest

Armin Schmidt Armin.R.Schmidt at Gmail.com
Fri Jul 17 09:53:02 PDT 2015

Hi Even,

I have converted it to a Spatialite file for easier download:

The problem is still the same. The offending command is:
gdal_grid.exe test.sqlite test.tif -ot Float32 -of GTiff -zfield 
Cond1_mSm -l 02vhidep_raw -a nearest

"-a invdist" works without a problem. Are the two algorithms not using 
the same search?

Since this problem only occurs with files covering France in 
RGF93/Lambert93 (I have tested two different files, both show the same 
problem) I wonder whether the range of coordinates of RGF93 may be the 
issue. All my other files so far never had this problem.


On 17/07/2015 01:20, Even Rouault wrote:
> On Thursday 16 July 2015 21:03:52 Armin Schmidt wrote:
>> I have a very simple point-shapefile which throws various memory
>> allocation errors when I try to grid it with gdal_grid using "nearest",
>> but works absolutely fine and fast when using the "invdist" algorithm. I
>> never had this problem before. Does anyone have any idea what is wrong?
>> If it would help I can provide the shapefile.
> Armin,
> That could be useful indeed. From your description, it looks like the building
> of the spatial index would went wrong with this particular dataset, looping
> forever or something like that and ending up eating all the memory.
> Even
>> The stripped down command-line is:
>> gdal_grid.exe 02VHiDep_raw.shp test.tif -ot Float32 -of GTiff -zfield
>> Cond1_mSm -l 02VHiDep_raw -a nearest
>> After taking some time (probably searching for the nearest neighbours),
>> this throws:
>> ERROR 1: CPLMalloc(): Out of memory allocating 64 bytes.
>> FATAL: CPLMalloc(): Out of memory allocating 64 bytes.
>> ERROR 1: TIFFWriteDirectorySec:Out of memory
>> ERROR 2: Cannot allocate 8192 bytes
>> ERROR 1: TIFFWriteDirectorySec:Out of memory
>> ERROR 1: TIFFWriteDirectorySec:Out of memory
>> Grid data type is "Float32"
>> Grid size = (256 256).
>> Corner coordinates = (449675.737076 6895223.317256)-(449705.249717
>> 6895209.690215).
>> Grid cell size = (0.114835 0.053024).
>> Source point count = 3280.
>> Algorithm name: "nearest".
>> Options are
>> "radius1=0.000000:radius2=0.000000:angle=0.000000:nodata=0.000000"
>> Armin

Dr. Armin Schmidt
Chief Developer, GeodataWIZ Ltd:  Geo Data + Visualisation
Chairman, Internat. Society for Archaeological Prospection
Honorary Visiting Research Fellow, University of Bradford
  Department of Archaeological Sciences
Honorary Fellow, Durham University, Department of Archaeology

Email: Armin.R.Schmidt at Gmail.com

Now available:
Earth Resistance for Archaeologists (2013). Lanham: AltaMira Press
Geophysical Data in Archaeology (2013). Oxford: Oxbow Books.

More information about the gdal-dev mailing list