-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy path03-gis-2.R
42 lines (31 loc) · 895 Bytes
/
03-gis-2.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
# challenge 1 time
library(sf)
library(ggplot2)
library(dplyr)
ward98 <- st_read("data/ward1998.shp")
ward98 <- st_transform(ward98, 32616)
water <- st_read("data/Waterways.geojson")
water <- st_transform(water, 32616)
centroids <- st_centroid(ward98)
ggplot(data = ward98) +
geom_sf()
ggplot(data = centroids) +
geom_sf()
ggplot() +
geom_sf(data = ward98, aes(fill = COUNT)) +
geom_sf(data = centroids, color = "red")
ggplot() +
geom_sf(data = water)
View(water)
names(water)
unique(water$name)
water_clean <- filter(water, name != "LAKE MICHIGAN")
ggplot() +
geom_sf(data = ward98) +
geom_sf(data = water_clean, color = "blue")
intersects <- st_intersects(ward98, water_clean)
water_wards <- filter(ward98, lengths(intersects) > 0)
ggplot() +
geom_sf(data = ward98) +
geom_sf(data = water_wards, fill = "lightblue") +
geom_sf(data = water_clean, color = "blue")