[gdal-dev] Rasterize Inmem vector

Even Rouault even.rouault at spatialys.com
Mon Jul 31 07:42:22 PDT 2017


On lundi 31 juillet 2017 07:31:05 CEST Johan de Braak wrote:
> Hi all,
> 
> How would I rasterize an in memory vector? I have tried this:
> 
>     assert isinstance(inmemds, ogr.DataSource), 'inmemds is not a ogr
> DataSource' #assert not triggered
> 
>     rastoptions = gdal.RasterizeOptions(outputType=gdal.GDT_Byte,
> burnValues=1, xRes=100, yRes=100)
> 
>     ds = gdal.Rasterize('/vsimem/tmp_{}'.format(uuid4().hex), inmemds,
> options=rastoptions)
> 
> 
> gives:
> 
>     TypeError: in method 'wrapper_GDALRasterizeDestName', argument 2 of type
> 'GDALDatasetShadow *'
> 
> The docstring of gdal.Rasterize says the following:
> 
>     Arguments are :
>       destNameOrDestDS --- Output dataset name or object
>       srcDS --- a Dataset object or a filename
> 
> So srcDS can be a Dataset, right? As I missing something?

Yes, srcDS must be a gdal.Dataset, not a ogr.DataSource

so use gdal.GetDriverByName("Memory").Create("", 0, 0, 0, gdal.GDT_Unknown) to create it

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/20170731/0a93b2cc/attachment.html>


More information about the gdal-dev mailing list