From 7ffa6c549efcf2c85d56b4402110e5846a724f5f Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Wed, 23 Jul 2025 09:56:59 +0200 Subject: 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. --- common_gdal.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'common_gdal.py') 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) -- cgit v1.2.3