Skip to content

Rasterio Coverage Requests Fail for GCS/VSI Paths Without Bbox Parameter #2402

Description

@tevbrasch

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

  1. 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)

  2. Ensure GOOGLE_APPLICATION_CREDENTIALS is set and valid with GCS read permissions

  3. Request the coverage without a bbox parameter: GET /collections/raster_collection/coverage?format=tif

  4. Observe error:FileNotFoundError: [Errno 2] No such file or directory: '/vsigs/bucket-name/file.tif'

  5. Request the same coverage with a bbox parameter: GET /collections/raster_collection/coverage?bbox=3.0,56.5,32.0,71.5&format=tif

  6. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions