Rasterize Inmem vector

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Rasterize Inmem vector

Johan de Braak
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?

Regards,

Johan
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Rasterize Inmem vector

Even Rouault-2

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


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