Support cropped (bbox/extent) exports and raster (.tif) caching #14
Description
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:
-
No AOI/extent cropping.
post_export(post_export.py) builds the request body with onlyformats+items(+ optional namedtiles).ExportRequestSchema.extent(schemas.py) is typedextent: None = Noneand never set, so every export is the whole layer. ThePolygonExtent/MultiPolygonExtentschemas and theis_croppedresponse field are scaffolded but not wired through. A whole national DEM is far too large to download for a small area of interest. -
GeoPackage-only caching path.
get_latest_layer(get_latest.py) hardcodes…_{hash}.gpkgandglob("*.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
- Thread an optional
extent(a GeoJSON Polygon/MultiPolygon, EPSG:4326 per the Koordinates API) throughget_layer_from_id→download_layer→create_export→post_export→ExportRequestSchema.extent, so callers can request a cropped export. - Make
get_latest_layer(anddownload_layer) raster-aware: when the layerkindisgrid, expect/cache a.tif(…_{hash}.tif, glob*.tif) instead of.gpkg. Drive the extension offLayerDetails.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.tifand are reused on repeat requests (version-aware, as today for vector). - Existing vector behaviour unchanged.
Activity