aboutsummaryrefslogtreecommitdiffstats
path: root/common_gdal.py
diff options
context:
space:
mode:
Diffstat (limited to 'common_gdal.py')
-rw-r--r--common_gdal.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/common_gdal.py b/common_gdal.py
index 7333f58..b91f8c5 100644
--- a/common_gdal.py
+++ b/common_gdal.py
@@ -59,7 +59,7 @@ def gdalSetOpenExArgs(option_dict : Optional[dict[str, Any]] = {},
flags : int = 0) -> tuple[dict[str, int|list[str]], gdal.Driver]:
"""Return a pair kwargs and driver to use with gdal.OpenEx()."""
- kwargs = { 'nOpenFlags': gdal.OF_VECTOR | flags }
+ kwargs = { 'nOpenFlags': flags }
fmt = option_dict.get('format', None)
if fmt is None:
@@ -68,8 +68,10 @@ def gdalSetOpenExArgs(option_dict : Optional[dict[str, Any]] = {},
drv = gdal.GetDriverByName(fmt)
if drv is None:
raise RuntimeError(f'Unknown driver name "{fmt}"')
- if not gdalGetMetadataItem(drv, gdal.DCAP_VECTOR):
+ if flags & gdal.OF_VECTOR and not gdalGetMetadataItem(drv, gdal.DCAP_VECTOR):
raise RuntimeError(f'Driver "{drv.ShortName}" has no vector capabilities')
+ if flags & gdal.OF_RASTER and not gdalGetMetadataItem(drv, gdal.DCAP_RASTER):
+ raise RuntimeError(f'Driver "{drv.ShortName}" has no raster capabilities')
kwargs['allowed_drivers'] = [ drv.ShortName ]
oo = option_dict.get('open-options', None)