0

I'm trying to create an interactive Markdown webpage in R-studio. I need to use the leaflet package to complete this assignment. I want my map to display polygon shapes that display park boundaries in San Antonio, TX. Here is the dataset I am using https://data.sanantonio.gov/dataset/park-boundaries1/resource/162f2658-e535-4c05-b4ae-8fdc545c9f3b

## I want the map to have geometric shapes that will display the boundaries of every 
## San Antonio park listed in the dataset.

install.packages("leaflet")
library(leaflet)
SA_Parks <- read.csv("Park_Boundaries.csv")
SA_Parks <- SA_Parks[complete.cases(SA_Parks),]
m <- leaflet() %>% 
  addTiles()
m

1
  • Seems like you're missing a call to addPolygons or such. Have you gone through the help docs?
    – r2evans
    Commented Jul 7, 2021 at 21:45

1 Answer 1

0

First of all, you need to get polygon data of park boundaries, "Park_Boundaries.geojson" like this. https://data.sanantonio.gov/dataset/park-boundaries1/resource/a338a450-d8a6-4eb9-8946-01d74f3a8824?inner_span=True

This is geojson data and easily read by Rstudio.

Then, mapping with leaflet.

library(leaflet)
parks <- geojsonio::geojson_read("Park_Boundaries.geojson", what = "sp")
m <- parks %>% 
  leaflet() %>% 
  addTiles() %>% 
  addPolygons()
m

I believe that this is what you want to do.

1
  • Thank you! this is exactly what I was trying to do.
    – Brock J
    Commented Jul 7, 2021 at 22:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.