Opened 16 years ago
Closed 6 years ago
#2023 closed enhancement (fixed)
Add a Python wrapper for GDALGridCreate() function
Reported by: | dron | Owned by: | hobu |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | PythonBindings | Version: | unspecified |
Severity: | normal | Keywords: | |
Cc: | warmerdam, chrisbarker, Ari Jolma |
Description
The recently added GDALGridCreate(http://www.gdal.org/gdal__alg_8h.html#272e099fee92569aff154bbb035fc7c1) function needs to be wrapped for use in Python. The function takes three floating point arrays pdfX, pdfY and pdfZ as input and outputs an interpolated data as a regular array of specified data type and dimensions.
To control the interpolation process function takes the algorithm name and algorithm options. There are different set of options for every particular algorithm. At the moment we have GDALGridInverseDistanceToAPowerOptions (http://www.gdal.org/structGDALGridInverseDistanceToAPowerOptions.html), GDALGridMovingAverageOptions(http://www.gdal.org/structGDALGridMovingAverageOptions.html) and GDALGridNearestNeighborOptions(http://www.gdal.org/structGDALGridNearestNeighborOptions.html) structures for three available algorithms. I am thinking about passing this options to Python function in form of dictionary:
options["algorithm"] = "nearest" options["radius1"] = 12.3 options["radius2"] = 34.5
The whole Python API could look like that:
GridCreate(numpy_array, (minx,miny,maxx,maxy), nXSize, nYSize, eType, options)
numpy_array is a 2D NumPy array containing all three pdfX, pdfY and pdfZ vectors.
Change History (9)
comment:1 by , 16 years ago
Cc: | added |
---|
comment:2 by , 16 years ago
Andrey,
I don't think I will be able to get to this before the release on Tuesday...
I think we would want to use the numpy swig typemap stuff from numpy's subversion repository to make the array coercion easier http://svn.scipy.org/svn/numpy/trunk/numpy/doc/swig/
comment:3 by , 16 years ago
Cc: | added |
---|
cc'ing Chris in case he can add some insight to what's going on in swig/numpy land, as I've seen some traffic on the swig lists lately...
comment:4 by , 16 years ago
Howard,
There is no any urgency with this wrapper. I just need it to simplify a tests creation before I will continue GDALGrid development and that will go in new post-1.5 GDAL branch anyway.
Best regards,
Andrey
comment:5 by , 16 years ago
Cc: | added |
---|
Hmm, this would of course be useful for Perl wrappers too. But.. in fact I'd like the API to be something like dataset = GridCreate(layer_of_multiple_points, ...), so it would be easy to integrate into an application.
But nevermind, I can build the extra layer in Perl bindings too.
Regards,
Ari
ps: isn't this an enhancement and not a defect?
comment:6 by , 16 years ago
Type: | defect → enhancement |
---|
Ari,
Do you mean to pass OGR layer as an input parameter? I would like not to do that for four reasons:
- It is better to keep bindings for different languages with the same set of parameters.
- Often you need to process the SQL query results and not a single layer, so functionality of the GDALGridCreate() should be flexible enough to allow this.
- Sometimes you want to get Z value from the semantic field and not from the geometry, so we need more flexible function again.
- It is very common to pass XYZ data in form of simple CSV file, that is very easy to parse in script and create input array without any connection to OGR at all.
If you really like a function that gets OGR layer as input I can create an appropriate C wrapper on top of GDALCreateGrid() and that function could be exposed in bindings along with GDALCreateGrid().
Best regards,
Andrey
comment:7 by , 10 years ago
I just ran across this because I find myself in need of this functionality. Was this enhancement ever done? I've searched through the gdal import and can't find a GridCreate function.
comment:8 by , 10 years ago
The Java bindings has been done, but the Python bindings still not. Contributions or funding are always welcome.
comment:9 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
gdal.Grid() is available in Python bindings
CC'ing Frank for any input he might have on this
Here was our IRC output: