setwd(“/Users/cc/Desktop/UBC Y3/Courses/GEOS 372 - Cartography/Lab7”)
install.packages(“leaflet”) library(leaflet) library(sp)
bikeData <- read.csv(“biketheft.csv”)
summary(bikeData)
bikeData\(Longitude <- as.numeric(bikeData\)Longitude) bikeData\(Latitude <- as.numeric(bikeData\)Latitude) class(bikeData\(Latitude) # [1] "numeric" class(bikeData\)Type) # [1] “character”
bikeData_SP <- SpatialPointsDataFrame(bikeData[c(6,7)], bikeData[-c(6,7)]) bikeIcon <- makeIcon(iconUrl = “nikeicon.png”, iconWidth <- 34, iconHeight = 50, iconAnchorX = 17, iconAnchorY = 48)
map <- leaflet() %>% addTiles() %>% addMarkers(data = bikeData, lng = ~Longitude, lat = ~Latitude, clusterOptions = markerClusterOptions(showCoverageOnHover = FALSE), popup = ~paste(“Neighborhood:”,bikeData\(Neighbourhood, "<br /><b>Address:</b>",bikeData\)Hundred_Block, “
Author: Ivy Hsu
DataSource:
VPD Data Portal (2022)
GEOS 372 | Lab Section: L1A
“)) %>% addLegend(position =”bottomright”, colors = c(“#91d467”, “#ebc83d”, “#f68f42”), labels = c(“< 10”, “< 100”, “100+”), opacity = 1, title = “Number of Bike Thefts”) map