R Markdown

##ejercitación con shapefile y geojson .Mapa de Conurbano. Mapa de Cuenca del Reconquista(El mapa que realicé es incompleto, debido a que determinados Municipios no son incluidos en el data set, aunque en el chunk, al filtrar tanto el dataset de partidos_amba y conurbano estan los Municipios requeridos, estaban y con data, pasa lo mismo con geojson ). ##La segunda parte es explorar open street Map, este es un link de donde se puede obtener un mapa y tiene data en forma de FEATURES en el link https://wiki.openstreetmap.org/wiki/Map_Features) , sobre el uso del suelo, hospitales , industria, data muy incompleta

library(osmdata)
## Warning: package 'osmdata' was built under R version 4.0.5
## Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
library(sf)
## Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(tidyverse)
## -- Attaching packages ------------------------------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.2     v purrr   0.3.4
## v tibble  3.0.1     v dplyr   1.0.0
## v tidyr   1.1.0     v stringr 1.4.0
## v readr   1.3.1     v forcats 0.5.0
## -- Conflicts ---------------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(ggmap)
## Warning: package 'ggmap' was built under R version 4.0.5
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.

TAREA

descargar un shp o geojson. al descargar un shapefile, hacerlo en conjunto con otros elementos descomprimidos. Leer con st_read el que diga shp

partidos_amba <- st_read("partidos_amba.shp")
## Reading layer `partidos_amba' from data source `C:\Users\siena\Documents\2021 R\Datos II\DEBER CLASE 2 openstreet ggmap\partidos_amba.shp' using driver `ESRI Shapefile'
## Simple feature collection with 48 features and 3 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -59.3392 ymin: -35.23893 xmax: -57.70946 ymax: -34.23007
## geographic CRS: WGS 84
head(partidos_amba)
## Simple feature collection with 6 features and 3 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -59.05579 ymin: -34.91331 xmax: -58.27953 ymax: -34.26732
## geographic CRS: WGS 84
##       nombre provincia area_km2                       geometry
## 1 Avellaneda       GBA    57.25 MULTIPOLYGON (((-58.33444 -...
## 2      Tigre       GBA   381.99 MULTIPOLYGON (((-58.5167 -3...
## 3      Pilar       GBA   382.95 MULTIPOLYGON (((-58.90312 -...
## 4     Moreno       GBA   186.36 MULTIPOLYGON (((-58.82401 -...
## 5      Merlo       GBA   173.97 MULTIPOLYGON (((-58.72917 -...
## 6 La Matanza       GBA   328.26 MULTIPOLYGON (((-58.52885 -...
summary(partidos_amba)
##     nombre           provincia            area_km2               geometry 
##  Length:48          Length:48          Min.   :  6.30   MULTIPOLYGON :48  
##  Class :character   Class :character   1st Qu.: 17.72   epsg:4326    : 0  
##  Mode  :character   Mode  :character   Median : 55.91   +proj=long...: 0  
##                                        Mean   :140.59                     
##                                        3rd Qu.:177.07                     
##                                        Max.   :889.49
conurbano <- filter(partidos_amba, provincia == "GBA")
head(conurbano)
## Simple feature collection with 6 features and 3 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -59.05579 ymin: -34.91331 xmax: -58.27953 ymax: -34.26732
## geographic CRS: WGS 84
##       nombre provincia area_km2                       geometry
## 1 Avellaneda       GBA    57.25 MULTIPOLYGON (((-58.33444 -...
## 2      Tigre       GBA   381.99 MULTIPOLYGON (((-58.5167 -3...
## 3      Pilar       GBA   382.95 MULTIPOLYGON (((-58.90312 -...
## 4     Moreno       GBA   186.36 MULTIPOLYGON (((-58.82401 -...
## 5      Merlo       GBA   173.97 MULTIPOLYGON (((-58.72917 -...
## 6 La Matanza       GBA   328.26 MULTIPOLYGON (((-58.52885 -...

## Mapa del Conurbano shp

ggplot()+
  geom_sf(data = conurbano)

Cuenca_baja_Reconquista <- filter (conurbano,nombre ==" Vicente López "|nombre=="San Isidro"|nombre=="San Fernando"|nombre =="Tigre") 

##no entiendo el error,la copia de los nombres esta ok pero no incluye en el dataset a Vicente Lopez "

##la idea con estos data set era pintar los municipios por la cuenca

Mapa con los Municipios de Cuenca Baja del reconquista shp, sin Vicente Lopez ??

ggplot()+

