[gdal-dev] DataSource/Dataset using gdal.Grid()
Even Rouault
even.rouault at spatialys.com
Thu Jun 1 11:21:21 PDT 2017
On jeudi 1 juin 2017 18:13:00 CEST Kai Muehlbauer wrote:
> Hi everyone,
>
> I'm using python-bindings gdal.Grid() function to grid scattered data.
>
> I have a in-memory vector point data inside <class
> 'osgeo.ogr.DataSource'> "ds" which I want to feed directly to gdal.Grid().
>
> ds2 = gdal.Grid('', ds, format='MEM',
> width=900, height=900,
> algorithm=algo,
> zfield='ZX')
>
> Unfortunately I get a "TypeError: in method 'GridInternal', argument 2
> of type 'GDALDatasetShadow *'", see complete trace at the end.
>
> If I save this dataset as is to an ESRI-Shapefile "test", I can
> successfully do this:
>
> ds2 = gdal.Grid('', 'test', format='MEM',
> width=900, height=900,
> algorithm=algo,
> zfield='ZX')
>
> Although I'm happy to get this running that way, I really would avoid
> the save-to-disc part. Can I somehow fake my <osgeo.ogr.DataSource>
> object to behave like a Dataset object or do some other magic? Any hints
> very much appreciated.
gdal.Grid() and other utility-as-a-function requires GDALDataset and not
legacy OGRDataSource,
so create your vector memory dataset with :
ds = gdal.GetDriverByName('Memory').Create('', 0, 0, 0, gdal.GDT_Unknown)
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20170601/3bcc13c3/attachment.html>
More information about the gdal-dev
mailing list