Show the code
library(readr) # read CSV
library(dplyr) # data wrangling
library(sf) # simple features
library(ggplot2) # maps
ggplot
Using Location Datalibrary(readr) # read CSV
library(dplyr) # data wrangling
library(sf) # simple features
library(ggplot2) # maps
read_csv
to Read Text File with Client Data<- read_csv("./location-data/clients.csv") clients
<- clients %>%
clients filter(latitude <= 42.33 &
>= 42.22 &
latitude >= -83.8 &
longitude <= -83.65) longitude
sf
Object While Indicating Coordinate Reference System (CRS)<- st_as_sf(clients,
point coords = c("longitude", "latitude"),
crs = 4269) # A2 is NAD1983
# write to shapefile
st_write(point,
"./shapefiles/clients/clients.shp",
append = FALSE) # replace; don't append
<- read_sf("./shapefiles/AA_City_Boundary/AA_City_Boundary.shp")
city_boundary
<- read_sf("./shapefiles/Roads/RoadCenterlines.shp")
WashtenawRoads
<- st_crop(WashtenawRoads,
AnnArborRoads # crop to only get A2 roads city_boundary)
ggplot(city_boundary) +
geom_sf(alpha = .5) +
geom_sf(data = AnnArborRoads,
color = "darkgrey") +
geom_sf(data = point,
aes(color = program),
size = 3) +
labs(title = "Ann Arbor",
subtitle = "Location of Program Clients") +
scale_color_viridis_d() +
scale_fill_viridis_d() +
theme_minimal() +
theme(plot.title = element_text(size = rel(2)),
axis.text = element_text(size = rel(.5)),
legend.position = "bottom")