-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
330 lines (289 loc) · 12.9 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
TOPOJSON = node node_modules/.bin/topojson
OREGON_NORTH_SRS = 'EPSG:2913'
node_modules:
npm install
.SECONDARY:
################################################################################
# ARCHIVES
################################################################################
gz/historic/Trolley_All.zip:
mkdir -p $(dir $@)
curl --remote-time 'http://www.upa.pdx.edu/IMS/currentprojects/TAHv3/GIS_Data/Portlands_People/$(notdir $@)' -o [email protected]
mv [email protected] $@
gz/metro/%.zip:
mkdir -p $(dir $@)
curl -L --remote-time 'http://library.oregonmetro.gov/rlisdiscovery/$(notdir $@)' -o [email protected]
mv [email protected] $@
gz/trimet/%.zip:
mkdir -p $(dir $@)
curl -L --remote-time 'http://developer.trimet.org/gis/data/$(notdir $@)' -o [email protected]
mv [email protected] $@
gz/osm/%.zip:
mkdir -p $(dir $@)
curl --remote-time 'https://s3.amazonaws.com/metro-extracts.mapzen.com/$(notdir $@)' -o [email protected]
mv [email protected] $@
gz/dropbox/%.zip:
mkdir -p $(dir $@)
curl -L --remote-time 'https://dl.dropboxusercontent.com/u/602885/open-data/$(notdir $@)' -o [email protected]
mv [email protected] $@
gz/%.zip:
mkdir -p $(dir $@)
curl --remote-time 'ftp://ftp02.portlandoregon.gov/CivicApps/$(notdir $@)' -o [email protected]
mv [email protected] $@
################################################################################
# SHAPEFILES: CITY OF PORTLAND
################################################################################
shp/bicycle-network.shp: gz/Bicycle_Network_pdx.zip
shp/bicycle-parking.shp: gz/bicycle_parking_pdx.zip
shp/bridges.shp: gz/Bridge_pdx.zip
shp/business-associations.shp: gz/Business_Associations_pdx.zip
shp/lid-boundaries.shp: gz/LID_Boundaries_pdx.zip
shp/cip-data.shp: gz/CIP_Data.zip
shp/city-boundaries.shp: gz/City_metro.zip
shp/corners.shp: gz/Corners_pdx.zip
shp/counties.shp: gz/County_metro.zip
shp/curbs.shp: gz/Curb_pdx.zip
shp/curb-ramps.shp: gz/Curb_Ramp_pdx.zip
shp/development-opportunity-areas.shp: gz/Development_Opp_Areas_pdx.zip
shp/contours-5ft.shp: gz/Contours_5ft_metro.zip
shp/enterprise-ecommerce-zone.shp: gz/Enterprise_ECommerce_Zone_pdx.zip
shp/freight-districts.shp: gz/Freight_Districts_pdx.zip
shp/freight-facilities.shp: gz/Freight_Facilities_pdx.zip
shp/guardrail.shp: gz/Guardrail_pdx.zip
shp/heritage-trees.shp: gz/Heritage_Trees_pdx.zip
shp/homebuyer-opportunity-areas.shp: gz/LTA_HomeBuyer_Opportunity_pdx.zip
shp/intermodal-facilities.shp: gz/Intermodal_Facilities_pdx.zip
shp/its-camera.shp: gz/its_camera_pdx.zip
shp/its-sign.shp: gz/its_sign_pdx.zip
shp/leaf-pickup.shp: gz/Leaf_Pickup_pdx.zip
shp/neighborhoods.shp: gz/Neighborhoods_pdx.zip
shp/parking-meters.shp: gz/Parking_Meter_pdx.zip
shp/parks.shp: gz/Parks_pdx.zip
shp/parks-desired-future-cond.shp: gz/Parks_Desired_Future_Cond_pdx.zip
shp/parks-easements.shp: gz/Parks_Easements_pdx.zip
shp/parks-taxlots.shp: gz/Parks_Taxlots_pdx.zip
shp/parks-trails.shp: gz/Parks_Trails_pdx.zip
shp/parks-vegetation-surveys.shp: gz/Parks_Vegetation_Surveys_pdx.zip
shp/pavement-maint.shp: gz/Pavement_PMS_pdx.zip
shp/pavemoratorium.shp: gz/Pavemoratorium.zip
shp/pedestrian-districts.shp: gz/Pedestrian_Districts_pdx.zip
shp/percent-slope.shp: gz/Percent_Slope_pdx.zip
shp/sidewalks.shp: gz/Sidewalk_pdx.zip
shp/signage-lighting-improvement-program.shp: gz/Signage_Lighting_Imp_Prog_pdx.zip
shp/snow-ice-routes.shp: gz/PDOT_Snow_Ice_Routes_pdx.zip
shp/storefront-improvement-areas.shp: gz/Storefront_Imp_Areas_pdx.zip
shp/streets.shp: gz/Streets_pdx.zip
shp/street-contract-jobs-line.shp: gz/Contract_Jobs_line_pdx.zip
shp/street-contract-jobs-multipoint.shp: gz/Contract_Jobs_multipoint_pdx.zip
shp/portland-streets-permit-jobs-line.shp: gz/Permit_Jobs_Line_pdx.zip
shp/portland-streets-permit-jobs-point.shp: gz/Permit_Jobs_Point_pdx.zip
shp/portland-streets-permit-jobs-polygon.shp: gz/Permit_Jobs_Polygon_pdx.zip
shp/lid-streets.shp: gz/LID_Streets_pdx.zip
shp/street-sweeping.shp: gz/Portland_Street_Sweeping.zip
shp/street-trees.shp: gz/Street_Trees_pdx.zip
shp/traffic-calming.shp: gz/traffic_calming_pdx.zip
shp/traffic-signal.shp: gz/traffic_signal_pdx.zip
shp/portland-transit-stations.shp: gz/Transit_Stations_pdx.zip
shp/tsp-classifications.shp: gz/TSP_Classifications_pdx.zip
shp/tsp-district-boundaries.shp: gz/TSP_District_Boundaries_pdx.zip
shp/urban-renewal-areas.shp: gz/Urban_Renewal_Areas_pdx.zip
shp/vegetation.shp: gz/vegetation_pdx.zip
shp/watersheds.shp: gz/Watersheds_Web_BES_pdx.zip
shp/wellhead-prot-areas.shp: gz/Wellhead_Prot_Areas_pdx.zip
shp/zipcodes.shp: gz/Zipcode_metro.zip
shp/zoning_pdx.shp: gz/Zoning.zip
rm -rf $(basename $@)
mkdir -p $(basename $@)
tar --exclude="._*" -xzm -C $(basename $@) -f $<
for file in `find $(basename $@)/PortlandZoning -name '*.shp'`; do \
echo shp/$$(basename $$file); \
ogr2ogr -dim 2 -f 'ESRI Shapefile' -t_srs 'EPSG:4326' shp/$$(basename $$file) $$file; \
done
rm -rf $(basename $@)
################################################################################
# SHAPEFILES: OREGON METRO
################################################################################
shp/master-address.shp: gz/metro/master_address.zip
shp/buildings.shp: gz/metro/buildings.zip
shp/blockgroup-1990.shp: gz/metro/blockgrp1990.zip
shp/blockgroup-2000.shp: gz/metro/blockgrp2000.zip
shp/blockgroup-2010.shp: gz/metro/blockgrp2010.zip
shp/urban-growth-boundary.shp: gz/metro/ugb.zip
shp/urban-growth-boundary-history.shp: gz/metro/ugb_history.zip
shp/water.shp: gz/metro/mjriv_fi.zip
################################################################################
# SHAPEFILES: TRIMET
################################################################################
shp/trimet-boundary.shp: gz/trimet/tm_boundary.zip
shp/trimet-park-and-rides.shp: gz/trimet/tm_parkride.zip
shp/trimet-rail-stops.shp: gz/trimet/tm_rail_stops.zip
shp/trimet-rail-lines.shp: gz/trimet/tm_rail_lines.zip
shp/trimet-routes.shp: gz/trimet/tm_routes.zip
shp/trimet-stops.shp: gz/trimet/tm_stops.zip
shp/trimet-route-stops.shp: gz/trimet/tm_route_stops.zip
shp/trimet-transit-centers.shp: gz/trimet/tm_tran_cen.zip
################################################################################
# SHAPEFILES: OPENSTREETMAP
################################################################################
shp/osm.shp: gz/osm/portland_oregon.osm2pgsql-shapefiles.zip
rm -rf $(basename $@)
mkdir -p $(basename $@)
tar --exclude="._*" -xzm -C $(basename $@) -f $<
chmod 644 $(basename $@)/*
mv $(basename $@)/* shp
rm -rf $(basename $@)
touch $@
################################################################################
# SHAPEFILES: CUSTOM/DROPBOX
#
# Rehosted public data not available on the web or data that's difficult
# to access as a result of cumbersome UIs or other burdensome reasons
################################################################################
shp/school-attendance-areas.shp: gz/dropbox/school-attendance-areas.zip # (school districts)
################################################################################
# SHAPEFILES: PDX.EDU
################################################################################
shp/historic-trolleys.shp: gz/historic/Trolley_All.zip
rm -rf $(basename $@)
mkdir -p $(basename $@)
tar -xzm -C $(basename $@) -f $<
find $(basename $@) -name 'Alberta*' -exec mv '{}' $(dir $@) \;
for file in shp/historic-trolleys/*.shp; do \
ogr2ogr -dim 2 -f 'ESRI Shapefile' -update -append $(dir $@)Alberta.shp $$file; \
done
ogr2ogr -dim 2 -f 'ESRI Shapefile' -t_srs EPSG:4326 $@ $(dir $@)Alberta.shp
rm -rf $(basename $@)
rm $(dir $@)Alberta.*
################################################################################
# SHAPEFILES: SECOND-STAGE SIMPLIFIED
################################################################################
# Freeway, highway, primary arterial, secondary arterial and major residential
shp/streets-major.shp: shp/streets.shp
ogr2ogr -where 'TYPE IN (1110, 1200, 1300, 1400, 1450)' $@ $<
# Simplified portland-only buildings
shp/buildings/portland.shp: shp/buildings.shp
mkdir -p $(dir $@)
ogr2ogr -dialect sqlite \
-sql "select BLDG_ID, ST_UNION(Geometry), \
case lower(BLDG_USE) \
when 'commercial general' then 'commercial' \
when 'commercial grocery' then 'retail' \
when 'commercial hotel' then 'hotel' \
when 'commercial office' then 'office' \
when 'commercial restaurant' then 'commercial' \
when 'commercial retail' then 'retail' \
when 'industrial' then 'industrial' \
when 'institutional religious' then 'church' \
when 'multi family residential' then 'apartments' \
when 'parking' then 'garage' \
when 'single family residential' then 'residential' \
else NULL \
end as BLDG_USE \
from buildings \
where SUBAREA = 'City of Portland' \
group by BLDG_ID, BLDG_USE" $@ $<
################################################################################
# SHAPEFILES: META
################################################################################
shp/%.shp:
rm -rf $(basename $@)
mkdir -p $(basename $@)
tar --exclude="._*" -xzm -C $(basename $@) -f $<
for file in `find $(basename $@) -name '*.shp'`; do \
ogr2ogr -dim 2 -f 'ESRI Shapefile' -t_srs 'EPSG:4326' $(basename $@).$${file##*.} $$file; \
chmod 644 $(basename $@).$${file##*.}; \
done
rm -rf $(basename $@)
################################################################################
# CSV
################################################################################
csv/crime-latest.csv: gz/crime_incident_data.zip
rm -rf $(basename $@)
mkdir -p $(basename $@)
echo '<OGRVRTDataSource> \
<OGRVRTLayer name="$(notdir $(basename $@))"> \
<SrcDataSource>$(@F)</SrcDataSource> \
<GeometryType>wkbPoint</GeometryType> \
<LayerSRS>EPSG:2913</LayerSRS> \
<GeometryField encoding="PointFromColumns" x="X Coordinate" y="Y Coordinate"/> \
<Field name="id" src="Record ID" /> \
<Field name="date" src="Report Date" /> \
<Field name="time" src="Report Time" /> \
<Field name="offense type" src="Major Offense Type" /> \
<Field name="address" src="Address" /> \
<Field name="neighborhood" src="Neighborhood" /> \
<Field name="precinct" src="Police Precinct" /> \
<Field name="district" src="Police District" /> \
</OGRVRTLayer> \
</OGRVRTDataSource>' > $(@D)/$(notdir $(basename $@)).vrt
tar -xzm -C $(basename $@) -f $<
mv $(basename $@)/*.csv $(basename $@).csv
rm -rf $(basename $@)
cd $(dir $@) && ogr2ogr -overwrite -f CSV -lco GEOMETRY=AS_XY -t_srs EPSG:4326 $(notdir $(basename $@))-wgs84.csv $(notdir $(basename $@)).vrt
rm $(basename $@).vrt
csv/crime-%.csv: gz/crime_incident_data_%.zip
rm -rf $(basename $@)
mkdir -p $(basename $@)
echo '<OGRVRTDataSource> \
<OGRVRTLayer name="$(notdir $(basename $@))"> \
<SrcDataSource>$(@F)</SrcDataSource> \
<GeometryType>wkbPoint</GeometryType> \
<LayerSRS>EPSG:2913</LayerSRS> \
<GeometryField encoding="PointFromColumns" x="X Coordinate" y="Y Coordinate"/> \
<Field name="id" src="Record ID" /> \
<Field name="date" src="Report Date" /> \
<Field name="time" src="Report Time" /> \
<Field name="offense type" src="Major Offense Type" /> \
<Field name="address" src="Address" /> \
<Field name="neighborhood" src="Neighborhood" /> \
<Field name="precinct" src="Police Precinct" /> \
<Field name="district" src="Police District" /> \
</OGRVRTLayer> \
</OGRVRTDataSource>' > $(@D)/$(notdir $(basename $@)).vrt
tar -xzm -C $(basename $@) -f $<
mv $(basename $@)/*.csv $(basename $@).csv
rm -rf $(basename $@)
cd $(dir $@) && ogr2ogr -overwrite -f CSV -lco GEOMETRY=AS_XY -t_srs EPSG:4326 $(notdir $(basename $@))-wgs84.csv $(notdir $(basename $@)).vrt
rm $(basename $@).vrt
################################################################################
# TOPOJSON
################################################################################
topo/crime-%.json: csv/crime-%.csv
mkdir -p $(dir $@)
$(TOPOJSON) -x "X Coordinate" -y "Y Coordinate" -- $< > $@
topo/historic-trolleys.json: shp/historic-trolleys.shp
mkdir -p $(dir $@)
$(TOPOJSON) -q 1e3 -s 9e-9 -p street=STREET,year=+Year_,notes=Notes -- $< > $@
topo/streets-ungrouped.json: shp/streets-major.shp
mkdir -p $(dir $@)
${TOPOJSON} \
-o $@ \
--no-pre-quantization \
--simplify=1e-7 \
--id-property=FULL_NAME \
-p length=LENGTH \
-- $<
topo/streets.json: topo/streets-ungrouped.json
mkdir -p $(dir $@)
node_modules/.bin/topojson-group \
-o $@ \
-- $<
topo/projected/buildings.json: shp/buildings/portland.shp
topo/projected/parks.json: shp/parks.shp
topo/projected/streets.json: topo/streets.json
topo/projected/%.json:
mkdir -p $(dir $@)
$(TOPOJSON) \
--width 960 \
--height 800 \
--margin 20 \
-s .50 \
-o $@ \
-- $<
################################################################################
# PNG
################################################################################
png/%.png: shp/%.shp bin/rasterize
mkdir -p $(dir $@)
node bin/rasterize $< $@
pngnq -f -n 256 -s 10 -Q f -e ".png" $@