Interactive map of the MacLeish Field Station property

library(pacman)
p_load(macleish, leaflet, ggmap,mdsr)
names(macleish_layers)
##  [1] "landmarks"         "forests"           "streams"          
##  [4] "challenge_courses" "buildings"         "wetlands"         
##  [7] "boundary"          "research"          "soil"             
## [10] "trails"            "contours_30ft"     "contours_3m"
leaflet() %>%
  addTiles() %>%
  addPolygons(data = macleish_layers[["streams"]],
              weight = 1, color = "blue") %>%
  addPolygons(data = macleish_layers[["buildings"]],
              weight = 5, color = "red") %>%
  addPolygons(data = macleish_layers[["forests"]], weight = 1, color = "#05ad21") %>%
  addMarkers(data = filter(macleish_layers[["landmarks"]], grepl("Met", Label)), 
             popup = ~Label)
leaflet() %>%
  addTiles() %>%
  addPolylines(data = macleish_layers[["research"]], weight = 2, color="blue") %>%
  addPolylines(data = macleish_layers[["trails"]], weight = 2, color = "red") %>%
  addPolylines(data = macleish_layers[["wetlands"]], weight = 1, color = "#0af531") 

Informative interactive map using leaflet that illustrates the nature and extent of restaurant violations in New York City

#Geocoding Unique Addresses
morris_park <- geocode("Morris Park Bake Shop, Bronx, NY 10462")
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=Morris+Park+Bake+Shop,+Bronx,+NY+10462&key=xxx-7L8B2ghRpDMirp_hyjE
morris_park
wendys <- geocode("Wendy's, Brooklyn, NY 11225")
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=Wendy's,+Brooklyn,+NY+11225&key=xxx-7L8B2ghRpDMirp_hyjE
wendys
reynoldspub <- geocode("DJ Reynold's Pub and Restaurant, Manhattanm NY 10019")
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=DJ+Reynold's+Pub+and+Restaurant,+Manhattanm+NY+10019&key=xxx-7L8B2ghRpDMirp_hyjE
reynoldspub
brunos <- geocode("Brunos on the boulevard, Queens, NY 11369")
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=Brunos+on+the+boulevard,+Queens,+NY+11369&key=xxx-7L8B2ghRpDMirp_hyjE
nyc <- geocode("NYC")
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=NYC&key=xxx-7L8B2ghRpDMirp_hyjE
nyc
#upload data with geocode
mydata <- read.csv("Violations_loc.csv", header = TRUE, sep = ",")
#remove na
mynewdata <- na.omit(mydata)
#Filter out NYC
mynewdata <- mydata %>% select(lon,lat) %>% filter( lon> -73.85 & lat< 40.8)
#Sample 500
sample <- mynewdata[sample(nrow(mynewdata), 500), ]
sample_500 <- sample %>% select(lon,lat)
#plot
map <- map <-leaflet() %>%
  addTiles() %>%
  addMarkers(lng = ~lon, lat = ~lat, data = sample_500)
map