diff --git a/tiles/download-overture.sh b/tiles/download-overture.sh new file mode 100755 index 00000000..a1842ccf --- /dev/null +++ b/tiles/download-overture.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +set -euo pipefail + +STAC_CATALOG="https://stac.overturemaps.org/catalog.json" +DEFAULT_BBOX="7.408446,43.722901,7.4405,43.752481" +DEFAULT_OUT="data/sources/monaco.parquet" + +usage() { + cat </dev/null || true +} + +if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then + usage + exit 0 +fi + +REL="${1:-$(latest_release)}" +if [[ -z "$REL" ]]; then + echo "Could not determine the latest release from ${STAC_CATALOG}; pass one explicitly." >&2 + exit 1 +fi +BBOX="${2:-$DEFAULT_BBOX}" +OUT="${3:-$DEFAULT_OUT}" + +IFS=',' read -r XMIN YMIN XMAX YMAX <<< "$BBOX" + +echo "Downloading release $REL: $BBOX to $OUT" + +duckdb -c " +COPY ( + SELECT * + FROM read_parquet( + 's3://overturemaps-us-west-2/release/${REL}/**/*.parquet', + hive_partitioning=1, filename=1, union_by_name=1 + ) + WHERE theme IN ('transportation','places','base','buildings','divisions') + AND bbox.xmin <= ${XMAX} + AND bbox.xmax >= ${XMIN} + AND bbox.ymin <= ${YMAX} + AND bbox.ymax >= ${YMIN} +) TO '${OUT}' (FORMAT PARQUET);" + +echo "Wrote ${OUT}" \ No newline at end of file