Am 1. Juni 2017 20:21:21 MESZ schrieb Even Rouault <[email protected]>:
>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)

Thanks Even, for the fast response. You mention the OGRDataSource as legacy. 
I wasn't aware of that fact. Is there anything important to know about that, 
because I would need to port quite some code to use the GDALDataset. 

Kai
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to