1

I use gdal_grid within a Python script, but for my large files the calculation time is enormous. Apparently this is a gdal_grid issue http://trac.osgeo.org/gdal/ticket/2411

Does anyone have an advice / some code which can serve as a simple alternative to gdal_grid?

5
  • Give some information for reproducing the gdal_grid issue. How big is a large file? Which GDAL version, what command did you use?
    – user30184
    Aug 22, 2014 at 6:29
  • File size is 1520x2240 pixels, GDAL 1.11 --- A colleague tells me that gridding the same file size in Matlab goes very much faster. I mainly look for an alternative way of gridding data in Python with gdal, if anyone happens to have one. Detailed info on what I do here geoinformaticstutorial.blogspot.no/2014/07/…
    – Max
    Aug 22, 2014 at 6:42
  • Have you asked from GDAL developers about the situation of that ancient ticket and if the general development in GDAL during the past six years have brought new possibilities for speed improvements?
    – user30184
    Aug 22, 2014 at 7:49
  • Interesting reading but repeating all that feels a bit too tedious for me. Could you create some artificial point dataset and gdal_grid command line for demonstrating the sluggish speed of gdal_grid?
    – user30184
    Aug 22, 2014 at 10:40
  • Have you thought that csv must be one the worst input formats for your task because it can't be indexed with spatial index? I would try to convert your .vrt into shapefile, create a spatial index with shptree utility and make a new test with gdal_grid. It may be that gdal_grid can't utilize spatial index but if it can then the speed improvement should be dramatic.
    – user30184
    Aug 22, 2014 at 12:03

2 Answers 2

1

I am using gdal_grid to generate rasters from point data using Python. Right now I am dealing with the same issue as you do, so I am testing as much as I can before taking my chance with another library.

My advice would be to use the options for multiple cores and as much cache as you can give.

--config 'NUM_THREADS=ALL_CPUS GDAL_CACHEMAX=2000'

The gdal grid does not have an option to let you allocate as much memory as you wish. I would like to see if this increases performance or not.

If you are using "invdist" interpolator, it is best not to use a search radius because you will add a spatial filter. This is explained in the code. You can check it here

https://svn.osgeo.org/gdal/trunk/gdal/alg/gdalgrid.cpp

The interpolator config should look like this:

-a invdist:power=2.0:smoothing=0.0

I am about to test the -clipsrc option to limit the output raster to the region of interest since my polygons are not uniform.

I am using a i7 (3.6GHz) with 8GB of memory. My input data has less than 200.000 features, 16bits values, and the interpolation time is about 3 min.

1

I finally got a workaround by using the Generic Mapping Tool gmt. I used the nearneighbour command, which does the gridding much faster than gdal_grid:

http://gmt.soest.hawaii.edu/doc/5.1.0/nearneighbor.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.