#Comunas#
comunas <- st_read('https://bitsandbricks.github.io/data/CABA_comunas.geojson')
## Reading layer `CABA_comunas' from data source 
##   `https://bitsandbricks.github.io/data/CABA_comunas.geojson' 
##   using driver `GeoJSON'
## Simple feature collection with 15 features and 4 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -58.53152 ymin: -34.70529 xmax: -58.33514 ymax: -34.52754
## Geodetic CRS:  WGS 84
#Barrios#

barrios <- st_read('https://bitsandbricks.github.io/data/CABA_barrios.geojson')
## Reading layer `CABA_barrios' from data source 
##   `https://bitsandbricks.github.io/data/CABA_barrios.geojson' 
##   using driver `GeoJSON'
## Simple feature collection with 48 features and 4 fields
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: -58.53152 ymin: -34.70529 xmax: -58.33514 ymax: -34.52754
## Geodetic CRS:  WGS 84
puestos_flore_barrio = st_join(barrios, puestos_flore)

puestos_flore_barrio = puestos_flore_barrio  %>%filter(!is.na(BARRIO))  %>% group_by(BARRIO) %>%
  summarise(cantidad=n())

Hagamos un primer mapa de florerías en la ciudad de buenos aires

ggplot() +
  geom_sf(data = puestos_flore_barrio, aes(fill=cantidad)) +
  geom_sf_text(data=puestos_flore_barrio, aes(label = BARRIO ), size=2.5, colour = "black") +
    labs(title = "Cantidad de florerias por barrio",
         fill = "Cantidad",
         caption= "Fuente: GCBA",
         y="",
         x="") +
  scale_fill_gradient(low="khaki2", high="deeppink4")
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

Podría ser más lindo ¿No?

m <- leaflet(puestos_flore_barrio) %>%
  setView(-58.391556, -34.616194, 11) %>%
  addTiles()


bins <- c(1, 5, 10, 15, 20,40, Inf)
pal <- colorBin("YlOrRd", domain = puestos_flore_barrio$cantidad, bins = bins)

labels <- sprintf(
  "<strong>%s</strong><br/>%g : Cantidad de florerías ",
  puestos_flore_barrio$BARRIO, puestos_flore_barrio$cantidad
) %>% lapply(htmltools::HTML)
 m %>% addPolygons(
  fillColor = ~pal(cantidad),
  weight = 2,
  opacity = 1,
  color = "white",
  dashArray = "3",
  fillOpacity = 0.7,
  highlightOptions = highlightOptions(
    weight = 5,
    color = "#666",
    dashArray = "",
    fillOpacity = 0.7,
    bringToFront = TRUE),
  label = labels,
  labelOptions = labelOptions(
    style = list("font-weight" = "normal", padding = "3px 8px"),
    textsize = "15px",
    direction = "auto"))
quantile(puestos_flore_barrio$cantidad)
##   0%  25%  50%  75% 100% 
##  1.0  1.0  1.0  8.5 59.0

¿Y si a la cantidad de florerías le sumamos los espacios verdes? Recordá que podés sacar y poner las florerías en este mapa interactivo

espaciosverdes <- st_read('http://cdn.buenosaires.gob.ar/datosabiertos/datasets/espacios-verdes/espacio-verde-publico.geojson')
## Reading layer `espacio_verde_publico_WGS84' from data source 
##   `http://cdn.buenosaires.gob.ar/datosabiertos/datasets/espacios-verdes/espacio-verde-publico.geojson' 
##   using driver `GeoJSON'
## Simple feature collection with 1736 features and 36 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -58.53175 ymin: -34.70557 xmax: -58.33983 ymax: -34.52657
## Geodetic CRS:  WGS 84
espaciosverdes_canteros <- espaciosverdes %>% filter(clasificac =="CANTERO CENTRAL")
espaciosverdes_sincanteros <- espaciosverdes %>% filter(clasificac !="CANTERO CENTRAL")

pal <- colorFactor("Paired",
                    domain = espaciosverdes_sincanteros$clasificac)
greenLeafIcon <- makeIcon(
  iconUrl = "https://leafletjs.com/examples/custom-icons/leaf-green.png",
  iconWidth = 38, iconHeight = 95,
  iconAnchorX = 22, iconAnchorY = 94,
  shadowUrl = "https://leafletjs.com/examples/custom-icons/leaf-shadow.png",
  shadowWidth = 50, shadowHeight = 64,
  shadowAnchorX = 4, shadowAnchorY = 62
)
leaflet(espaciosverdes_sincanteros)  %>% addProviderTiles("CartoDB.Positron")  %>% addPolygons(fillOpacity=1, label = ~paste(nombre,";","Tamaño en m2",area )
    , color = ~pal(clasificac), highlightOptions = highlightOptions(color = "red", weight = 1, bringToFront = TRUE)) %>% addLegend("bottomright", pal = pal, values = ~clasificac, title = "Espacios verdes en CABA",
               labFormat = labelFormat(prefix = ""),
               opacity = 3 )  %>% addMarkers(data = puestos_flore, icon = greenLeafIcon, group = "florerias") %>%  addLayersControl(
    overlayGroups = c("florerias"),
    options = layersControlOptions(collapsed = FALSE)
  )
espaciosverdes_sincanteros <- split(espaciosverdes_sincanteros, espaciosverdes_sincanteros$clasificac)