-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy path02-gis-1.R
46 lines (36 loc) · 1.15 KB
/
02-gis-1.R
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
# Challenge: import 1986 ward data and project it into the correct UTM projection
library(sf)
ward86 <- st_read("data/ward1986.shp")
ward86 <- st_transform(ward86, 32616)
plot(ward86)
plot(st_geometry(ward86))
?st_centroid
centroids <- st_centroid(ward86)
plot(st_geometry(centroids), cex = 0.1)
plot(st_geometry(ward86), add = T)
plot(st_geometry(ward86))
plot(st_geometry(centroids), cex = 0.1, add = T)
# challenge: figure out how to set a bounding box to something else
st_bbox(centroids)
ward_bbox <- st_bbox(ward86)
# to get coordinates of something
st_coordinates(centroids)
# random detour - plot a single ward and centroid
library(dplyr)
ward1 <- filter(ward86, WARDNO == "01")
centroid1 <- filter(centroids, WARDNO == "01")
plot(st_geometry(ward1))
plot(st_geometry(centroid1), add = T, cex = 0.1)
# make buffers
st_crs(centroids)
buffers <- st_buffer(centroids, 1000)
# challenge: plot wards, centroids, buffers altogether on one map
plot(st_geometry(buffers), col = "yellow")
plot(st_geometry(ward86), add = T)
plot(st_geometry(centroids), add = T, cex = 0.2, col = "red")
# functions learned
st_geometry()
st_centroid()
st_buffer()
st_bbox()
st_coordinates()