Skip to content

Support cropped (bbox/extent) exports and raster (.tif) caching #14

Open

Description

@b-j-karl

Problem

koop cannot currently download a clipped layer or cache a raster, which blocks using it to acquire large rasters (e.g. national LINZ DEMs) for a small AOI.

Two gaps:

  1. No AOI/extent cropping. post_export (post_export.py) builds the request body with only formats + items (+ optional named tiles). ExportRequestSchema.extent (schemas.py) is typed extent: None = None and never set, so every export is the whole layer. The PolygonExtent/MultiPolygonExtent schemas and the is_cropped response field are scaffolded but not wired through. A whole national DEM is far too large to download for a small area of interest.

  2. GeoPackage-only caching path. get_latest_layer (get_latest.py) hardcodes …_{hash}.gpkg and glob("*.gpkg"), raising "Should only be one geopackage per export" if the export is not exactly one geopackage. A raster (grid) layer exports a .tif, so the raster path errors — despite the README advertising raster (GeoTIFF) support.

Proposed change

  1. Thread an optional extent (a GeoJSON Polygon/MultiPolygon, EPSG:4326 per the Koordinates API) through get_layer_from_id → download_layer → create_export → post_export → ExportRequestSchema.extent, so callers can request a cropped export.
  2. Make get_latest_layer (and download_layer) raster-aware: when the layer kind is grid, expect/cache a .tif (…_{hash}.tif, glob *.tif) instead of .gpkg. Drive the extension off LayerDetails.kind.

Why

tonkintaylor/yyyttnz-0730-6-009-cv-landslides (#13) needs AOI-clipped LINZ DEMs. We are hand-rolling a thin client there for now and intend to migrate to koop once the above land — koop is the right home for Koordinates operations and already has the version-aware caching, export/poll/download/unzip flow, and multi-domain auth.

Acceptance

  • get_layer_from_id(..., extent=<geojson>) produces a server-side cropped export.
  • Raster (grid) layers download and cache as .tif and are reused on repeat requests (version-aware, as today for vector).
  • Existing vector behaviour unchanged.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions