Tarea 1 - Mapear Información Geográfica

library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.3     v purrr   0.3.4
## v tibble  3.1.0     v dplyr   1.0.5
## v tidyr   1.1.3     v stringr 1.4.0
## v readr   1.4.0     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(sf)
## Linking to GEOS 3.9.0, GDAL 3.2.1, PROJ 7.2.1
library(ggmap)
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
espacios_verdes <- st_read("espacio-verde-publico.geojson.txt", stringsAsFactors=TRUE)
## Reading layer `espacio_verde_publico_WGS84' from data source `C:\Users\juanp\Documents\Curso Ciencia de Datos\Ciclo 2 - Tareas\espacio-verde-publico.geojson.txt' using driver `GeoJSON'
## Simple feature collection with 1731 features and 31 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -58.53175 ymin: -34.70557 xmax: -58.33983 ymax: -34.52657
## Geodetic CRS:  WGS 84
dim(espacios_verdes)
## [1] 1731   32
summary(espacios_verdes)
##                                               nombre   
##  Cantero Av 27 de Febrero                        :  7  
##  Predio Villa Olímpica (no oficial)              :  4  
##  Hungría                                         :  3  
##  Paseo del Ballet Argentino                      :  3  
##  Cancha auxiliar abierta - Club Atl. Boca Juniors:  2  
##  (Other)                                         :952  
##  NA's                                            :760  
##                                   nombre_ev              clasificac 
##  SIN NOMBRE                            :275   PLAZOLETA       :650  
##  S/D                                   :137   CANTERO CENTRAL :620  
##  SIN DENOMINACION                      : 63   PLAZA           :343  
##  CANTERO AV. 27 DE FEBRERO (no oficial):  7   PARQUE          : 56  
##  PREDIO VILLA OLIMPICA (NO OFICIAL)    :  4   JARDÍN          : 27  
##  (Other)                               :947   PATIO RECREATIVO: 18  
##  NA's                                  :298   (Other)         : 17  
##  patio_de_j                                                apadrinada  
##  NO  :1223   NO                                                 : 568  
##  SI  : 370   GATORADE                                           :  14  
##  NA's: 138   PATAGONIA FLOORING  S.A. -EN TRÁMITE DE RENOVACIÓN-:   7  
##              DIFERENTES NOMBRES                                 :   4  
##              PATAGONIA FLOORING S.A.                            :   4  
##              (Other)                                            : 119  
##              NA's                                               :1015  
##                                                                                                                                       observacio 
##  ESPACIOS VERDES                                                                                                                           :220  
##  no incluidos en el nomenclador de espacios verdes                                                                                         : 25  
##  Redigitalización en Febrero 2020 en base a información enviada por DG Regeneración Urbana                                                 : 20  
##  Agregado en Diciembre de 2017. Veredón verde. Dentro del denominado Barrio Municipal Alte Brown                                           : 19  
##  Redigitalización en Febrero de 2020 en base a información enviada por la DG Regeneración Urbana. Se incorporaron los canteros del Metrobus: 19  
##  (Other)                                                                                                                                   :953  
##  NA's                                                                                                                                      :475  
##                   fuente_geo   fuente_ins 
##  DIGITALIZACION 2009   :  9   E.V.  :693  
##  ESPACIOS VERDES       :684   USIG  :863  
##  ESPACIOS VERDES - USIG:  1   USIG 2:122  
##  USIG                  :998   NA's  : 53  
##  NA's                  : 39               
##                                           
##                                           
##                                                                                                                            ubicacion   
##  DELLEPIANE, LUIS J., TTE. GRAL., AV. E/ LARRAZABAL, AV Y ESCALADA, AV.                                                         :  15  
##  DELLEPIANE, LUIS J., TTE. GRAL., AV. E/ PAZ, GRAL., AV. - RIO NEGRO Y CAÑADA DE GOMEZ                                          :  14  
##  ROCA, CNEL., AV.  E/ PORTELA Y PAZ, GRAL., AV (FALTA RELEVAR COMO SE CRUZAN LAS CALLES A FIN DE ESTABLECER LIMITES DE CANTEROS):  14  
##  CONJUNTO PLAZOLETAS HOLMBERG - CONGRESO - PLAZA - PARQUE (PROYECTO AUTOPISTA U5                                                :  13  
##  CONJUNTO DE CANTEROS UBICADOS ENTRE BACH, JUAN SEBASTIAN - PARQUE - DONADO - CONGRESO                                          :  12  
##  (Other)                                                                                                                        :1561  
##  NA's                                                                                                                           : 102  
##      decreto          fecha_decr          ordenanza_        fecha_orde 
##  De Hecho:  58   16/10/2001:  25   45.591      :  21   18/09/2001: 29  
##  2       :  22   02/01/1992:  20   27.387      :  20   07/12/1991: 23  
##  De hecho:  22   07/11/2003:  18   LEY N° 644  :  17   09/10/2003: 20  
##  186/17  :   9   20/01/1998:  12   LEY 1.128   :   9   23/01/1973: 19  
##  5.527   :   8   29/12/2014:  11   LEY N.º 5810:   9   16/07/2002: 14  
##  (Other) : 380   (Other)   : 451   (Other)     : 633   (Other)   :640  
##  NA's    :1232   NA's      :1194   NA's        :1022   NA's      :986  
##    boletin_of       fecha_bole            BARRIO         COMUNA      
##  ACTA   : 49   24/10/2001: 27   VILLA LUGANO : 184   Min.   : 0.000  
##  1303   : 26   29/01/1973: 20   VILLA SOLDATI: 135   1st Qu.: 4.000  
##  19.205 : 21   14/11/2003: 19   PALERMO      : 123   Median : 8.000  
##  14.467 : 20   27/01/1992: 19   RETIRO       :  98   Mean   : 7.682  
##  1818   : 17   09/01/2015: 10   SAAVEDRA     :  94   3rd Qu.:11.000  
##  (Other):642   (Other)   :678   (Other)      :1091   Max.   :15.000  
##  NA's   :956   NA's      :958   NA's         :   6                   
##       Fech_padri        Vig_padri   
##  29-07-2013:  17   29-07-2016:  17  
##  03-12-2009:  10   03-12-2012:  10  
##  12-12-2013:   6   12-12-2016:   6  
##  26-07-2013:   6   26-07-2016:   6  
##  28-03-2011:   5   09-04-2015:   4  
##  (Other)   :  25   (Other)   :  25  
##  NA's      :1662   NA's      :1663  
##                                                Alc_conven  
##  Instalación y mantenimiento de estaciones aeróbicas:  15  
##  Jardinería fina, corte y limpieza                  :  14  
##  Corte y limpieza                                   :  12  
##  Puesta en valor (no incluye corte y limpieza)      :  10  
##  Puesta en valor, corte y limpieza                  :   6  
##  (Other)                                            :  10  
##  NA's                                               :1664  
##                        nom_mapa     id_ev_pub           area          
##  Cantero Av 27 de Febrero  :  7   Min.   :   2.0   Min.   :      0.0  
##  Paseo del Ballet Argentino:  3   1st Qu.: 601.5   1st Qu.:    224.0  
##  Complejo Villa Olímpica   :  2   Median :1067.0   Median :    676.3  
##  Hungría                   :  2   Mean   :1045.9   Mean   :   9409.6  
##  Martín Boneo y Villalonga :  2   3rd Qu.:1504.0   3rd Qu.:   2782.2  
##  (Other)                   :952   Max.   :1953.0   Max.   :2352162.4  
##  NA's                      :763                                       
##    perimeter        DGEV_Padri  Mant_2017  
##  Min.   :    0.00   SI  :  82   SI  :  83  
##  1st Qu.:    0.00   NA's:1649   NA's:1648  
##  Median :   18.18                          
##  Mean   : 1945.19                          
##  3rd Qu.:  856.88                          
##  Max.   :15917.93                          
##                                            
##                                                                                               TAREAS    
##  Riego - Patio de juegos con solado antigolpes - Hamaca inclusiva - Parquización - Nuevos solados:   5  
##  Parquización - Iluminación                                                                      :   3  
##  Parquización - Nuevos solados                                                                   :   3  
##  Riego - Parquización - Nuevos solados - Nuevo mobiliario y equipamiento - Iluminación           :   3  
##  Riego - Parquización                                                                            :   2  
##  (Other)                                                                                         :  67  
##  NA's                                                                                            :1648  
##         ESTADO       SUP_TOTAL        Canil      Posta_aero 
##  Finalizada:  83   Min.   :    0.0   -   :   7   -   :   5  
##  NA's      :1648   1st Qu.:    0.0   NO  : 130   NO  : 104  
##                    Median :    0.0   SI  :  58   SI  :  61  
##                    Mean   :  456.1   NA's:1536   NA's:1561  
##                    3rd Qu.:    0.0                          
##                    Max.   :77100.0                          
##                                                             
##           geometry   
##  MULTIPOLYGON :1731  
##  epsg:4326    :   0  
##  +proj=long...:   0  
##                      
##                      
##                      
## 

Mapa número 1: Mapa coroplético que muestre la distribución geográfica de una variable numérica.

Se muestra la distribución geográfica de los espacios verdes en la Ciudad de Buenos Aires y su la densidad según el tamaño de cada uno de los espacios.

ggplot(espacios_verdes)+
  geom_sf(aes(fill=area), color="green")+
  labs(title="Espacios verdes en CABA",
       subtitle="Densidad de los espacios")+
  scale_fill_viridis_c(direction = +1)

Mapa número 2: Mapa coroplético que muestre la distribución geográfica de una variable categórica.

espacios_verdes <- mutate(espacios_verdes,
                          Superficie=if_else(area>=500000, "mayor a 500k", "menor a 500k"))
ggplot(espacios_verdes)+
  geom_sf(aes(fill=Superficie))

Tarea 2: Unir Datos Espaciales.

comunas_norte <- filter(espacios_verdes, COMUNA%in% c("1","2","14","13"))
ggplot(comunas_norte)+
  geom_sf(aes(fill=area), color="green")

barrios_caba <- read.csv("barrios.csv", stringsAsFactors = TRUE)
class(barrios_caba)
## [1] "data.frame"
barrios_caba <- st_as_sf(barrios_caba, wkt = "WKT", crs=4326)
st_crs(barrios_caba)
## Coordinate Reference System:
##   User input: EPSG:4326 
##   wkt:
## GEOGCRS["WGS 84",
##     DATUM["World Geodetic System 1984",
##         ELLIPSOID["WGS 84",6378137,298.257223563,
##             LENGTHUNIT["metre",1]]],
##     PRIMEM["Greenwich",0,
##         ANGLEUNIT["degree",0.0174532925199433]],
##     CS[ellipsoidal,2],
##         AXIS["geodetic latitude (Lat)",north,
##             ORDER[1],
##             ANGLEUNIT["degree",0.0174532925199433]],
##         AXIS["geodetic longitude (Lon)",east,
##             ORDER[2],
##             ANGLEUNIT["degree",0.0174532925199433]],
##     USAGE[
##         SCOPE["Horizontal component of 3D system."],
##         AREA["World."],
##         BBOX[-90,-180,90,180]],
##     ID["EPSG",4326]]
barrios_caba <- st_transform(barrios_caba, crs = 4326)
class(barrios_caba)
## [1] "sf"         "data.frame"
ggplot(barrios_caba)+
  geom_sf(fill="blue", color="white")