geom_sf(data=conurbano)+
  geom_sf(data = Cuenca_baja_Reconquista,aes(fill= "red") )+
  labs(title =" Municipios de Cuenca Baja",
       subtitle = "Tigre, San Fernando,San isidro, Vicente Lopez(no incluido)",
       fill= "Municipios Cuenca Baja del Reconquista ")

# Este datset ignora a Vicente lopez, esta en elchunk, en vez de 4 obs aparecen 3 y elimina a Vicentelopez.

Vicente_lopez <- filter(conurbano, nombre =="Vicente López ")

con filter no tira error, pero da cero “0” observaciones filtre tanto con el data set de partidos_amba t el data set conurbano. Pero en estos dataset los datos de Vicente lopez estan cargados

table(conurbano$nombre)
## 
##     Almirante Brown          Avellaneda         Berazategui             Berisso 
##                   1                   1                   1                   1 
##            Ensenada             Escobar  Esteban Echeverría              Ezeiza 
##                   1                   1                   1                   1 
##    Florencio Varela   General Rodríguez  General San Martín          Hurlingham 
##                   1                   1                   1                   1 
##           Ituzaingó         José C. Paz          La Matanza            La Plata 
##                   1                   1                   1                   1 
##               Lanús     Lomas de Zamora               Luján Malvinas Argentinas 
##                   1                   1                   1                   1 
##               Merlo              Moreno               Morón               Pilar 
##                   1                   1                   1                   1 
##    Presidente Perón             Quilmes        San Fernando          San Isidro 
##                   1                   1                   1                   1 
##          San Miguel         San Vicente               Tigre     Tres de Febrero 
##                   1                   1                   1                   1 
##       Vicente López 
##                   1

haciendo table esta Vicente Lopez

No puedo hacer un data set con 10 Municipios de la Cuenca Media del Reconquista , solo reconoce 8 entonces no incluyo ni General San Martin y Jose Cpaz

otra forma de obtener dataset sin General San Martín ni jose C paz, que fueron excluidos, entonces ggplot realiza el mapa cuando estaban los municipios ignorado daba error

cuenca_media_reconquista_b <- filter(conurbano, nombre=="Hurlingham"|nombre=="San Miguel"|nombre=="Ituzaingó" | nombre =="Tres de Febrero"|nombre=="Malvinas Argentinas"|nombre=="Moreno"|nombre=="Merlo"|nombre=="Morón")

Mapa de los Municipios de la cuenca Media shp. excluye San Martín ni José C Paz

ggplot()+

geom_sf(data=conurbano)+
  geom_sf(data = cuenca_media_reconquista_b,aes(fill= "red") )+
  labs(title =" Municipios de Cuenca Media sin San Martin ni Jose C Paz",
       subtitle = "Cuenca media",
       fill= "Municipios Cuenca media ")

## Exploro con geojson

municipios_amba <-st_read("partidos_amba.geojson")
## Reading layer `partidos_amba' from data source `C:\Users\siena\Documents\2021 R\Datos II\DEBER CLASE 2 openstreet ggmap\partidos_amba.geojson' using driver `GeoJSON'
## Simple feature collection with 48 features and 3 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -59.3392 ymin: -35.23893 xmax: -57.70946 ymax: -34.23007
## geographic CRS: WGS 84
municipios_conurbano <- filter(municipios_amba,provincia =="GBA")
Municipios_Cuenca_Reconquista <- filter(municipios_conurbano,nombre ==" Vicente López "|nombre=="San Isidro"|nombre=="San Fernando"|nombre =="Tigre"|nombre=="Hurlingham"|nombre=="San Miguel"|nombre=="Ituzaingó" | nombre =="Tres de Febrero"|nombre=="Malvinas Argentinas"|nombre=="Moreno"|nombre=="Merlo"|nombre=="Morón"|nombre=="Lujan" )
head(Municipios_Cuenca_Reconquista)
## Simple feature collection with 6 features and 3 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: -58.89094 ymin: -34.77968 xmax: -58.4531 ymax: -34.26732
## geographic CRS: WGS 84
##         nombre provincia area_km2                       geometry
## 1        Tigre       GBA   381.99 MULTIPOLYGON (((-58.5167 -3...
## 2       Moreno       GBA   186.36 MULTIPOLYGON (((-58.82401 -...
## 3        Merlo       GBA   173.97 MULTIPOLYGON (((-58.72917 -...
## 4 San Fernando       GBA    24.22 MULTIPOLYGON (((-58.51786 -...
## 5   San Miguel       GBA    82.12 MULTIPOLYGON (((-58.7211 -3...
## 6   San Isidro       GBA    51.99 MULTIPOLYGON (((-58.50077 -...
ggplot()+
  geom_sf(data= municipios_conurbano)+
  geom_sf(data = Municipios_Cuenca_Reconquista,aes(fill="red"))+
  labs(title = "Municipios_Cuenca_Reconquista",
       subtitle = "no estan en rojo Vicente lopez, San Martin, Jose C Paz",
       fill= "Municipios Cuenca Reconquista",
       caption = "dataset propio incompleto")

