### Format examples Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/stac-extension/README.md Format the example files using the format-examples script. ```bash npm run format-examples ``` -------------------------------- ### Install dependencies and run migrations with uv Source: https://github.com/hotosm/openaerialmap/blob/main/backend/uploader-api/README.md Uses uv to sync all groups. Migrations do not run on app startup, so apply them once before running outside compose. Then start the FastAPI app with uvicorn on port 8080. ```bash uv sync --all-groups # Migrations don't run on app startup. Apply them once before running outside compose: MIGRATIONS_DIR=./migrations DB_HOST=localhost DB_USER=oam \ DB_PASSWORD=oam DB_NAME=oam_uploader \ ./migrate-entrypoint.sh uv run uvicorn app.main:app --reload --port 8080 ``` -------------------------------- ### Install uploader-api Helm chart (production and local) Source: https://github.com/hotosm/openaerialmap/blob/main/backend/uploader-api/chart/README.md Install the uploader-api Helm chart. The first command configures a production deployment with an external PostgreSQL/PostGIS database (pgstac) and asset base URL, enabling ingress with TLS. The second command installs a local single-cluster setup using bundled ephemeral DB and disabled auth via chart/values.local.yaml. ```bash helm upgrade --install uploader-api ./chart -n oam --create-namespace \ --set existingSecret.name=oam-uploader-secrets \ --set env.PGSTAC_DB_HOST=pgstac.internal --set env.PGSTAC_DB_USER=oam \ --set env.PGSTAC_DB_NAME=postgis \ --set env.PUBLIC_ASSET_BASE_URL=https://cdn.openaerialmap.org \ --set ingress.enabled=true --set ingress.tls.enabled=true ``` ```bash helm upgrade --install uploader-api ./chart -n oam --create-namespace \ -f chart/values.local.yaml ``` -------------------------------- ### Check Markdown and examples Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/stac-extension/README.md Run the test suite to check Markdown and examples. ```bash npm test ``` -------------------------------- ### Install dependencies Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/stac-extension/README.md Install the project dependencies using npm. ```bash npm install ``` -------------------------------- ### Install dependencies and run dev server Source: https://github.com/hotosm/openaerialmap/blob/main/frontend/README.md Install dependencies with pnpm and start the Vite development server on port 3000. Defaults point at production PMTiles and TiTiler-PgSTAC; override via .env. ```bash pnpm install pnpm run dev # vite on :3000 ``` -------------------------------- ### Sync Dependencies with uv Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stac-ingester/README.md Installs all dependencies including all groups after installing uv. ```bash uv sync --all-groups ``` -------------------------------- ### Install pre-commit hooks Source: https://github.com/hotosm/openaerialmap/blob/main/CONTRIBUTING.md Install and activate the pre-commit hooks used in this repository to enforce coding style for Python, TypeScript/JavaScript, Markdown, and SQL. ```bash pip install pre-commit pre-commit install ``` -------------------------------- ### Start all services and populate sample data Source: https://github.com/hotosm/openaerialmap/blob/main/docs/dev/local-setup.md Starts the core OAM stack with Docker Compose and loads sample data from the production STAC API. Requires Docker with Compose v2 and the 'just' command runner. After running, open http://imagery.localhost:8080 to view the frontend. ```sh # Start all core services just start all # Load sample data from production just test populate-prod ``` -------------------------------- ### Install dependencies with uv sync --all-extras Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/README.md Installs all dependencies including extras using uv. Run from the package directory. ```bash uv sync --all-extras ``` -------------------------------- ### Copy .env.example to .env Source: https://github.com/hotosm/openaerialmap/blob/main/docs/dev/local-setup.md Copies the example environment file to .env at the repo root. The compose file reads from .env via 'set dotenv-load' in the root Justfile, so this is required to customise configuration values. ```sh cp .env.example .env ``` -------------------------------- ### Define an OpenDataCatalog in stac.py Source: https://github.com/hotosm/openaerialmap/blob/main/docs/dev/ingest/new-provider.md Create a stac.py file in the provider directory with an OpenDataCatalog instance. The example uses the 'Example' provider and 'example-opendata' collection. The default implementation walks the source catalog, clones items, adds OAM properties, and validates the result. ```python from pystac import Provider, ProviderRole from stactools.hotosm import opendata CATALOG = opendata.OpenDataCatalog( key="Example", collection_id="example-opendata", collection_description="Example open imagery", catalog_url="https://example.org/stac/catalog.json", producer_name="Example", platform_type="satellite", providers=[ Provider( name="Example", url="https://example.org", roles=[ProviderRole.PRODUCER, ProviderRole.LICENSOR], ) ], ) ``` -------------------------------- ### Install dependencies with uv sync Source: https://github.com/hotosm/openaerialmap/blob/main/backend/global-mosaic/README.md Install Python dependencies using uv. Requires uv to be installed first. ```bash uv sync --all-groups ``` -------------------------------- ### Start STAC API with Docker Compose Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stac-api/README.md Starts the STAC FastAPI PgSTAC application using Docker Compose. ```bash docker compose up app ``` -------------------------------- ### Run local development environment Source: https://github.com/hotosm/openaerialmap/blob/main/backend/tilepack-api/README.md Starts the Go API locally with Docker Compose. Requires AWS credentials and a STAC URL; the worker side needs a real Kubernetes cluster. ```sh docker compose up --build ``` -------------------------------- ### Example Job log output Source: https://github.com/hotosm/openaerialmap/blob/main/docs/dev/ingest/backfill.md Example log output from a Job run. `Completed ingesting N` is the number of Items built, not the number accepted by PgSTAC. ```text Found 6600 metadata items added since 2024-01-01 00:00:00+00:00 Skipping 6524 Items already in PgSTAC Completed ingesting 76 STAC Items ``` -------------------------------- ### Output: processing start Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/OAM STAC Items.ipynb Output showing the total number of items to process. ```text Going to process 17930 items from entire catalog ``` -------------------------------- ### Run end-to-end tests with Talos and Argo via just recipes Source: https://github.com/hotosm/openaerialmap/blob/main/backend/uploader-api/README.md From the repo root, these just recipes spin up a local Talos-in-Docker cluster with Argo, apply the WorkflowTemplate, and run an upload through the whole pipeline. Needs docker; talosctl/kubectl/jq are installed on demand. Use your own GeoTIFF path or a sample image. ```bash just test cluster-init # Talos cluster + Argo + template + secret just test uploader-e2e # start services, push an upload, wait for register # just test uploader-e2e path/to/image.tif # your own GeoTIFF (else a sample) just k8s cluster-destroy # tear down ``` -------------------------------- ### Run local dump and tests Source: https://github.com/hotosm/openaerialmap/blob/main/docs/dev/ingest/new-provider.md Run from backend/stactools-hotosm. Dumps a collection and example items, then runs the test script. The date option is required for the default catalogue walk but only filters when timestamp_property is set. ```bash uv run hotosm dump-collection --catalog Example --file collection.json uv run hotosm dump-example \ --uploaded-after 2020-01-01 \ --handle-exceptions IGNORE \ --file items.ndjson ./scripts/test ``` -------------------------------- ### Install pre-commit hooks Source: https://github.com/hotosm/openaerialmap/blob/main/AGENTS.md Install pre-commit and its hooks. Pre-commit is mandatory and runs ruff, ruff-format, uv-lock, pyupgrade, codespell, oxfmt, bashate, shellcheck, markdownlint, and commitizen. ```bash uv tool install pre-commit pre-commit install ``` -------------------------------- ### Example Output Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/STAC Ingest.ipynb The console output displayed after successfully processing an NDJSON file. ```text Output: Loading Items from maxar-opendata-20250505T085548.ndjson ``` -------------------------------- ### Start standalone uploader stack with docker compose Source: https://github.com/hotosm/openaerialmap/blob/main/backend/uploader-api/README.md Runs the self-contained compose.yaml stack (API, migrations, Postgres, S3 via rustfs) for end-to-end upload testing without the rest of OAM. With AUTH_PROVIDER=disabled, a local-admin user is available at http://localhost:8090. Use the Python script to push a real multipart upload (no browser, so no S3 CORS needed). ```bash # Standalone stack (easiest for working on the uploader): docker compose up --build # open http://localhost:8090 (AUTH_PROVIDER=disabled gives you a local-admin user) # Push a real multipart upload through it (no browser, so no S3 CORS needed): python scripts/test-upload.py path/to/image.tif # then check http://localhost:8090/ under "Your uploads" ``` -------------------------------- ### Build, run, and test the stac-browser Docker image Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stac-browser/README.md Builds the custom STAC Browser image, runs it on port 8080 with the SB_catalogUrl environment variable, and fetches the generated runtime-config.js to verify the setup. ```sh docker build -t oam-stac-browser backend/stac-browser docker run --rm -p 8080:8080 \ -e SB_catalogUrl=https://api.imagery.hotosm.org/stac \ oam-stac-browser curl -s localhost:8080/runtime-config.js ``` -------------------------------- ### Just commands for development Source: https://github.com/hotosm/openaerialmap/blob/main/AGENTS.md Core `just` commands for starting, stopping, testing, and preparing the OpenAerialMap stack. Use these instead of raw docker or pytest invocations. ```bash just start all # Bring up the core stack (docker compose up -d --build) just start all-tms # Core stack plus global TMS tiles just start stop # Tear down just start logs # Follow one service's logs just test all # Every unit suite (uploader, stactools, stac-extension, tilepack-api) just test uploader # Uploader suites only, in the built test image just test chart # Helm chart rendering tests, on the host just chart build # Lint, resolve dependencies, and package the chart just prep machine # Install host tooling ``` -------------------------------- ### Example per-item TiTiler URL for Freetown 2025 Source: https://github.com/hotosm/openaerialmap/blob/main/docs/usage/using-imagery.md Example URL using the Freetown 2025 dataset item ID. Includes &nodata=0 for older images with black borders. ```text https://tiles.imagery.hotosm.org/raster/collections/openaerialmap/items/68beefef128fd7aac0cd73ec/tiles/WebMercatorQuad/{z}/{x}/{y}?assets=visual&nodata=0 ``` -------------------------------- ### Helm upgrade with s3.rustfs.enabled=true to bundle RustFS as object store Source: https://github.com/hotosm/openaerialmap/blob/main/backend/uploader-api/chart/README.md Installs the chart with RustFS as the in-cluster object store, requiring a public ingress hostname and TLS. `env.S3_ENDPOINT` is derived from the store's Service, and `env.S3_EXTERNAL_ENDPOINT`/`env.PUBLIC_ASSET_BASE_URL` from the ingress. Explicit `env` values override these derivations. ```bash helm upgrade --install uploader-api ./chart -n oam \ --set s3.rustfs.enabled=true \ --set s3.rustfs.ingress.enabled=true \ --set s3.rustfs.ingress.host=s3.stage.imagery.hotosm.org \ --set s3.rustfs.ingress.tls.enabled=true \ --set rustfs.storageclass.name=gp3-ephemeral ``` -------------------------------- ### Create collection before first sync Source: https://github.com/hotosm/openaerialmap/blob/main/docs/dev/ingest/new-provider.md Run this command to create the Collection before the first Item sync. The stac-ingester image tracks OpenAerialMap's main branch, so wait for the new image before starting the CronJob. ```bash hotosm sync-collection --catalog Example ``` -------------------------------- ### Generate WMTS endpoint with GET request to titiler-pgstac Source: https://github.com/hotosm/openaerialmap/blob/main/notebooks/titiler-pgstac.ipynb Generates a WMTS endpoint on the fly using a GET request to titiler-pgstac, passing a bounding box and datetime range as query parameters. The response is the WMTS Capabilities XML, and the code prints the first 200 characters of the decoded response. Requires the client and URL variables to be defined beforehand. ```python url = urllib.parse.urljoin(HOT_OAM_RASTER_URL, "collections/maxar-opendata/WebMercatorQuad/WMTSCapabilities.xml") response = client.get(url, params={ "bbox": ",".join(str(b) for b in COLORADO_BBOX), "datetime": "2025-04-01T00:00:00Z/2025-05-01T00:00:00Z" }) response.raise_for_status() print(response.content.decode()[0:200] + "...") ``` ```text Output: /etc/apt/sources.list.d/pgdg.list wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc \ | apt-key add - apt update apt install postgresql-client-16 # Port forward the db service kubectl port-forward service/eoapi-pgbouncer 5432:5432 # Get the connection string kubectl get secrets eoapi-pguser-eoapi -o go-template='{{.data.uri | base64decode}}' # Replace eoapi-primary.eoapi.svc with localhost, as we are port-forwarding PGURL= # Dump the db in custom format pg_dump -Fc "$PGURL" > pgstac-backup.dump.gz ``` -------------------------------- ### Get tile URL from registered search Source: https://github.com/hotosm/openaerialmap/blob/main/notebooks/titiler-pgstac.ipynb Fetches the TileJSON for the registered search using WebMercatorQuad, extracts the tile link, and appends ?assets=visual to the href. The result is a template URL for tiles. ```python response = client.get(urllib.parse.urljoin(HOT_OAM_RASTER_URL, f"searches/{data['id']}/tiles/WebMercatorQuad")) response.raise_for_status() data = response.json() link = next(link for link in data["links"] if link["rel"] == "tile") tiles_href = link["href"] + "?assets=visual" tiles_href ``` ```text 'https://hot-oam.ds.io/raster/searches/25cbe8b7ebe2fc01198c9573e0ef3566/tiles/WebMercatorQuad/{z}/{x}/{y}?assets=visual' ``` -------------------------------- ### Helm upgrade with seed.enabled=true to seed a fresh catalogue Source: https://github.com/hotosm/openaerialmap/blob/main/backend/uploader-api/chart/README.md Installs or upgrades the uploader-api chart with the seed Job enabled, creating the STAC collection and optionally copying items from a public STAC API. `seed.maxItems=500` and `seed.maxGiB=50` control the copy; `seed.maxGiB` is a ceiling, not a target. Match the Helm/ArgoCD timeout to `seed.activeDeadlineSeconds`. ```bash helm upgrade --install uploader-api ./chart -n oam \ --set seed.enabled=true --set seed.maxItems=500 --set seed.maxGiB=50 \ --timeout 60m ``` -------------------------------- ### GET ///.png Source: https://github.com/hotosm/openaerialmap/blob/main/backend/global-tms/chart/templates/NOTES.txt Retrieves a raster tile at the specified zoom, x, and y coordinates. Tiles are served from the chiitiler and NGINX sidecar, with zoom levels >=16 redirecting to an external TiTiler service. ```APIDOC ## GET ///.png ### Description Retrieves a raster tile at the specified zoom, x, and y coordinates. Tiles are served from the chiitiler and NGINX sidecar, with zoom levels >=16 redirecting to an external TiTiler service. ### Method GET ### Endpoint http://{{ .Values.ingress.host }}///.png ### Parameters #### Path Parameters - **z** (integer) - Required - Zoom level (0-15) - **x** (integer) - Required - Tile column - **y** (integer) - Required - Tile row ### Request Example curl http://{{ .Values.ingress.host }}/10/511/340.png -o tile.png ### Response #### Success Response (200) - **body** (binary) - PNG image of the tile #### Response Example (Image data) ### Error Handling - Zoom levels >=16 will redirect to an external TiTiler service. ``` -------------------------------- ### GET /health Source: https://github.com/hotosm/openaerialmap/blob/main/backend/global-tms/chart/templates/NOTES.txt Health check endpoint to verify the service is running. ```APIDOC ## GET /health ### Description Health check endpoint to verify the service is running. ### Method GET ### Endpoint http://{{ .Values.ingress.host }}/health ### Response #### Success Response (200) - **body** (string) - Health status #### Response Example (Health status text) ``` -------------------------------- ### Canonical polling flow: POST /tilepacks/{id}?format=pmtiles Source: https://github.com/hotosm/openaerialmap/blob/main/backend/tilepack-api/README.md Shows the polling flow for a canonical request (no zoom parameters). The same endpoint is used to trigger and poll; it returns 'started', then 'in_progress', then 'ready' with the download URL. Canonical outputs are patched into STAC assets. ```http POST /tilepacks/67ac270a43f18e3e3665bef7?format=pmtiles ``` ```json { "status": "started" } ``` ```json { "status": "in_progress" } ``` ```json { "status": "ready", "url": "https://.../67ac270a43f18e3e3665bef7.pmtiles" } ``` -------------------------------- ### GET /healthz Source: https://github.com/hotosm/openaerialmap/blob/main/backend/tilepack-api/README.md Health check endpoint to verify the service is running. ```APIDOC ## [GET] /healthz ### Description Health check endpoint to verify the service is running. ### Method GET ### Endpoint /healthz ### Parameters None ### Request Example GET /healthz ### Response #### Success Response (200) Service is healthy. #### Response Example No response body specified. ``` -------------------------------- ### Build raster step image from backend context Source: https://github.com/hotosm/openaerialmap/blob/main/backend/uploader-api/pipeline/README.md Builds the metadata step image using the Dockerfile in backend/uploader-api/pipeline/metadata with the prod target. The build context must be backend/ because the stactools-hotosm path dependency lives there. ```bash docker build -f backend/uploader-api/pipeline/metadata/Dockerfile \ --target prod backend ``` -------------------------------- ### Verify tiles, cache, and restart deployment Source: https://github.com/hotosm/openaerialmap/blob/main/backend/global-tms/chart/templates/NOTES.txt Commands to verify tile access, check cache status, and restart the deployment for PMTiles freshness. ```bash curl http://{{ .Values.ingress.host }}/10/511/340.png -o tile.png ``` ```bash curl -sI http://{{ .Values.ingress.host }}/5/16/12.png | grep X-Cache ``` ```bash kubectl rollout restart deployment/{{ include "chart.fullname" . }} ``` -------------------------------- ### Create PgstacDB and Loader Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/STAC Ingest.ipynb Initializes the PgstacDB connection and Loader instance for loading data. ```python pgstac = PgstacDB(dsn) loader = Loader(pgstac) ``` -------------------------------- ### Import libraries and configure logging Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/OAM STAC Items.ipynb Imports required modules and sets up a custom logging formatter to reduce exception verbosity. ```python import datetime as dt import json import logging import time from concurrent.futures import ThreadPoolExecutor, as_completed from pystac import Item from stactools.hotosm.exceptions import AssetNotFoundError from stactools.hotosm.oam_metadata import OamMetadata from stactools.hotosm.oam_metadata_client import OamMetadataClient from stactools.hotosm.stac import create_collection, create_item logging.basicConfig() class QuietLogFormatter(logging.Formatter): """Quieter exception logging for the notebook.""" def format(self, record): """Only log the last line of an exception.""" if not record.exc_text: record.exc_text = self.formatException(record.exc_info) record.exc_text = record.exc_text.split("\n")[-1] return super().format(record) hotosm_logger = logging.getLogger("stactools.hotosm") handler = logging.StreamHandler() handler.setFormatter(QuietLogFormatter()) hotosm_logger.addHandler(handler) ``` -------------------------------- ### Build STAC Ingester Docker Image Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stac-ingester/README.md Builds the STAC ingester image from the backend directory, targeting the prod stage. ```bash docker build -f backend/stac-ingester/Dockerfile --target prod backend ``` -------------------------------- ### GET /uploads/anonymous Source: https://github.com/hotosm/openaerialmap/blob/main/backend/uploader-api/README.md Retrieves anonymous uploads by IDs. This endpoint is unauthenticated and only returns rows owned by the `custom|anonymous` account. ```APIDOC ## GET /uploads/anonymous ### Description Retrieves anonymous uploads by IDs. This endpoint is unauthenticated and only returns rows owned by the `custom|anonymous` account. ### Method GET ### Endpoint /uploads/anonymous ### Parameters #### Query Parameters - **ids** (string) - Required - Comma-separated list of upload IDs to retrieve. ### Response #### Success Response (200) Returns rows owned by `custom|anonymous`. ``` -------------------------------- ### GET /api/v1/uploads/lookup Source: https://github.com/hotosm/openaerialmap/blob/main/backend/uploader-api/README.md Resolves an upload by its external ID. The external ID is an opaque idempotency key, conventionally formatted as `:`. ```APIDOC ## GET /api/v1/uploads/lookup ### Description Resolves an upload by its external ID. The external ID is an opaque idempotency key, conventionally formatted as `:`. ### Method GET ### Endpoint /api/v1/uploads/lookup ### Parameters #### Query Parameters - **external_id** (string) - Required - The external ID to look up. ``` -------------------------------- ### Build DSN from environment variables Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/STAC Ingest.ipynb Constructs a PostgreSQL DSN using standard PG environment variables with defaults from eoAPI Docker Compose. ```python dsn = "postgresql://{username}:{password}@{host}:{port}/{database}".format( username=os.getenv("PGUSER", "username"), password=os.getenv("PGPASSWORD", "password"), host=os.getenv("PGHOST", "localhost"), port=os.getenv("PGPORT", 5439), database=os.getenv("PGDATABASE", "postgis"), ) ``` -------------------------------- ### Configure STAC API connection Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/STAC Ingest.ipynb Sets up the STAC API connection by reading the STAC_API_ROOT environment variable, creating a requests session, and applying basic authentication if STAC_API_USERNAME and STAC_API_PASSWORD are set. ```python import json import os from itertools import batched from pathlib import Path from urllib.parse import urljoin import pystac import requests import rustac STAC_API_ROOT = os.environ["STAC_API_ROOT"] if not STAC_API_ROOT.endswith("/"): STAC_API_ROOT += "/" session = requests.Session() if (username := os.getenv("STAC_API_USERNAME")) and ( password := os.getenv("STAC_API_PASSWORD") ): session.auth = (username, password) ``` -------------------------------- ### Initialize OAM metadata client Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/OAM STAC Items.ipynb Creates a new OamMetadataClient instance. ```python client = OamMetadataClient.new() ``` -------------------------------- ### Output: progress items 0-4000 Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/OAM STAC Items.ipynb Output showing progress every 1000 items. ```text Item 0/17930 Item 1000/17930 Item 2000/17930 Item 3000/17930 Item 4000/17930 ``` -------------------------------- ### API Surface: POST /tilepacks/{stac_item_id} and GET /healthz Source: https://github.com/hotosm/openaerialmap/blob/main/backend/tilepack-api/README.md Lists the two endpoints of the Tilepack API: the main tilepack creation endpoint and a health check. The tilepack endpoint accepts a STAC item ID and a format (pmtiles or mbtiles), with optional zoom parameters. ```text POST /tilepacks/{stac_item_id}?format=pmtiles|mbtiles[&min_zoom=N&max_zoom=N] GET /healthz ``` -------------------------------- ### Import required libraries Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/Maxar Open Data.ipynb Imports datetime, json, concurrent.futures, pystac, requests, and the stactools.hotosm.maxar functions. ```python import datetime as dt import json from concurrent.futures import ThreadPoolExecutor, as_completed import pystac import requests from stactools.hotosm.maxar.stac import create_collection, create_item ``` -------------------------------- ### Result of creating collection Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/Maxar Open Data.ipynb Output showing the collection object. ```text Result: ``` -------------------------------- ### Enable workflowNetworkPolicy and get API server addresses Source: https://github.com/hotosm/openaerialmap/blob/main/backend/uploader-api/chart/templates/NOTES.txt Configuration to enable the workflow network policy and commands to retrieve the Kubernetes API server addresses. The policy restricts pipeline pod egress; the bundled store is allowed automatically, but an external in-cluster store needs additionalEgress. ```yaml workflowNetworkPolicy: enabled: true apiServerCIDRs: ["/32", "/32"] ``` ```bash kubectl get svc kubernetes -n default -o jsonpath='{.spec.clusterIP}' kubectl get endpoints kubernetes -n default # the bundled store is allowed automatically; an external in-cluster one # still needs allowing via additionalEgress ``` -------------------------------- ### Print a sample converted item Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/Maxar Open Data.ipynb Prints a converted STAC item as JSON. ```python print(json.dumps(maxar_items[24_000].to_dict(), indent=2)) ``` -------------------------------- ### Load STAC collections from files Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/STAC Ingest.ipynb Reads all local collection.json files into pystac Collection objects and displays them. ```python collections = [pystac.read_file(path) for path in Path(".").glob("*collection.json")] collections ``` ```text Result: [, ] ``` -------------------------------- ### Output of sample item JSON Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/Maxar Open Data.ipynb Shows the JSON representation of a converted STAC item. ```json Output: { "type": "Feature", "stac_version": "1.1.0", "stac_extensions": [ "https://stac-extensions.github.io/view/v1.0.0/schema.json", "https://stac-extensions.github.io/projection/v2.0.0/schema.json", "https://stac-extensions.github.io/eo/v1.1.0/schema.json", "https://stac-extensions.github.io/raster/v1.1.0/schema.json", "https://stac-extensions.github.io/grid/v1.1.0/schema.json", "https://stac-extensions.github.io/alternate-assets/v1.2.0/schema.json", "https://docs.imagery.hotosm.org/oam/v0.1.0/schema.json" ], "id": "29-120202010002-1040050057DC8500", "geometry": { "type": "Polygon", "coordinates": [ [ [ -8.125223569079694, 31.729769515270355 ], [ -8.101110652346883, 31.728244412050305 ], [ -8.101178991082955, 31.72083051048363 ], [ -8.125296297652588, 31.720998275800387 ], [ -8.125223569079694, 31.729769515270355 ] ] ] }, "bbox": [ -8.125296297652588, 31.72083051048363, -8.101110652346883, 31.729769515270355 ], "properties": { "datetime": "2023-09-10T11:25:17Z", "platform": "WV03", "gsd": 0.35, "ard_metadata_version": "0.0.1", "catalog_id": "1040050057DC8500", "utm_zone": 29, "quadkey": "120202010002", "view:off_nadir": 22.2, "view:azimuth": 336.4, "view:incidence_angle": 65.5, "view:sun_azimuth": 147.2, "view:sun_elevation": 59.5, "proj:geometry": { "type": "Polygon", "coordinates": [ ``` -------------------------------- ### POST /tilepacks/{id}?format=pmtiles Source: https://github.com/hotosm/openaerialmap/blob/main/backend/tilepack-api/README.md Generates a PMTiles archive for a STAC item and returns a download URL when complete. ```APIDOC ## [POST] /tilepacks/{id}?format=pmtiles ### Description Generates a PMTiles archive for a STAC item. Poll the endpoint until it returns 200 with a download URL. ### Method POST ### Endpoint https://packager.imagery.hotosm.org/tilepacks/{id}?format=pmtiles ### Parameters #### Path Parameters - **id** (string) - Required - The STAC item ID. #### Query Parameters - **format** (string) - Required - The output format, e.g., `pmtiles`. ### Response #### Success Response (200) - **download URL** (string) - The URL to download the generated PMTiles archive. #### Response Example ``` 200 OK ``` #### Error Responses - **202** - The worker is still running; continue polling. - **409** - The last build failed; terminal, stop polling. ``` -------------------------------- ### Widen sync window in job.yaml Source: https://github.com/hotosm/openaerialmap/blob/main/docs/dev/ingest/backfill.md The command line to edit into `job.yaml` to widen the sync window. `--handle-exceptions IGNORE` lets Item errors be listed at the end without stopping the Job. ```text hotosm sync-oam --uploaded-after 2024-01-01 --handle-exceptions IGNORE ``` -------------------------------- ### Result of collection creation Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/OAM STAC Items.ipynb Output showing the created collection object. ```text Result: ``` -------------------------------- ### Run and clean up backfill Job Source: https://github.com/hotosm/openaerialmap/blob/main/docs/dev/ingest/backfill.md Creates the backfill Job, follows its logs, and deletes it. The same process works with the `stac-ingest-maxar` and `stac-ingest-vantor` CronJobs. ```bash kubectl create -f job.yaml kubectl -n oam logs -f job/oam-backfill kubectl -n oam delete job oam-backfill ``` -------------------------------- ### Create STAC collection Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/OAM STAC Items.ipynb Creates a STAC collection for OpenAerialMap and displays it. ```python collection = create_collection() collection ``` -------------------------------- ### Repository structure Source: https://github.com/hotosm/openaerialmap/blob/main/backend/tilepack-api/README.md Directory layout of the tilepack-api repository, showing the Go API, internal packages, Python worker, and Helm chart. ```text cmd/api/ Go HTTP server (single binary, distroless) internal/ config, stac, s3, k8s, ratelimit, handler worker/ Python image: rio-tiler + go-pmtiles chart/ Helm chart ``` -------------------------------- ### Output: progress items 5000-8000 Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/OAM STAC Items.ipynb Output showing progress for items 5000 to 8000. ```text Item 5000/17930 Item 6000/17930 Item 7000/17930 Item 8000/17930 ``` -------------------------------- ### List Exported Files Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/Maxar Open Data.ipynb Displays the file sizes and details of the generated NDJSON and GeoParquet files. ```bash ! ls -lh maxar-opendata-* ``` ```text Output: -rw-r--r-- 1 ceholden staff 168M May 13 09:23 maxar-opendata-20250513T092240.ndjson -rw-r--r-- 1 ceholden staff 12M May 13 09:23 maxar-opendata-20250513T092240.parquet -rw-r--r-- 1 ceholden staff 1.5K May 12 18:07 maxar-opendata-collection.json ``` -------------------------------- ### Set POPULATE_ITEMS to 50 for populate-prod Source: https://github.com/hotosm/openaerialmap/blob/main/docs/dev/local-setup.md Configures the number of items to fetch from the production STAC API when running 'just test populate-prod'. The default is 20 items; setting POPULATE_ITEMS overrides it. ```sh POPULATE_ITEMS=50 just test populate-prod ``` -------------------------------- ### Run tests with ./scripts/test Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/README.md Runs the test suite. Execute from the package directory. ```bash ./scripts/test ``` -------------------------------- ### Dump and Upsert Items for External Provider Source: https://github.com/hotosm/openaerialmap/blob/main/docs/dev/ingest/schema.md Rebuilds an Item with the current schema version by dumping the source and loading it with upsert. Not for the 'openaerialmap' collection because an upsert deletes tilepack-written assets; patch those Items instead. ```bash hotosm dump-maxar \ --uploaded-after 2023-01-01 \ --handle-exceptions IGNORE \ --file maxar.ndjson pypgstac load items --method upsert maxar.ndjson ``` -------------------------------- ### Import pypgstac modules Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/STAC Ingest.ipynb Imports necessary modules from pypgstac and standard libraries for database loading. ```python import os from pathlib import Path from typing import Iterator from pypgstac.db import PgstacDB from pypgstac.load import Loader, Methods ``` -------------------------------- ### Create STAC collections via POST /collections Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/STAC Ingest.ipynb Creates each loaded collection via a POST to /collections on the STAC API and prints the created collection ID. ```python for collection in collections: r = session.post(urljoin(STAC_API_ROOT, "collections"), json=collection.to_dict()) r.raise_for_status() print(f"Created {collection.id}") ``` ```text Output: Created openaerialmap Created maxar-opendata ``` -------------------------------- ### Run GLO-30 test ingest with bbox Source: https://github.com/hotosm/openaerialmap/blob/main/docs/dev/ingest/elevation.md Runs a smaller test ingest of GLO-30 data using the specified bounding box (minx miny maxx maxy). Use this to validate ingestion before running the full job. ```bash hotosm sync-glo30 --bbox 85.0 27.0 88.0 29.0 ``` -------------------------------- ### Output of item conversion progress Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/Maxar Open Data.ipynb Shows the progress output from the conversion process. ```text Output: Submitted all Collections. Finding Items Submitting item 5000 Submitting item 10000 Submitting item 15000 Submitting item 20000 Submitting item 25000 Found all Items. Processed item 0 of 29228 Processed item 2000 of 29228 Processed item 4000 of 29228 Processed item 6000 of 29228 Processed item 8000 of 29228 Processed item 10000 of 29228 Processed item 12000 of 29228 Processed item 14000 of 29228 Processed item 16000 of 29228 Processed item 18000 of 29228 Processed item 20000 of 29228 Processed item 22000 of 29228 Processed item 24000 of 29228 Processed item 26000 of 29228 Processed item 28000 of 29228 ``` -------------------------------- ### Request PMTiles packager Source: https://github.com/hotosm/openaerialmap/blob/main/docs/usage/using-imagery.md Ask the packager to build a PMTiles archive for a specific item via a terminal. It returns 202 while the worker runs and 200 with the URL once the archive is on S3 and registered in STAC. ```APIDOC ## [POST] https://packager.imagery.hotosm.org/tilepacks/{item_id}?format=pmtiles ### Description Ask the packager to build a PMTiles archive for a specific item via a terminal. It returns 202 while the worker runs and 200 with the URL once the archive is on S3 and registered in STAC. ### Method POST ### Endpoint https://packager.imagery.hotosm.org/tilepacks/{item_id}?format=pmtiles ### Parameters #### Path Parameters - **item_id** (string) - Required - STAC item ID #### Query Parameters - **format** (string) - Required - Format, e.g., `pmtiles` ### Response #### Success Response (202) - Worker running #### Success Response (200) - URL of the archive ### Request Example ```bash curl -X POST "https://packager.imagery.hotosm.org/tilepacks/{item_id}?format=pmtiles" ``` ``` -------------------------------- ### Manually apply Argo workflow template Source: https://github.com/hotosm/openaerialmap/blob/main/backend/uploader-api/pipeline/README.md Applies the workflow template to the oam namespace for development. The template is the single source of truth and is applied separately from the helm chart. ```bash # manual apply (dev) argo template create workflow-template.yaml -n oam ``` -------------------------------- ### Visualize tile URL with folium Source: https://github.com/hotosm/openaerialmap/blob/main/notebooks/titiler-pgstac.ipynb Creates a folium map centered on a location and adds a TileLayer using the tiles_href. The map is displayed inline. ```python from folium import Map, TileLayer map = Map(location=[39.9778, -105.1319], zoom_start=13) TileLayer(tiles_href, min_zoom=12, attr="©️ Maxar https://www.maxar.com/open-data").add_to(map) map ``` ```text ``` -------------------------------- ### Create and write OAM collection Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/Maxar Open Data.ipynb Creates a STAC collection from the Maxar catalog and event dates, then writes it to a JSON file. ```python collection = create_collection( maxar_catalog, min(maxar_event_dates), max(maxar_event_dates) ) pystac.write_file( collection, include_self_link=False, dest_href="maxar-opendata-collection.json" ) collection ``` -------------------------------- ### Request PMTiles tilepack via curl Source: https://github.com/hotosm/openaerialmap/blob/main/docs/usage/using-imagery.md Ask the packager to build a PMTiles archive for a single image. Returns 202 while the worker runs and 200 with the URL once the archive is on S3 and registered in STAC. ```bash curl -X POST "https://packager.imagery.hotosm.org/tilepacks/{item_id}?format=pmtiles" ``` -------------------------------- ### Run code checks (format, lint, typecheck) Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/README.md Runs formatting with ruff format, linting with ruff check, and type checking with mypy. Each command is run from the package directory. ```bash ./scripts/format # ruff format ``` ```bash ./scripts/lint # ruff check ``` ```bash ./scripts/typecheck # mypy ``` -------------------------------- ### new_stac_items function for large catalogues Source: https://github.com/hotosm/openaerialmap/blob/main/docs/dev/ingest/new-provider.md Implement this function in sync.py when the catalogue is too large to walk. Use a provider index, manifest, STAC API search, or partitioned catalogue to avoid reading every Item, and remove any provider-specific duplicates. ```python def new_stac_items(stac_io, session, after): yield from ... ``` -------------------------------- ### Check OAM ingest Job logs Source: https://github.com/hotosm/openaerialmap/blob/main/docs/dev/ingest/backfill.md Lists OAM ingest Jobs by creation time and shows the last 100 log lines for a specific Job. The log output indicates what was found, skipped, and ingested. ```bash kubectl -n oam get jobs -l app=stac-ingest-oam --sort-by=.metadata.creationTimestamp kubectl -n oam logs job/stac-ingest-oam- --tail=100 ``` -------------------------------- ### Create backfill Job from CronJob Source: https://github.com/hotosm/openaerialmap/blob/main/docs/dev/ingest/backfill.md Creates a one-off Job from the `stac-ingest-oam` CronJob and writes its YAML to `job.yaml` for editing. ```bash kubectl -n oam create job oam-backfill --from=cronjob/stac-ingest-oam \ --dry-run=client --output yaml > job.yaml ``` -------------------------------- ### Output: additional warnings Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/OAM STAC Items.ipynb Output showing rasterio warnings for EPSG:4293. ```text WARNING:rasterio._env:CPLE_AppDefined in The definition of geographic CRS EPSG:4293 got from GeoTIFF keys is not the same as the one from the EPSG registry, which may cause issues during reprojection operations. Set GTIFF_SRS_SOURCE configuration option to EPSG to use official parameters (overriding the ones from GeoTIFF keys), or to GEOKEYS to use custom values from GeoTIFF keys and drop the EPSG code. WARNING:rasterio._env:CPLE_AppDefined in The definition of geographic CRS EPSG:4293 got from GeoTIFF keys is not the same as the one from the EPSG registry, which may cause issues during reprojection operations. Set GTIFF_SRS_SOURCE configuration option to EPSG to use official parameters (overriding the ones from GeoTIFF keys), or to GEOKEYS to use custom values from GeoTIFF keys and drop the EPSG code. ``` -------------------------------- ### prepare_item hook for provider-specific metadata Source: https://github.com/hotosm/openaerialmap/blob/main/docs/dev/ingest/new-provider.md Use this hook to fix provider-specific metadata fields that genuinely differ, such as missing title or gsd, incorrect asset names, relative URLs, or unsafe Item IDs. Do not add standard oam: properties, providers, or provenance links here; the shared code already does that. ```python from pystac import Item def prepare_item(oam_item: Item, source_item: Item) -> None: oam_item.properties["title"] = source_item.properties["title"] oam_item.properties.setdefault("gsd", source_item.properties["pan_gsd"]) ``` -------------------------------- ### Result of reading Maxar root catalog Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/Maxar Open Data.ipynb Output showing the catalog object. ```text Result: ``` -------------------------------- ### Check PgSTAC and pypgstac versions Source: https://github.com/hotosm/openaerialmap/blob/main/docs/dev/ingest/backfill.md Checks the PgSTAC version and the `pypgstac` version in the Job's pod. Versions before `pypgstac` 0.9.11 can report success without writing Items when used with PgSTAC 0.9.10 or earlier. ```bash psql -c "select pgstac.get_version();" kubectl -n oam exec job/ -- pip show pypgstac | head -2 ``` -------------------------------- ### PMTiles for one image Source: https://github.com/hotosm/openaerialmap/blob/main/docs/usage/using-imagery.md Some items carry a `pmtiles` asset, a pre-rendered raster archive of that single image. Check the item's assets for the `pmtiles` key and use its `href`, `minzoom` and `maxzoom`. ```APIDOC ## [GET] ### Description Some items carry a `pmtiles` asset, a pre-rendered raster archive of that single image. Check the item's assets for the `pmtiles` key and use its `href`, `minzoom` and `maxzoom`. ### Method GET ### Endpoint ### Response #### Success Response (200) - PMTiles archive ``` -------------------------------- ### POST /api/v1/uploads Source: https://github.com/hotosm/openaerialmap/blob/main/backend/uploader-api/README.md Creates an upload. Supports anonymous uploads by sending `anonymous: true` in the request body. ```APIDOC ## POST /api/v1/uploads ### Description Creates an upload. Supports anonymous uploads by sending `anonymous: true` in the request body. ### Method POST ### Endpoint /api/v1/uploads ### Parameters #### Request Body - **anonymous** (boolean) - Optional - Set to `true` to perform an anonymous upload. ``` -------------------------------- ### Run mosaicker with docker compose Source: https://github.com/hotosm/openaerialmap/blob/main/backend/global-mosaic/README.md Run the mosaicker script using Docker Compose. Executes the generator in a container. ```bash docker compose run --rm mosaicker ``` -------------------------------- ### Read Maxar root catalog Source: https://github.com/hotosm/openaerialmap/blob/main/backend/stactools-hotosm/examples/Maxar Open Data.ipynb Reads the Maxar Open Data root catalog using pystac. ```python maxar_catalog = pystac.read_file(MAXAR_ROOT_CATALOG) maxar_catalog ```