Bug Report: Rasterio Coverage Requests Fail for GCS/VSI Paths Without Bbox Parameter
Description
Coverage requests to rasterio providers using GDAL Virtual File System (VSI) paths (e.g., /vsigs/ for GCS) succeed when a bbox parameter is included, but fail with FileNotFoundError when no bbox is specified.
The root cause is an early-return optimization in pygeoapi's rasterio provider that bypasses rasterio/GDAL for native format requests with no bands, subsets, or bbox (i.e a plain {collectionsid}/coverage?f=GTiff type call). This shortcut delegates to util.read_data(), which only recognizes http:// and s3:// as remote paths and treats all other paths (including /vsigs/) as local file paths. GDAL VSI paths cannot be opened with Path.open("rb"), causing the failure.
Requests with a bbox parameter continue through the full rasterio/GDAL code path, which correctly handles VSI paths, so they succeed.
Steps to Reproduce
-
Configure a pygeoapi coverage collection with a rasterio coverage provider pointing to a GCS object via /vsigs/ path (e.g., /vsigs/bucket-name/file.tif)
-
Ensure GOOGLE_APPLICATION_CREDENTIALS is set and valid with GCS read permissions
-
Request the coverage without a bbox parameter: GET /collections/raster_collection/coverage?format=tif
-
Observe error:FileNotFoundError: [Errno 2] No such file or directory: '/vsigs/bucket-name/file.tif'
-
Request the same coverage with a bbox parameter: GET /collections/raster_collection/coverage?bbox=3.0,56.5,32.0,71.5&format=tif
-
Observe the request succeeds and returns the raster data
Expected Behavior
Coverage requests should handle GDAL VSI paths correctly regardless of whether optional parameters like bbox are present. Both requests should succeed when the credentials and path are valid.
Environment
- pygeoapi version: 0.24.0
- Python version: 3.11 (in geopython/pygeoapi:0.24.0 base image)
- Operating System: Windows 10/11 (Docker Desktop)
- GDAL/rasterio version: Latest in base image (rasterio 1.3.x+)
- Storage backend: Google Cloud Storage (GCS) via
/vsigs/ VSI path
Bug Report: Rasterio Coverage Requests Fail for GCS/VSI Paths Without Bbox Parameter
Description
Coverage requests to rasterio providers using GDAL Virtual File System (VSI) paths (e.g.,
/vsigs/for GCS) succeed when abboxparameter is included, but fail withFileNotFoundErrorwhen nobboxis specified.The root cause is an early-return optimization in pygeoapi's rasterio provider that bypasses rasterio/GDAL for native format requests with no bands, subsets, or bbox (i.e a plain {collectionsid}/coverage?f=GTiff type call). This shortcut delegates to
util.read_data(), which only recognizeshttp://ands3://as remote paths and treats all other paths (including/vsigs/) as local file paths. GDAL VSI paths cannot be opened withPath.open("rb"), causing the failure.Requests with a bbox parameter continue through the full rasterio/GDAL code path, which correctly handles VSI paths, so they succeed.
Steps to Reproduce
Configure a pygeoapi coverage collection with a rasterio coverage provider pointing to a GCS object via
/vsigs/path (e.g.,/vsigs/bucket-name/file.tif)Ensure
GOOGLE_APPLICATION_CREDENTIALSis set and valid with GCS read permissionsRequest the coverage without a bbox parameter: GET /collections/raster_collection/coverage?format=tif
Observe error:FileNotFoundError: [Errno 2] No such file or directory: '/vsigs/bucket-name/file.tif'
Request the same coverage with a bbox parameter: GET /collections/raster_collection/coverage?bbox=3.0,56.5,32.0,71.5&format=tif
Observe the request succeeds and returns the raster data
Expected Behavior
Coverage requests should handle GDAL VSI paths correctly regardless of whether optional parameters like
bboxare present. Both requests should succeed when the credentials and path are valid.Environment
/vsigs/VSI path