Spaces:
Running
Running
Download tools/fetch_data.sh from albertobarnabo/plasmodio: direct link, hf CLI and curl.
- Browser
- Download file 1.88 kB
-
https://huggingface.co/spaces/albertobarnabo/plasmodio/resolve/main/tools/fetch_data.sh
- Command line
-
hf download hf://spaces/albertobarnabo/plasmodio/tools/fetch_data.sh
-
curl -L -o fetch_data.sh https://huggingface.co/spaces/albertobarnabo/plasmodio/resolve/main/tools/fetch_data.sh
1.88 kB
| # Fetches every real dataset Plasmodio needs into data/raw. Re-runnable; skips files that exist. | |
| cd "$(dirname "$0")/../data/raw" | |
| log(){ echo "[$(date +%H:%M:%S)] $*"; } | |
| get(){ [ -s "$2" ] && { log "have $2"; return; }; log "GET $1"; curl -sL --fail --retry 3 --max-time 900 -o "$2" "$1" || log "FAILED $2"; } | |
| # 1. Italy / San Marino / Vatican boundaries (geoBoundaries, OSM-derived, CC BY 4.0) | |
| for iso in ITA SMR VAT; do | |
| if [ ! -s "gb_${iso}_ADM0.geojson" ]; then | |
| url=$(curl -sL "https://www.geoboundaries.org/api/current/gbOpen/${iso}/ADM0/" | python3 -c "import json,sys; d=json.load(sys.stdin); print(d.get('gjDownloadURL',''))") | |
| log "geoBoundaries $iso -> $url" | |
| [ -n "$url" ] && get "$url" "gb_${iso}_ADM0.geojson" | |
| fi | |
| done | |
| # fallback: Natural Earth 10m admin-0 (public domain) | |
| get "https://naciscdn.org/naturalearth/10m/cultural/ne_10m_admin_0_countries.zip" "ne_10m_admin_0_countries.zip" | |
| # 2. GeoNames cities (CC BY 4.0): every place with population >= 5000 | |
| get "https://download.geonames.org/export/dump/cities5000.zip" "cities5000.zip" | |
| # 3. OpenStreetMap via Overpass (ODbL) | |
| ovp(){ [ -s "$2" ] && { log "have $2"; return; }; log "Overpass -> $2"; curl -sL --fail --retry 2 --max-time 900 -o "$2" --data-urlencode "data=$1" "https://overpass-api.de/api/interpreter" || log "FAILED $2"; } | |
| ovp '[out:json][timeout:600]; area["ISO3166-1"="IT"][admin_level=2]->.it; way(area.it)["railway"="rail"]["highspeed"="yes"]; out geom;' osm_hsr.json | |
| ovp '[out:json][timeout:600]; way["route"="ferry"](36.0,6.0,47.5,19.5); out geom;' osm_ferry.json | |
| ovp '[out:json][timeout:900]; area["ISO3166-1"="IT"][admin_level=2]->.it; way(area.it)["railway"="rail"]["usage"="main"]; out geom;' osm_rail_main.json | |
| ovp '[out:json][timeout:1200]; area["ISO3166-1"="IT"][admin_level=2]->.it; way(area.it)["highway"="motorway"]; out geom;' osm_motorway.json | |
| log "done" | |