ggplot()+
  geom_sf(data=barrios_caba)+
  geom_sf(data=espacios_verdes, aes(fill=area), color="green")

espacios_verdes <- st_join(espacios_verdes, barrios_caba)
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
head(espacios_verdes)
## Simple feature collection with 6 features and 36 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -58.45529 ymin: -34.58077 xmax: -58.41527 ymax: -34.54612
## Geodetic CRS:  WGS 84
##                               nombre                              nombre_ev
## 1           Escuela Scalabrini Ortiz ESCUELA Nº 13 D.E. 09 SCALABRINI ORTIZ
## 2           Polideportivo Colegiales               POLIDEPORTIVO COLEGIALES
## 3                               <NA>                             SIN NOMBRE
## 4             Plaza Rafael Hernández                      HERNANDEZ, RAFAEL
## 5 Plaza Pques. Nacionales Argentinos          PARQUES NACIONALES ARGENTINOS
## 6                               <NA>                             SIN NOMBRE
##   clasificac patio_de_j apadrinada
## 1  PLAZOLETA         NO       <NA>
## 2     PARQUE         NO       <NA>
## 3  PLAZOLETA         NO       <NA>
## 4      PLAZA         SI         NO
## 5      PLAZA         NO         NO
## 6  PLAZOLETA         NO       <NA>
##                                                                                                                                                                   observacio
## 1                                                                                               Redigitalización en Agosto de 2017. Unión de sectores y asignación de nombre
## 2 Redigitalización por USIG en Agosto de 2017. Unión de sectores y asignación de nombre. Categoría de parque tomada de registros de Dir. Gral de Esp. Verdes de la Comuna 13
## 3                                                                                                                                                            ESPACIOS VERDES
## 4                                                                                                                                                                       <NA>
## 5                                                                                                                                                                       <NA>
## 6                                                                                                                                                            ESPACIOS VERDES
##        fuente_geo fuente_ins
## 1            USIG       USIG
## 2            USIG       USIG
## 3            USIG       USIG
## 4 ESPACIOS VERDES       E.V.
## 5 ESPACIOS VERDES       E.V.
## 6            USIG       USIG
##                                                                            ubicacion
## 1                       CONDE - MATIENZO, BENJAMIN, TTE. - FREIRE, RAMON, CAP. GRAL.
## 2                       CONDE - MATIENZO, BENJAMIN, TTE. - FREIRE, RAMON, CAP. GRAL.
## 3 GUIRALDES, INTENDENTE - ESTACIONAMIENTO - PARQUE BALNEARIO NORTE - ESTACIONAMIENTO
## 4                                   ECHEVERRIA - VUELTA DE OBLIGADO - MOM, POLICARPO
## 5 ECHEVERRIA - CASTAÑEDA - SUCRE, ANTONIO J. DE, MCAL. - FIGUEROA ALCORTA PRES., AV.
## 6            DEL LIBERTADOR, AV. - SARMIENTO, AV. (FRENTE MONUMENTO A LOS ESPA¤OLES)
##   decreto fecha_decr ordenanza_ fecha_orde boletin_of fecha_bole     BARRIO
## 1    <NA>       <NA>       <NA>       <NA>       <NA>       <NA> COLEGIALES
## 2    <NA>       <NA>       <NA>       <NA>       <NA>       <NA> COLEGIALES
## 3    <NA>       <NA>       <NA>       <NA>       <NA>       <NA>   BELGRANO
## 4   7.918       1975     32.256       1975     15.173       1975   BELGRANO
## 5    <NA>       <NA>     26.838 10/07/1972     14.339 20/07/1972   BELGRANO
## 6    <NA>       <NA>       <NA>       <NA>       <NA>       <NA>    PALERMO
##   COMUNA Fech_padri Vig_padri Alc_conven                          nom_mapa
## 1     13       <NA>      <NA>       <NA>             Esc. Scalabrini Ortiz
## 2     13       <NA>      <NA>       <NA>               Polidep. Colegiales
## 3     13       <NA>      <NA>       <NA>                              <NA>
## 4     13       <NA>      <NA>       <NA>             Pza. Rafael Hernández
## 5     13       <NA>      <NA>       <NA> Pza. Pques. Nacionales Argentinos
## 6     14       <NA>      <NA>       <NA>                              <NA>
##   id_ev_pub    area.x perimeter DGEV_Padri Mant_2017
## 1         2  1658.266         0       <NA>      <NA>
## 2         6  4686.060         0       <NA>      <NA>
## 3         8  3746.965       100       <NA>      <NA>
## 4         9   558.986      9990       <NA>      <NA>
## 5        10 12169.958      1000         SI        SI
## 6        11    28.385         2       <NA>      <NA>
##                                TAREAS     ESTADO SUP_TOTAL Canil Posta_aero
## 1                                <NA>       <NA>         0  <NA>       <NA>
## 2                                <NA>       <NA>         0  <NA>       <NA>
## 3                                <NA>       <NA>         0  <NA>       <NA>
## 4                                <NA>       <NA>         0  <NA>       <NA>
## 5 Parquización - Veredas perimetrales Finalizada     10215  <NA>       <NA>
## 6                                <NA>       <NA>         0  <NA>       <NA>
##     Superficie     barrio comuna perimetro   area.y
## 1 menor a 500k COLEGIALES     13  6374.619  2289774
## 2 menor a 500k COLEGIALES     13  6374.619  2289774
## 3 menor a 500k   BELGRANO     13 20609.775  7999240
## 4 menor a 500k   BELGRANO     13 20609.775  7999240
## 5 menor a 500k   BELGRANO     13 20609.775  7999240
## 6 menor a 500k    PALERMO     14 22126.532 15845871
##                         geometry
## 1 MULTIPOLYGON (((-58.44536 -...
## 2 MULTIPOLYGON (((-58.44481 -...
## 3 MULTIPOLYGON (((-58.43824 -...
## 4 MULTIPOLYGON (((-58.45529 -...
## 5 MULTIPOLYGON (((-58.43714 -...
## 6 MULTIPOLYGON (((-58.41527 -...
espacios_verdes <- espacios_verdes%>%
  group_by(barrio)%>%
  summarise(cantidad=n())
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
## although coordinates are longitude/latitude, st_union assumes that they are planar
head(espacios_verdes)
## Simple feature collection with 6 features and 2 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -58.49194 ymin: -34.66229 xmax: -58.33983 ymax: -34.53445
## Geodetic CRS:  WGS 84
## # A tibble: 6 x 3
##   barrio   cantidad                                                     geometry
##   <fct>       <int>                                           <MULTIPOLYGON [°]>
## 1 AGRONOM~        5 (((-58.49156 -34.59347, -58.4917 -34.59354, -58.49183 -34.5~
## 2 ALMAGRO        11 (((-58.4299 -34.5997, -58.4299 -34.5997, -58.4299 -34.5997,~
## 3 BALVANE~        8 (((-58.41373 -34.60807, -58.41389 -34.60807, -58.4139 -34.6~
## 4 BARRACAS       68 (((-58.41624 -34.65892, -58.4162 -34.65891, -58.41616 -34.6~
## 5 BELGRANO       54 (((-58.46873 -34.56614, -58.46901 -34.56612, -58.46919 -34.~
## 6 BOCA           38 (((-58.36804 -34.64552, -58.36804 -34.64552, -58.36804 -34.~
espacios_verdes <- espacios_verdes%>%
  st_set_geometry(NULL)
