FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
library(tidyverse)
## -- Attaching packages --------------------------------------------------------------------------------------------------- tidyverse 1.2.1 --
## v ggplot2 3.2.0 v purrr 0.3.2
## v tibble 2.1.1 v dplyr 0.8.1
## v tidyr 0.8.3 v stringr 1.4.0
## v readr 1.3.1 v forcats 0.4.0
## -- Conflicts ------------------------------------------------------------------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(sf)
## Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
Rosario_barrios <- st_read("https://datos.rosario.gob.ar/sites/default/files/barrios.gml",
stringsAsFactors = FALSE)
## Reading layer `barrios' from data source `https://datos.rosario.gob.ar/sites/default/files/barrios.gml' using driver `GML'
## Simple feature collection with 50 features and 4 fields
## geometry type: POLYGON
## dimension: XY
## bbox: xmin: -60.79693 ymin: -33.03934 xmax: -60.61278 ymax: -32.86941
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
CSalud_rosario <- st_read("https://datos.rosario.gob.ar/sites/default/files/geo_salud.gml")
## Reading layer `OGRGeoJSON' from data source `https://datos.rosario.gob.ar/sites/default/files/geo_salud.gml' using driver `GML'
## Simple feature collection with 67 features and 22 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: -60.76006 ymin: -33.02803 xmax: -60.61493 ymax: -32.88314
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
names(CSalud_rosario)
## [1] "fid" "id" "name"
## [4] "codigo_calle" "calle" "altura"
## [7] "bis" "direccion" "etiquetas"
## [10] "subtipo" "divs_admin" "coordenada_ref_x"
## [13] "coordenada_ref_y" "calculo_coord_ref" "lineas_tup"
## [16] "titular" "estado" "tipo_geometria"
## [19] "ultima_actualizacion" "contactos" "atencion"
## [22] "piso" "geometry"
ggplot() +
geom_sf(data = Rosario_barrios)
ggplot() +
geom_sf(data = CSalud_rosario)
ggplot() +
geom_sf(data = Rosario_barrios) +
geom_sf(data = CSalud_rosario,
aes(x = coordenada_ref_x, y = coordenada_ref_x),
alpha = .3,
color = "orange")
## Warning: Ignoring unknown aesthetics: x, y
CSalud_rosario <- CSalud_rosario %>%
filter(!is.na(coordenada_ref_x), !is.na(coordenada_ref_y)) %>%
st_as_sf(coords = c("coordenada_ref_x", "coordenada_ref_y"), crs = 4326)
ggplot() +
geom_sf(data = Rosario_barrios) +
geom_sf(data = CSalud_rosario, color = "orange", alpha = .3)
csalud_con_barriosrosario <- st_join(CSalud_rosario, Rosario_barrios)
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
csalud_con_barriosrosario %>% head
## Simple feature collection with 6 features and 26 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: -60.73402 ymin: -33.00581 xmax: -60.66739 ymax: -32.88314
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
## fid id name codigo_calle
## 1 F0 3171 Centro de Salud "Elena Bazzet" 33200
## 2 F1 1175 Centro de Salud "Dr. Salvador Mazza" 55000
## 3 F2 1176 Centro de Salud "Itatí" 53200
## 4 F3 1178 Centro de Salud "Vecinal La Florida" 31700
## 5 F4 1182 Centro de Salud "Emaús" 92850
## 6 F5 1188 Centro de Salud "Dr. Roque Coulin" 57750
## calle altura bis direccion
## 1 CABRINI MADRE 2717 0 CABRINI MADRE 2717
## 2 GRANDOLI FLODUARDO 3498 0 GRANDOLI FLODUARDO 3498
## 3 GARIBALDI JOSE 2502 0 GARIBALDI JOSE 2502
## 4 BRAILLE LUIS 1205 0 BRAILLE LUIS 1205
## 5 URDINARRAIN 7900 0 URDINARRAIN 7900
## 6 HUMBERTO 1º 2033 0 HUMBERTO 1º 2033
## etiquetas subtipo
## 1 Salud, Datos útiles LUGAR
## 2 Salud, Datos útiles LUGAR
## 3 Salud, Datos útiles LUGAR
## 4 Salud, Datos útiles LUGAR
## 5 Salud, Datos útiles LUGAR
## 6 Salud, Datos útiles LUGAR
## divs_admin
## 1 Distrito: SUDOESTE. Vecinal: San Francisco Solano. Seccional Policial: Comisaría 21. Fracción Censal: 50. Radio Censal: 5021. Zona Notificación: 11.
## 2 Distrito: NORTE. Vecinal: Sin Vecinal. Seccional Policial: Sub-comisaría 2. Fracción Censal: 03. Radio Censal: 0308. Zona Notificación: 24.
## 3 Distrito: SUDOESTE. Vecinal: Villa 57 y 58. Seccional Policial: Comisaría 15. Fracción Censal: 46. Radio Censal: 4611. Zona Notificación: 13.
## 4 Distrito: NORTE. Vecinal: La Florida. Seccional Policial: Sub-comisaría 27. Fracción Censal: 04. Radio Censal: 0411. Zona Notificación: 21.
## 5 Distrito: NOROESTE. Vecinal: Vecinal Amiga. Seccional Policial: Comisaría 17. Fracción Censal: 11. Radio Censal: 1103. Zona Notificación: 39.
## 6 Distrito: NOROESTE. Vecinal: Ludueña Norte y Moreno. Seccional Policial: Comisar¡a 12. Fracción Censal: 12. Radio Censal: 1217. Zona Notificación: 19.
## coordenada_ref_x coordenada_ref_y calculo_coord_ref
## 1 5437260 6348373 geometria
## 2 5431316 6361513 geometria
## 3 5437617 6350975 geometria
## 4 5434440 6361960 geometria
## 5 5431435 6358198 geometria
## 6 5435297 6356762 geometria
## lineas_tup titular estado
## 1 133 Negra, 133 Verde, 134, 143 Negra, Ronda CUR Sur Municipal Publicado
## 2 106 Ibarlucea Municipal Publicado
## 3 <NA> Municipal Publicado
## 4 102 Negra, 153 Negra, 153 Roja Municipal Publicado
## 5 115, 142 Roja (5 a 23hs), 146 Negra, 146 Roja Municipal Publicado
## 6 112 Roja Municipal Publicado
## tipo_geometria ultima_actualizacion contactos atencion piso
## 1 Punto 01/08/2017 09:35 Teléfono: 4809197. <NA> <NA>
## 2 Punto 01/08/2017 09:35 Teléfono: 4806636. <NA> <NA>
## 3 Punto 01/08/2017 09:35 <NA> <NA> <NA>
## 4 Punto 01/08/2017 09:35 Teléfono: 4806637. <NA> <NA>
## 5 Punto 01/08/2017 09:35 Teléfono: 4807804. <NA> <NA>
## 6 Punto 01/08/2017 09:35 Teléfono: 4804819. <NA> <NA>
## gml_id MSLINK BARRIO OBSERVACIO
## 1 barrios.50 27 Mercedes de San Martín 10
## 2 barrios.46 1 La Cerámica y Cuyo 10
## 3 barrios.28 26 Matheu 10
## 4 barrios.40 3 Alberdi 10
## 5 barrios.43 5 Fisherton 10
## 6 barrios.34 10 Ludueña Sur y Norte 10
## geometry
## 1 POINT (-60.67139 -33.00581)
## 2 POINT (-60.73401 -32.88698)
## 3 POINT (-60.66739 -32.98237)
## 4 POINT (-60.7006 -32.88314)
## 5 POINT (-60.73299 -32.91688)
## 6 POINT (-60.69181 -32.93006)
names(csalud_con_barriosrosario)
## [1] "fid" "id" "name"
## [4] "codigo_calle" "calle" "altura"
## [7] "bis" "direccion" "etiquetas"
## [10] "subtipo" "divs_admin" "coordenada_ref_x"
## [13] "coordenada_ref_y" "calculo_coord_ref" "lineas_tup"
## [16] "titular" "estado" "tipo_geometria"
## [19] "ultima_actualizacion" "contactos" "atencion"
## [22] "piso" "gml_id" "MSLINK"
## [25] "BARRIO" "OBSERVACIO" "geometry"
csalud_con_barriosrosario %>%
group_by(BARRIO) %>%
summarise(cantidad = n())
## Simple feature collection with 31 features and 2 fields
## geometry type: GEOMETRY
## dimension: XY
## bbox: xmin: -60.76006 ymin: -33.02803 xmax: -60.61493 ymax: -32.88314
## epsg (SRID): 4326
## proj4string: +proj=longlat +datum=WGS84 +no_defs
## # A tibble: 31 x 3
## BARRIO cantidad geometry
## <chr> <int> <GEOMETRY [°]>
## 1 17 de agosto 1 POINT (-60.65946 -33.011)
## 2 Alberdi 2 MULTIPOINT (-60.7006 -32.88314, -60.69059 -32~
## 3 Alberto Olmedo 1 POINT (-60.66491 -32.93815)
## 4 Alvear 2 MULTIPOINT (-60.68409 -32.97633, -60.67627 -3~
## 5 Antártida Argen~ 1 POINT (-60.76006 -32.94061)
## 6 Azcuenaga 1 POINT (-60.6995 -32.94463)
## 7 Belgrano 1 POINT (-60.71751 -32.94593)
## 8 Centro 6 MULTIPOINT (-60.66919 -32.95501, -60.65146 -3~
## 9 Cinco Esquinas 2 MULTIPOINT (-60.69025 -32.95816, -60.6698 -32~
## 10 Domingo Faustin~ 2 MULTIPOINT (-60.69602 -32.90676, -60.68226 -3~
## # ... with 21 more rows
csalud_GRUP_BARRIOS <- csalud_con_barriosrosario %>%
group_by(BARRIO) %>%
summarise(cantidad = n())
Rosario_barrios <- st_join(Rosario_barrios, csalud_GRUP_BARRIOS)
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
verrrrrr
ggplot() +
geom_sf(data = Rosario_barrios, aes(fill = cantidad)) + scale_fill_viridis_c()