[gdal-dev] OGR support in gdal.x functions

Meyer, Jesse R. (GSFC-618.0)[SCIENCE SYSTEMS AND APPLICATIONS INC] jesse.r.meyer at nasa.gov
Fri Oct 18 12:15:08 PDT 2024


We have a bunch of legacy code that uses from osgeo import gdal, ogr, where raster datasets are created with gdal and vector datasets with ogr.   However, these don’t mix well when, say, rasterizing a vector dataset with gdal.rasterize.  The ‘workaround’ is to create a vector dataset using gdal:

vector_ds = gdal.GetDriverByName("Memory").Create(“”, 0, 0, 0, gdal.GDT_Unknown)

But this is arcane and quite unintuitive.  Unless there’s another approach I’m unaware of.

Could gdal.rasterize’s second parameter be made to support datasets from: ogr.GetDriverByName(driver_name).CreateDataSource(""), and similar?

Currently, trying to source an OGR dataset directly results in the following exception:
TypeError: in method 'wrapper_GDALRasterizeDestDS', argument 2 of type 'GDALDatasetShadow *'

Best,
Jesse

Lead Computer Scientist
Science Systems and Applications, Inc.
Dr Compton Tucker Team
NASA Goddard Space Flight Center
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20241018/846e1188/attachment.htm>


More information about the gdal-dev mailing list