head(espacios_verdes)
## # A tibble: 6 x 2
##   barrio    cantidad
##   <fct>        <int>
## 1 AGRONOMIA        5
## 2 ALMAGRO         11
## 3 BALVANERA        8
## 4 BARRACAS        68
## 5 BELGRANO        54
## 6 BOCA            38
barrios_caba <- left_join(barrios_caba, espacios_verdes, by="barrio")
head(barrios_caba)
## Simple feature collection with 6 features and 5 fields
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: -58.50617 ymin: -34.63064 xmax: -58.41192 ymax: -34.57829
## Geodetic CRS:  WGS 84
##             barrio comuna perimetro    area cantidad
## 1        CHACARITA     15  7724.853 3115707       17
## 2         PATERNAL     15  7087.513 2229829       10
## 3     VILLA CRESPO     15  8131.857 3615978       11
## 4 VILLA DEL PARQUE     11  7705.390 3399596       18
## 5          ALMAGRO      5  8537.901 4050752       11
## 6        CABALLITO      6 10990.964 6851029       32
##                              WKT
## 1 POLYGON ((-58.45282 -34.595...
## 2 POLYGON ((-58.46558 -34.596...
## 3 POLYGON ((-58.42375 -34.597...
## 4 POLYGON ((-58.49461 -34.614...
## 5 POLYGON ((-58.41287 -34.614...
## 6 POLYGON ((-58.43061 -34.607...
ggplot()+
  geom_sf(data=barrios_caba, aes(fill=cantidad))+
  labs(title="Cantidad de espacios verdes",
       subtitle="Por Barrio")

Se puede apreciar que los barrios de Palermo y Villa Lugano son los que más espacios verdes tienen. Asimismo, se podría afirmar que los barrios del centro de la ciudad son los que cuentan con menos espacios verdes.