Nuevamente con geojson Vicente lopez, San Martin y Jose C Paz, no son incluidos en el dataset

#1. Descargar de OpenStreetMap la grilla de calles para la Ciudad elegida en el ejercicio 1 y mapearla por uno de sus atributos (velocidad mínima, velocidad máxima, cantidad de carriles, etc).

Explorando TIGRE

Tigre <- filter (conurbano, nombre =="Tigre")
ggplot()+
  geom_sf(data= conurbano)+
  geom_sf(data = Tigre,aes(fill="red"))+
  labs(tittle = "Conurbano bonaerense",
       subtitle= " 33 Municipios del conurbano bonaerense   ",
       fill= "municipio de Tigre")

ggplot()+
  geom_sf(data = Tigre, aes(fill= "red"))+
  labs(title = "municipio de Tigre ")

Explorando la data existente en OPEN STREET . hacer un mapa con ggmap con DATA de OPEN STREET

bbox_tigre <- getbb("Tigre, Buenos Aires, Argentina")
bbox_tigre
##         min       max
## x -58.59746 -58.55877
## y -34.44848 -34.40806
mapa_tigre <- get_stamenmap(bbox = bbox_tigre,
                          zoom=13)
## Source : http://tile.stamen.com/terrain/13/2762/4930.png
## Source : http://tile.stamen.com/terrain/13/2763/4930.png
## Source : http://tile.stamen.com/terrain/13/2762/4931.png
## Source : http://tile.stamen.com/terrain/13/2763/4931.png

Mapa de Tigre con openstreet

ggmap(mapa_tigre)+
  labs(title = "Tigre",
       subtitle = "Parte Continental ",
       caption = "openstreet 2021 ")

tigre_polygon <- getbb("Tigre, Buenos Aires, Argentina", format_out = "sf_polygon")
ggmap(mapa_tigre)+
  geom_sf(data=tigre_polygon, fill=NA, size=1, color="firebrick3", inherit.aes = FALSE)+
  labs(title="Limites del Municipio deTigre",
       caption="Fuente: Open Street Map")+
  theme_void()
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

