-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmap_preprocess.yml
91 lines (65 loc) · 2.89 KB
/
map_preprocess.yml
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
target_default: map_preprocess
packages:
- vizlab
- rgdal
- dplyr
- tibble
- sbtools
- maptools
- jsonlite
- sp
- geojsonio
sources:
- scripts/map_preprocess/fetch_url.R
- scripts/map_preprocess/process_zip_to_shp.R
- scripts/map_preprocess/geo_utils.R
targets:
# --- parameter --- #
display_proj:
command: CRS(I("+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997 +b=6370997 +units=m +no_defs"))
svg_x:
command: I(800)
svg_y:
command: I(500)
topo_simple:
command: I(1e-4)
topo_quant:
command: I(1e4)
svg_prec:
command: I(1)
# --- fetch --- #
# See https://www.census.gov/geo/maps-data/data/cbf/cbf_state.html for details on this file.
cache/pre_state_boundaries_census.zip:
command: fetch_url(target_name, I('http://www2.census.gov/geo/tiger/GENZ2017/shp/cb_2017_us_state_20m.zip'))
# --- process --- #
state_boundaries_census_sp:
command: read_shp_zip('cache/pre_state_boundaries_census.zip', skip = I(list(STATEFP=c('69','66','60'))))
site_locations_sp:
command: readRDS('cache/site_locations_sp.rds')
site_locations_albers_sp:
command: spTransform(site_locations_sp, display_proj)
state_boundaries_albers_sp:
command: spTransform(state_boundaries_census_sp, display_proj)
state_boundaries_mutated_sp:
command: mutate_sp_coords(state_boundaries_albers_sp, STATEFP = I(list('02', c('72', '78'), c('15'))),
scale = I(c(0.47, 3, 1.5)), shift_x = I(c(90, -120, 520)), shift_y = I(c(-465, 90, -110)), rotate = I(c(-50, 20, -35)))
site_locations_mutated_sp:
command: mutate_sp_coords(site_locations_albers_sp, ref = state_boundaries_albers_sp, STATEFP = I(list('02', c('72', '78'), c('15'))),
scale = I(c(0.47, 3, 1.5)), shift_x = I(c(90, -120, 520)), shift_y = I(c(-465, 90, -110)), rotate = I(c(-50, 20, -35)))
state_boundaries_scaled_sp:
command: scale_fit_sp_coords(state_boundaries_mutated_sp, range_x = svg_x, range_y = svg_y)
site_locatations_scaled_sp:
command: scale_fit_sp_coords(site_locations_mutated_sp, ref = state_boundaries_mutated_sp, range_x = svg_x, range_y = svg_y)
cache/state_boundaries_scaled.geojson:
command: geojson_write(state_boundaries_scaled_sp, file = target_name) # confirmed this looks good on http://mapshaper.org/
cache/site_locations_scaled.geojson:
command: geojson_write(site_locatations_scaled_sp, file = target_name) # confirmed this looks good on http://mapshaper.org/
cache/state_boundaries.svg:
command: geo2svg("cache/state_boundaries_scaled.geojson", target_name,
w = svg_x, h = svg_y, svg_prec = svg_prec, topo_simple = topo_simple, topo_quant = topo_quant)
cache/site_coords.tsv:
command: points_to_svg_coords('cache/site_locations_scaled.geojson', target_name)
map_preprocess:
depends:
- cache/state_boundaries.svg
- cache/site_coords.tsv