aboutsummaryrefslogtreecommitdiffstats
path: root/common_gdal.py
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2025-07-23 09:56:59 +0200
committerGuilhem Moulin <guilhem@fripost.org>2025-07-23 15:21:20 +0200
commit7ffa6c549efcf2c85d56b4402110e5846a724f5f (patch)
tree697fd2594bbb77d9e80f73e34c62002ae2f68b8b /common_gdal.py
parent91abd89d67748a1e057d1299698d506613ee0f9f (diff)
Add logic to export raster files (as COG).
Raster data is not stored in the PostGIS database. Instead, the mtime of the target directory is used to determine whether the COG is up to date. Add a new flag --metadata-compress for JSON metadata compression (which also applies to MVT metadata), and --rasterdir for the target raster directory.
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)