Hello, I'm relatively new to this, so forgive me if there's a simple answer I'm not seeing. My state recently legalized medical marijuana, but has strict rules on where dispensaries can set up. I imported shape files for where they can set up in Oklahoma City based on zoning, and I have a separate file of excluded areas (they can't be within 1,000 feet of a school, church, or playground). Both maps work when I plot them alone, but I can't get them to work together when I try to layer them. Any ideas?
Code for the zoning areas map:
library(ggplot2) library(sf) zoning_shapes <- "Primary_Zoning.shp" zoning <- st_read(zoning_shapes) library(dplyr) zoning_1 <- filter(zoning, P_ZONE!="R-1") zoning_2 <- filter(zoning_1, P_ZONE!="SPUD") zoning_3 <- filter(zoning_2, P_ZONE!="AA") zoning_4 <- filter(zoning_3, P_ZONE!="R-2") zoning_5 <- filter(zoning_4, P_ZONE!="R-4") zoning_6 <- filter(zoning_5, P_ZONE!="PUD") zoning_7 <- filter(zoning_6, P_ZONE!="I-3") zoning_8 <- filter(zoning_7, P_ZONE!="R-A") zoning_9 <- filter(zoning_8, P_ZONE!="O-1") zoning_10 <- filter(zoning_9, P_ZONE!="R-3") zoning_11 <- filter(zoning_10, P_ZONE!="R-A2") zoning_12 <- filter(zoning_11, P_ZONE!="R-1ZL") zoning_13 <- filter(zoning_12, P_ZONE!="R-3M") zoning_14 <- filter(zoning_13, P_ZONE!="R-4M") zoning_15 <- filter(zoning_14, P_ZONE!="R-MH-1") zoning_16 <- filter(zoning_15, P_ZONE!="R-MH-2") zoning_17 <- filter(zoning_16, P_ZONE!="C-HC") zoning_18 <- filter(zoning_17, P_ZONE!="HP") zoning_19 <- filter(zoning_18, P_ZONE!="NC") zoning_20 <- filter(zoning_19, P_ZONE!="AE-1") zoning_21 <- filter(zoning_20, P_ZONE!="AE-2") ggplot(zoning_21) + geom_sf() + theme_void() + theme(panel.grid.major = element_line(colour = 'transparent'))
Code for the excluded areas:
locations <- read_csv("Marijuana_map_CSV.csv") View(locations) mew <- colorFactor(c("red", "blue", "purple"), domain=c("School", "Church", "Playground")) okc_locations <- leaflet(locations) %>% addTiles() %>% setView(-97.5164, 35.4676, zoom = 7) %>% addCircles(~Longitude, ~Latitude, popup=locations$Name, weight = 3, radius=304.8, color=~mew(locations$Type), stroke = T, fillOpacity = 0.8) okc_locations
I tried adding the zoning data as polygons in leaflet, but it doesn't show up. I also tried adding the excluded areas in ggplot, but I get one red dot very far from the zoning shapes, and nothing else. If anybody has ideas on how to fix it, I'd be quite grateful.