Skip to content

Commit f8c72f6

Browse files
committed
fix(mosaic): raise actionable MosaicError when GDAL bindings missing
_build_vrt imports `from osgeo import gdal`, which is not bundled with rasterio and not in any optional-dependency group. On systems without the GDAL Python bindings (including the CI integration runner) the import would fail with a bare ModuleNotFoundError. Wrap the import and raise MosaicError with install guidance instead. The `.tif` path through `_merge_tiles` does not need GDAL bindings, so the message points users there as a fallback.
1 parent 7d170f8 commit f8c72f6

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/abovepy/_mosaic.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,17 @@ def _build_vrt(
103103
Path
104104
Path to the created VRT file.
105105
"""
106-
from osgeo import gdal
106+
try:
107+
from osgeo import gdal
108+
except ImportError as exc:
109+
from abovepy._exceptions import MosaicError
110+
111+
raise MosaicError(
112+
"VRT construction requires the GDAL Python bindings, which are not "
113+
"installed by default. Install with `conda install -c conda-forge gdal` "
114+
"(recommended) or `pip install gdal` (requires matching system GDAL headers). "
115+
"Alternatively, pass an output path ending in `.tif` to merge via rasterio."
116+
) from exc
107117

108118
gdal.UseExceptions()
109119

0 commit comments

Comments
 (0)