[gdal-dev] Fwd: Problem with gdal.Rasterize utility : argument GDALDatasetShadow in wrapper_GDALRasterizeDestName
Even Rouault
even.rouault at spatialys.com
Fri Jul 15 10:36:57 PDT 2016
Le vendredi 15 juillet 2016 19:32:14, François ALLAIN a écrit :
> I am now trying to do this process as an in-memory process.
> I coudl figure out how to load the .tif in-memory :
>
> # Create in-memory file and initialize it with the content
> gdal.FileFromMemBuffer('/vsimem/tiffinmem', self.file)
>
> # Open the in-memory file
> ds = gdal.Open('/vsimem/tiffinmem', gdal.GA_Update)
>
> But i've got some problem to get a
> <osgeo.gdal.Dataset; proxy of <Swig Object of type 'GDALDatasetShadow *'
> from a geojson... Here are my vain attemps:
>
>
> #create an output datasource in memory
> outdriver=ogr.GetDriverByName('MEMORY')
> source=outdriver.CreateDataSource('memData')
> # <osgeo.ogr.DataSource; proxy of <Swig Object of type 'OGRDataSourceShadow
> *'
> #open the memory datasource with write access
> tmp=outdriver.Open('memData',1)
>
> import os
> import sys
> from osgeo import gdal, ogr, osr
> geojson =
> """{"type":"Polygon","coordinates":[[[-76.4603750,45.4506926],[-76.4603632,
> 45.4506998],[-76.4603522,45.4506914],[-76.4603639,45.4506845],[-76.4603750,
> 45.4506926]]]}""" geometry = ogr.CreateGeometryFromJson(geojson)
> # print type(geometry)
> # <class 'osgeo.ogr.Geometry'>
>
> I know that i need to build a GDALDatasetShadow object from the
> OGRDataSourceShadow
> object and the osgeo.ogr.Geometry object but i've got no clue after
> searching on the web :
> http://www.gdal.org/classGDALDataset.html#a9cb8585d0b3c16726b08e25bcc94274a
> https://pcjericks.github.io/py-gdalogr-cookbook/vector_layers.html#load-dat
> a-to-memory
> https://pcjericks.github.io/py-gdalogr-cookbook/vector_layers.html#spatial
> -filter
>
> Could please give a hint ?
Have a look at test_gdal_rasterize_lib_1() in
https://svn.osgeo.org/gdal/trunk/autotest/utilities/test_gdal_rasterize_lib.py
Even
--
Spatialys - Geospatial professional services
http://www.spatialys.com
More information about the gdal-dev
mailing list