-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
115 lines (95 loc) · 2.83 KB
/
Makefile
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# State boundaries (scale:1m) http://nationalmap.gov/small_scale/mld/1statep.html
# Index: http://nationalmap.gov/small_scale/atlasftp.html?openChapters=chpbound#chpbound
# 50 states + DC:
# al ak az ar ca co ct de dc fl
# ga hi id il in ia ks ky la me
# md ma mi mn ms mo mt ne nv nh
# nj nm ny nc nd oh ok or pa ri
# sc sd tn tx ut vt va wa wv wi
# wy
# territories with counties:
# pr vi
# territories without counties:
# as fm gu mh mp pw um
STATES=al ak az ar ca co ct de dc fl \
ga hi id il in ia ks ky la me \
md ma mi mn ms mo mt ne nv nh \
nj nm ny nc nd oh ok or pa ri \
sc sd tn tx ut vt va wa wv wi \
wy pr vi
## ----
# v1: http://dds.cr.usgs.gov/pub/data/nationalatlas/statep010_nt00798.tar.gz
# 62 polygons
# Geometry properties sample:
# AREA 279.462
# DAY_ADM 3
# MONTH_ADM 'January'
# ORDER_ADM 49
# PERIMETER 802.665
# STATE 'Alaska'
# STATE_FIPS '02'
# YEAR_ADM 1959
## ----
## --------
# v2: http://dds.cr.usgs.gov/pub/data/nationalatlas/statesp010g.shp_nt00938.tar.gz
# not used due to issue with removing water bodies
## --------
all: topo/us-states.json csv/us-states.csv
gz/%.tar.gz:
mkdir -p $(dir $@)
curl -L 'http://dds.cr.usgs.gov/pub/data/nationalatlas/$(notdir $@)' -o [email protected]
mv [email protected] $@
# shp/us-states-raw.shp: gz/statesp010g.shp_nt00938.tar.gz
shp/us-states-raw.shp: gz/statep010_nt00798.tar.gz
shp/%.shp:
rm -rf $(basename $@)
mkdir -p $(basename $@)
tar -xzm -C $(basename $@) -f $<
for file in $(basename $@)/*; do chmod 644 $$file; mv $$file $(basename $@).$${file##*.}; done
rmdir $(basename $@)
csv/us-states.csv: shp/us-states-raw.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'CSV' -progress $@ $<
shp/us-states.shp: shp/us-states-raw.shp
@rm -f -- $@ $(basename $@)-raw.json
ogr2ogr -f 'GeoJSON' $(basename $@)-raw.json $<
node ../bin/geouniq STATE_FIPS < $(basename $@)-raw.json > $(basename $@).json
ogr2ogr -f 'ESRI Shapefile' $@ $(basename $@).json
rm -f -- $(basename $@).json $(basename $@).json
shp/ak/state.shp: shp/us-states.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'ESRI Shapefile' -where "STATE_FIPS = '02'" $@ $<
geo/us-states.json: shp/us-states-raw.shp
mkdir -p $(dir $@)
rm -f $@
ogr2ogr -f 'GeoJSON' -simplify 0.005 -progress $@ $<
topo/us-states.json: shp/us-states.shp
mkdir -p $(dir $@)
../node_modules/.bin/topojson \
-o $@ \
-q 1E6 \
-s 1E-7 \
-p STATE,STATE_FIPS \
-- states=$<
topo/ak/state.json: shp/ak/state.shp
mkdir -p $(dir $@)
../node_modules/.bin/topojson \
-o $@ \
-q 1E6 \
-s 1E-6 \
-p STATE,STATE_FIPS \
-- states=$<
topo/us-states-simplified.json: shp/us-states.shp
mkdir -p $(dir $@)
../node_modules/.bin/topojson \
-o $@ \
-q 1E6 \
-s 1E-6 \
-p STATE,STATE_FIPS \
-- states=$<
##### clean targets ##########
clean-all: clean/shp clean/csv clean/topo clean/geo
clean/%:
rm -rf $(notdir $@)