2.Descargar de OpenStreetMap una (o más) capas de datos de tipo puntos o polígonos. (Ver catálogo de categorías en https://wiki.openstreetmap.org/wiki/Map_Features)

2.a. Proyectar los datos descargados en un mapa y comentar los resultados: ¿Cómo se distribuyen en la Ciudad ?

landuse_tigre_i <- opq(bbox_tigre)%>%
add_osm_feature(key = "landuse",value = "industrial")
landuse_tigre_i <-osmdata_sf(landuse_tigre_i)
landuse_tigre_i
## Object of class 'osmdata' with:
##                  $bbox : -34.4484782,-58.5974574,-34.4080633,-58.5587661
##         $overpass_call : The call submitted to the overpass API
##                  $meta : metadata including timestamp and version numbers
##            $osm_points : 'sf' Simple Features Collection with 149 points
##             $osm_lines : 'sf' Simple Features Collection with 4 linestrings
##          $osm_polygons : 'sf' Simple Features Collection with 12 polygons
##        $osm_multilines : NULL
##     $osm_multipolygons : 'sf' Simple Features Collection with 1 multipolygons
landuse_tigre_i <- landuse_tigre_i$osm_points
landuse_tigre_i <- st_intersection(landuse_tigre_i, tigre_polygon)
## although coordinates are longitude/latitude, st_intersection assumes that they are planar
## Warning: attribute variables are assumed to be spatially constant throughout all
## geometries

Mapa de tigre con Industrias segón open steet

ggmap(mapa_tigre)+
  geom_sf(data=landuse_tigre_i, aes(color= "red"), inherit.aes = FALSE)+
  labs(title="TIGRE",
       subtitle="LOCALIZACION DE INDUSTRIAS",
       color="Industrias",
       caption="Fuente: Open Street Map")+
  theme_void()
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

# Exploro el uso del suelo destinado a disposicion final de RSU

rsu_tigre <- opq(bbox_tigre)%>%
add_osm_feature(key = "landuse",value = "waste")
rsu_tigre <-osmdata_sf(rsu_tigre)
rsu_tigre
## Object of class 'osmdata' with:
##                  $bbox : -34.4484782,-58.5974574,-34.4080633,-58.5587661
##         $overpass_call : The call submitted to the overpass API
##                  $meta : metadata including timestamp and version numbers
##            $osm_points : 'sf' Simple Features Collection with 0 points
##             $osm_lines : NULL
##          $osm_polygons : 'sf' Simple Features Collection with 0 polygons
##        $osm_multilines : NULL
##     $osm_multipolygons : NULL

no se puede mapear porque la data es NULL, ni points ni poligonos tienen data

Hospitales en Tigre

hospitales_tigre<- opq(bbox_tigre)%>%
add_osm_feature(key = "amenity",value = "hospital")
hospitales_tigre <- osmdata_sf(hospitales_tigre)
hospitales_tigre
## Object of class 'osmdata' with:
##                  $bbox : -34.4484782,-58.5974574,-34.4080633,-58.5587661
##         $overpass_call : The call submitted to the overpass API
##                  $meta : metadata including timestamp and version numbers
##            $osm_points : 'sf' Simple Features Collection with 23 points
##             $osm_lines : NULL
##          $osm_polygons : 'sf' Simple Features Collection with 4 polygons
##        $osm_multilines : NULL
##     $osm_multipolygons : NULL
hospitales_tigre <- hospitales_tigre$osm_points
hospitales_tigre <-st_intersection(hospitales_tigre,tigre_polygon)
## although coordinates are longitude/latitude, st_intersection assumes that they are planar
## Warning: attribute variables are assumed to be spatially constant throughout all
## geometries

mapa con localizacion de Centros de salud en Tigre

ggmap(mapa_tigre)+
geom_sf(data= hospitales_tigre, aes(color= "red"), inherit.aes = FALSE)+
  labs(title="TIGRE",
       subtitle="LOCALIZACION DE centros de Salud ",
       color=" hospitales ",
       caption="Fuente: Open Street Map")+
  theme_void()
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

hospitales_tigre<- opq(bbox_tigre)%>%
add_osm_feature(key = "amenity",value = "hospital")
hospitales_tigre <- osmdata_sf(hospitales_tigre)
hospitales_tigre
## Object of class 'osmdata' with:
##                  $bbox : -34.4484782,-58.5974574,-34.4080633,-58.5587661
##         $overpass_call : The call submitted to the overpass API
##                  $meta : metadata including timestamp and version numbers
##            $osm_points : 'sf' Simple Features Collection with 23 points
##             $osm_lines : NULL
##          $osm_polygons : 'sf' Simple Features Collection with 4 polygons
##        $osm_multilines : NULL
##     $osm_multipolygons : NULL
hospitales_tigre <- hospitales_tigre$osm_polygons
hospitales_tigre <- st_intersection(hospitales_tigre,tigre_polygon)
## although coordinates are longitude/latitude, st_intersection assumes that they are planar
## Warning: attribute variables are assumed to be spatially constant throughout all
## geometries

Mapa con Hospitales de Tigre

ggmap(mapa_tigre)+
  geom_sf( data = hospitales_tigre,aes(fill="red"), inherit.aes = FALSE)+
  labs(title ="hospitales en tigre",
       fill= "hospital",
       caption = "openstreet map 2021 ") +
  theme_gray()
## Coordinate system already present. Adding new coordinate system, which will replace the existing one.

OPen Street Map no tiene muy desarrollada la data. La disposicion final ocupa territorio de tigre y no lo inclue entre sus “features” de landuse

##2. b. Hacer un conteo de los ítems de la capa descargada por barrio, mapearlo y compararlo con el conteo de los ítems descargados en el ejercicio anterior: ¿La distribución es similar o hay diferencias? ¿A qué se puede deber?

##hay muchas diferencias con la ciudad de Buenos Aires, en ciudad autonoma de Bs As hay abundacia de data Publica. ##En el caso de TIGRE open sreet map da poca infromación, porque no hay data en el conurbano bonaerense .. si hay poca DATA PÚBLICA , habrá menos data informada por los ciudadanos

##FORMATO DE ENTREGA El ejercicio se debe realizar en formato RMarkdown pero en este curso no hará falta que envíen el HTML resultante, ya que alcanza con el link de rpubs tras haberlo publicado desde RStudio (instructivo adjunto en la tarea 1)