Tile-based GRI resolver, downloader, cache, and investigation tools
Project description
gri_resolver
Tile-based GRI resolver, downloader, cache, and investigation tools.
- No runtime dependency on gcp_creator
- Tile-first resolution (no full catalog scan)
- Robust caching and optional force re-download
- Automatic quality-based selection (best image per tile)
- CLI with progress bars and JSON outputs
- Web interface for interactive tile management, visualization, and downloads
Install
python3 -m venv .venv
. .venv/bin/activate
pip install -U pip setuptools wheel
pip install -e .
Configuration
Defaults (override via CLI flags or env):
- GRI_BASE_URL (default
https://s3.eu-central-2.wasabisys.com/s2-mpc/catalog) - GRI_COLLECTION (default
GRI_L1C) - GRI_CACHE_DIR (default
<repo>/gri_resolver/cache) - GRI_OUTPUT_DIR (default
<repo>/gri_resolver/outputs) - GRI_TIMEOUT (default 60s)
- GRI_CACHE_TTL_HOURS (default 168h)
- GRI_FORCE=1 to ignore cache
- GRI_MAX_WORKERS (default 4)
- GRI_QUALITY_SELECTION (default 1, set to 0 to disable automatic quality selection)
- GRI_KEEP_MULTIPLE_PER_TILE (default 1, keeps historical images per tile)
- GRI_PREFER_RECENT (default 0, set to 1 to prefer more recent images in scoring)
Show current config:
gri-resolve resolve --show-config --json
CLI Overview
gri-resolve --help
Resolve and download
Resolve by tiles/ROI/region, download archives/images, and cache results.
# By tile(s)
gri-resolve resolve --tiles 31UDQ 33MUV --gri-base-url https://.../catalog --gri-collection GRI_L1C --progress
# By ROI (min_lon min_lat max_lon max_lat)
gri-resolve resolve --roi 2.0 48.0 3.0 49.0 --limit 3 --progress
# By region (predefined)
gri-resolve resolve --region gabon --limit 5 --progress
# Parallel downloads (e.g., 6 workers)
gri-resolve resolve --tiles 31UDQ 33MUV --max-workers 6 --progress
Outputs a summary (and JSON if --json or --report path.json).
Progress:
- “Tiles” bar for discovery (region/ROI)
- “Bytes” bar (parallel mode): cumulative download progress, with active tiles listed
- Per-item bar (serial mode): bytes + extracting stage
Presence (existence check by tile)
# By tiles
gri-resolve presence --tiles 31UDQ 33MUV --json
# By region / ROI (tiles computed then checked)
gri-resolve presence --region germany --json
gri-resolve presence --roi -5 41 10 51 --json
# Progress streaming (NDJSON)
gri-resolve presence --tiles 31UDQ 33MUV --progress --json --stream-json
Inspect (list metadata only)
# Tiles
gri-resolve inspect --tiles 31UDQ 33MUV --limit-per-tile 2 --json
# Region / ROI
gri-resolve inspect --region france --json
gri-resolve inspect --roi 2 48 3 49 --json
Coverage (list tiles only)
gri-resolve coverage --region gabon --json
gri-resolve coverage --roi -5 41 10 51 --json
Version
Display the package version:
# Show version only
gri-resolve version
# Show detailed version information (JSON)
gri-resolve version --json
Check Service Availability
Perform comprehensive health checks on the GRI service:
# Check GRI service availability
gri-resolve check
# Check with custom test tile
gri-resolve check --test-tile 31UDQ
# Check with JSON output
gri-resolve check --json
# Check with custom base URL and collection
gri-resolve check --gri-base-url https://.../catalog --gri-collection GRI_L1C
The check command performs three checks:
- Base URL: Verifies the GRI catalog base URL is accessible
- Collection: Verifies the specified collection is accessible
- Tile Access: Verifies that items can be retrieved for a test tile (default: 30TWT)
Exit codes:
0if all checks pass1if any check fails
This allows use in scripts and CI: gri-resolve check && echo "Service is up"
Web Interface
Start a web server for interactive tile management:
# Start server on default host/port (127.0.0.1:8000)
gri-resolve serve
# Custom host and port
gri-resolve serve --host 0.0.0.0 --port 8080
# Enable auto-reload for development
gri-resolve serve --reload
Then open http://localhost:8000 in your browser.
Features:
- Interactive map for ROI selection with MGRS tile overlay
- Download tiles by tile codes, ROI (drawn on map or coordinates), or predefined regions
- Real-time progress tracking with detailed activity log and byte-level progress bars
- Visualize cached images with previews (JP2/TIF supported via conversion)
- Rate images (0-5 stars) to mark favorites
- Delete images or entire tiles from cache
- Storage information dashboard showing disk usage, file counts, and top tiles by size
- Quicklook previews of top-rated images in tile listings
- Lazy loading of images for better performance
Regions
Some predefined regions exist (Africa subset + Europe quick bboxes). List them:
gri-resolve resolve --list-regions --json
API (Python)
from gri_resolver import GRIResolver, ResolverConfig
resolver = GRIResolver(ResolverConfig())
res = resolver.resolve_tiles(["31UDQ"], limit=1)
print(res.to_dict())
Notes & Behavior
- Resolution is tile-first: we try
*_item.jsonvia HEAD/GET; deep catalog scan is disabled by default for speed. - Quality selection: When multiple items exist for a tile, the resolver automatically selects the best one. Selection priority:
- User rating (if any image has been rated by the user, prefer the highest rated)
- Quality score (computed from metadata when no user ratings exist):
- Cloud cover (lower is better, if available in
eo:cloud_cover) - Sun elevation angle (higher is better, if available in
view:sun_elevation) - Recency (optional, if
GRI_PREFER_RECENT=1) Items without quality metadata receive a low but non-zero score and are still downloaded.
- Cloud cover (lower is better, if available in
- Caching: items already extracted are reused unless
--force/GRI_FORCE=1. The cache stores:- Quality scores and metadata for automatic selection
- User ratings (0-5 stars) for manual curation
- Multiple images per tile (historical) when
GRI_KEEP_MULTIPLE_PER_TILE=1The cache always returns the best image (prioritizing user ratings, then quality scores).
- Multiple images per tile: by default, the cache keeps multiple images per tile (historical), but always returns the best one. Set
GRI_KEEP_MULTIPLE_PER_TILE=0to keep only the best. - Archives:
.tar.gzsupported (extracts all.tif/.jp2/.tifffiles found); ZIP not yet supported. - Parallelism:
--max-workerscontrols concurrent downloads. - Progress: bars disabled when
--json/--reportto keep output machine-readable. Web interface shows real-time progress with detailed activity logs. - Image formats: The web interface can preview JP2 and TIF images by converting them to JPEG on-the-fly with contrast enhancement.
Web API Endpoints
The web server exposes a REST API for programmatic access:
GET /- Web interface (HTML)GET /api/config- Get current configurationGET /api/tiles- List all cached tiles with metadataGET /api/tiles/{tile_code}- Get details for a specific tileGET /api/tiles/{tile_code}/images/{item_id}- Get image file or preview (?preview=true)POST /api/tiles/{tile_code}/images/{item_id}/rate- Rate an image (0-5)DELETE /api/tiles/{tile_code}/images/{item_id}- Delete a specific imageDELETE /api/tiles/{tile_code}- Delete all images for a tilePOST /api/tiles/download- Start a download task (tiles, ROI, or region)GET /api/tasks/{task_id}- Get download task status and progressGET /api/storage- Get storage information (cache and output directories)GET /api/regions- List predefined regionsGET /api/geojson/tiles- Get MGRS tiles as simplified GeoJSON (for map overlay)GET /api/kml/tiles- Get MGRS tiles as KML (legacy format)
Troubleshooting
- No items found for a tile: verify the tile path exists in the catalog (e.g.,
.../GRI_L1C/T31/T31U/T31UDQ_item.json). - Mixed/too many tiles from ROI: increase/decrease
--sample-points; usepresenceto filter only existing tiles. - Verbosity: use
--progressfor human-friendly bars; omit it with--jsonfor clean JSON. - Web interface not loading: check that the server is running and accessible at the configured host/port.
- Image previews not showing: ensure
pillowandrasterioare installed (required for JP2/TIF conversion). - Slow MGRS tile layer: the GeoJSON endpoint uses aggressive simplification and viewport-based rendering for performance.
License
MIT License – see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gri_resolver-1.2.1.tar.gz.
File metadata
- Download URL: gri_resolver-1.2.1.tar.gz
- Upload date:
- Size: 10.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
10d61ec02017026f23edcf4401b9c02d94dd2529e473ceb491e51125b6929c91
|
|
| MD5 |
a13bbf381bc5b6959d0e033cec29d283
|
|
| BLAKE2b-256 |
5e24734de27389dc91bedaf3e40b8e989f5d0701ff0425413a7a099f5330434a
|
File details
Details for the file gri_resolver-1.2.1-py3-none-any.whl.
File metadata
- Download URL: gri_resolver-1.2.1-py3-none-any.whl
- Upload date:
- Size: 10.4 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eed262bfd26b8d5284cf63901a019b83c0a4afd8121c20d14514ee0d2d707cba
|
|
| MD5 |
bd76053f095f8256f99227418067538b
|
|
| BLAKE2b-256 |
2a1e4aedf3fe9d3a2413e6d21276fcded0907d58d30a693ae27470484b4df41d
|