Jesse,
Le 18/10/2024 à 21:15, Meyer, Jesse R. (GSFC-618.0)[SCIENCE SYSTEMS AND
APPLICATIONS INC] via gdal-dev a écrit :
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.
Admitedly true, although the "recommended" way since the GDAL 2.0 GDAL
and OGR unification, at least on the C/C++ side of things.
The good news is that in GDAL 3.10 in Python bindings as well,
ogr.DataSource is just now an alias of gdal.Dataset, so you can use
ogr.GetDriverByName(...).CreateDataSource(...) as a valid gdal.Dataset
>>> from osgeo import ogr
>>> ds = ogr.GetDriverByName('Memory').CreateDataSource('')
>>> ds
<osgeo.gdal.Dataset; proxy of <Swig Object of type 'GDALDatasetShadow *'
at 0x7fc32f3d9600> >
Even
--
http://www.spatialys.com
My software is free, but my time generally not.
Butcher of all kinds of standards, open or closed formats. At the end, this is
just about bytes.
_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev