Repository navigation
Expand file tree
/
Copy pathfetch_data.sh
More file actions
executable file
·51 lines (51 loc) · 2.71 KB
/
Copy pathfetch_data.sh
File metadata and controls
executable file
·51 lines (51 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env bash
# Download the source data into data/ (git-ignored).
# ./fetch_data.sh Natural Earth + US census files (~65 MB): enough to redraw the
# maps, atlases and height view from the committed out/hex/ extract
# ./fetch_data.sh --all also Kontur Population (2.4 GB download, 6.7 GB unzipped):
# needed to recompute populations or change stations
# ./fetch_data.sh --projections
# WorldPop 1 km SSP2 projections (4.1 GB) for build_projection.py,
# and Hauer et al. US county projections (326 MB) for build_msa.py
set -euo pipefail
cd "$(dirname "$0")"
mkdir -p data/ne
NE=https://raw.githubusercontent.com/nvkelso/natural-earth-vector/master/geojson
for f in ne_10m_admin_0_countries ne_10m_admin_1_states_provinces_lakes ne_10m_lakes; do
[ -s "data/ne/$f.geojson" ] || curl -fL --retry 3 -o "data/ne/$f.geojson" "$NE/$f.geojson"
done
# US census metro areas (build_msa.py): CBSA delineation, county estimates, county outlines
mkdir -p data/census
CEN=https://www2.census.gov
for u in programs-surveys/metro-micro/geographies/reference-files/2023/delineation-files/list1_2023.xlsx \
programs-surveys/popest/datasets/2020-2024/counties/totals/co-est2024-alldata.csv \
geo/tiger/GENZ2023/shp/cb_2023_us_county_5m.zip; do
[ -s "data/census/$(basename "$u")" ] || curl -fL --retry 3 -o "data/census/$(basename "$u")" "$CEN/$u"
done
# Canadian and Australian metro populations (build_msa.py)
mkdir -p data/statcan data/abs
[ -s data/statcan/17100148-eng.zip ] || curl -fL --retry 3 -o data/statcan/17100148-eng.zip \
https://www150.statcan.gc.ca/n1/tbl/csv/17100148-eng.zip
ABS=https://www.abs.gov.au/statistics/people/population/regional-population/2024-25
for n in 32180DS0003_2001-25 32180DS0004_2001-25; do
[ -s "data/abs/$n.xlsx" ] || curl -fL --retry 3 -o "data/abs/$n.xlsx" "$ABS/$n.xlsx"
done
if [ "${1:-}" = "--all" ]; then
K=kontur_population_20231101.gpkg
[ -s "data/$K" ] || {
curl -fL --retry 5 -C - -o "data/$K.gz" \
"https://geodata-eu-central-1-kontur-public.s3.amazonaws.com/kontur_datasets/$K.gz"
gunzip -k "data/$K.gz"
}
fi
if [ "${1:-}" = "--projections" ]; then
mkdir -p data/worldpop
W=FuturePop_SSP2_1km_v0_2.zip
[ -s "data/worldpop/$W" ] || curl -fL --retry 5 -C - -o "data/worldpop/$W" \
"https://data.worldpop.org/repo/prj/FuturePop/SSPs_1km_v0_2/$W"
# Hauer et al. US county projections by SSP (OSF project 9ynfc; served via OSF's file host)
mkdir -p data/hauer
[ -s data/hauer/SSP_asrc.zip ] || curl -fL --retry 3 -o data/hauer/SSP_asrc.zip \
"https://files.us.osf.io/v1/resources/9ynfc/providers/osfstorage/5bfd62b6d2ca140017c7775d"
fi
echo "data ready"