[gdal-dev] [EXTERNAL] Re: 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 14:55:50 PDT 2024


Good news indeed, thanks Even!

Best,
Jesse

Lead Computer Scientist
Science Systems and Applications, Inc.
Dr Compton Tucker Team
NASA Goddard Space Flight Center

From: Even Rouault <even.rouault at spatialys.com>
Date: Friday, October 18, 2024 at 5:46 PM
To: Meyer, Jesse R. (GSFC-618.0)[SCIENCE SYSTEMS AND APPLICATIONS INC] <jesse.r.meyer at nasa.gov>, Meyer, Jesse R. (GSFC-618.0)[SCIENCE SYSTEMS AND APPLICATIONS INC] via gdal-dev <gdal-dev at lists.osgeo.org>
Subject: [EXTERNAL] Re: [gdal-dev] OGR support in gdal.x functions
CAUTION: This email originated from outside of NASA.  Please take care when clicking links or opening attachments.  Use the "Report Message" button to report suspicious messages to the NASA SOC.



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<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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20241018/d282ff0d/attachment.htm>


More information about the gdal-dev mailing list