La Ciudad elegida fue Bilbao en España, por ser una ciudad interesante organizativamente, cultural, gastronomicamente y estratégica turisticamente en la región del Cantábrico, adicional a poseer un portal de datos abiertos disponible.
Fuentes de datos: https://www.bilbao.eus/opendata/es/catalogo https://opendata.euskadi.eus/inicio/ http://bilbaodatalab.wikitoki.org/2019/02/07/por-que-no-lo-hemos-visto-hasta-ahora-primer-mapa-de-zonificacion-escolar-en-bilbao/
Antes de hacer el ejercicio, cargamos las librerías necesarias para trabajar con los datos de nuestro interés:
library(tidyverse)
library(sf)
Ahora si, abrimos el shapefile (geojson) encontrado con la información sobre los Distritos/Barrios para la ciudad de Bilbao. El archivo se encuentra en proyecciones EPSG:3042. Vamos a mantener por el momento las mismas ya que el .csv importado posee las mismas proyecciones.
barrios <- st_read('distritos-bilbao.geojson') %>% rename(barrios_bilbao=BAR_DS_O) %>% mutate(barrios_bilbao=str_replace_na(barrios_bilbao, "Deusto"))
## Reading layer `distritos-bilbao' from data source `C:\Users\jabib\Desktop\TP\distritos-bilbao.geojson' using driver `GeoJSON'
## Simple feature collection with 8 features and 10 fields
## geometry type: MULTIPOLYGON
## dimension: XY
## bbox: xmin: 501138.3 ymin: 4784550 xmax: 509717.6 ymax: 4793035
## CRS: 3042
summary(barrios)
## BAR_CL BAR_BARR barrios_bilbao BAR_MUNI BAR_MUNI_D
## Min. :44802000000000 204 :1 Length:8 020 :7 Bilbao:7
## 1st Qu.:44802000000100 301 :1 Class :character NA's:1 NA's :1
## Median :44802000000200 403 :1 Mode :character
## Mean :44802000000200 506 :1
## 3rd Qu.:44802000000300 601 :1
## Max. :44802000000500 (Other):2
## NA's :1 NA's :1
## BAR_PROV BAR_PROV_D Shape_Leng Shape_Area distrito
## 48 :7 Bizkaia:7 Min. : 2206 Min. : 134503 Min. :1.00
## NA's:1 NA's :1 1st Qu.: 2997 1st Qu.: 367710 1st Qu.:2.75
## Median : 4523 Median : 676791 Median :4.50
## Mean : 5626 Mean :1047330 Mean :4.50
## 3rd Qu.: 7001 3rd Qu.: 929442 3rd Qu.:6.25
## Max. :13614 Max. :4162459 Max. :8.00
##
## geometry
## MULTIPOLYGON :8
## epsg:3042 :0
## +proj=utm ...:0
##
##
##
##
plot(barrios)
Cargamos también el Ría de Bilbao en proyecciones EPSG:3042.
ria <- st_read('ria.geojson')
## Reading layer `ria' from data source `C:\Users\jabib\Desktop\TP\ria.geojson' using driver `GeoJSON'
## replacing null geometries with empty geometries
## Simple feature collection with 4 features and 1 field (with 2 geometries empty)
## geometry type: POLYGON
## dimension: XY
## bbox: xmin: 501820.3 ymin: 4788047 xmax: 506458.3 ymax: 4793100
## CRS: 3042
zonescol <- st_read('zonificacion-escolar-bilbao.geojson')
## Reading layer `zonificacion-escolar-bilbao' from data source `C:\Users\jabib\Desktop\TP\zonificacion-escolar-bilbao.geojson' using driver `GeoJSON'
## Simple feature collection with 29 features and 1 field
## geometry type: MULTIPOLYGON
## dimension: XY
## bbox: xmin: 498330.2 ymin: 4783242 xmax: 509717.6 ymax: 4793035
## CRS: 3042
El dataset con registros geo-referenciados elegido es el referido a los “Lugares Turísticos” de la Ciudad.
turistico <- read.csv("LugaresInteresTuristico.csv", sep=";",
stringsAsFactors = FALSE)
summary(turistico)
## NOMBRE_FAMILIA NOMBRE_LUGAR_CAS NOMBRE_LUGAR_EUS COD_CALLE
## Length:266 Length:266 Length:266 Min. : 15
## Class :character Class :character Class :character 1st Qu.: 15
## Mode :character Mode :character Mode :character Median : 820
## Mean :2104
## 3rd Qu.:3397
## Max. :9795
## NOMBRE_CALLE COD_TIPO_VIA NOMBRE_TIPO_VIA BLOQUE
## Length:266 Length:266 Length:266 Mode:logical
## Class :character Class :character Class :character NA's:266
## Mode :character Mode :character Mode :character
##
##
##
## NUMERO BIS COORDENADA_UTM_X COORDENADA_UTM_Y
## Min. : 1.000 Length:266 Min. :503856 Min. :4788591
## 1st Qu.: 1.000 Class :character 1st Qu.:504578 1st Qu.:4789845
## Median : 3.000 Mode :character Median :505686 Median :4790143
## Mean : 5.726 Mean :505514 Mean :4790195
## 3rd Qu.: 4.000 3rd Qu.:506211 3rd Qu.:4790649
## Max. :61.000 Max. :507094 Max. :4791059
## X
## Mode:logical
## NA's:266
##
##
##
##
table(turistico$NOMBRE_FAMILIA)
##
## Arte al aire libre Edificios emblemáticos Museos
## 30 26 1
## Museos Bilbao Música y ópera Nueva arquitectura
## 11 158 16
## OTROS EDIFICIOS Qué ver
## 2 22
Probamos un ggplot combinando los 2 archivos importados.
ggplot() +
geom_sf(data = barrios)+
geom_sf(data = ria , color='blue') +
geom_point(data = turistico, aes(x = COORDENADA_UTM_X, y = COORDENADA_UTM_Y , color = NOMBRE_FAMILIA),size = 2,alpha = .9)+
labs(title = "Mapa puntos turísticos ciudad de Bilbao", fill = "Puntos turísticos", caption = "Fuente: portal de datos abiertos de BILBAO https://www.bilbao.eus/opendata/es/catalogo", y="Latitud", x="Longitud") +
theme_light()
str(turistico)
## 'data.frame': 266 obs. of 13 variables:
## $ NOMBRE_FAMILIA : chr "Edificios emblemáticos" "Edificios emblemáticos" "Edificios emblemáticos" "Edificios emblemáticos" ...
## $ NOMBRE_LUGAR_CAS: chr "LA EQUITATIVA" "PALACIO IBAIGANE" "INSTITUTO UNAMUNO" "EDIFICIO CORREOS" ...
## $ NOMBRE_LUGAR_EUS: chr "LA EQUITATIVA" "IBAIGANE JAUREGIA" "UNAMUNO INSTITUTUA ETA UNIBERTSITATE ESKOLA" "POSTA ERAIKINA" ...
## $ COD_CALLE : int 6090 6090 9340 9340 6090 7770 15 15 15 15 ...
## $ NOMBRE_CALLE : chr "MAZARREDO" "MAZARREDO" "URQUIJO" "URQUIJO" ...
## $ COD_TIPO_VIA : chr "AL" "AL" "AL" "AL" ...
## $ NOMBRE_TIPO_VIA : chr "ALAMEDA" "ALAMEDA" "ALAMEDA" "ALAMEDA" ...
## $ BLOQUE : logi NA NA NA NA NA NA ...
## $ NUMERO : int 7 23 10 19 61 39 2 4 4 2 ...
## $ BIS : chr "" "" "" "" ...
## $ COORDENADA_UTM_X: num 505850 505775 505706 505642 505471 ...
## $ COORDENADA_UTM_Y: num 4790238 4790557 4789953 4789883 4790728 ...
## $ X : logi NA NA NA NA NA NA ...
Transformamos el archivo .csv a sf.
turistico <- turistico %>%
filter(!is.na(COORDENADA_UTM_X), !is.na(COORDENADA_UTM_Y)) %>%
st_as_sf(coords = c("COORDENADA_UTM_X", "COORDENADA_UTM_Y"), crs = 3042)
turistico
## Simple feature collection with 266 features and 11 fields
## geometry type: POINT
## dimension: XY
## bbox: xmin: 503856.3 ymin: 4788591 xmax: 507093.7 ymax: 4791059
## CRS: EPSG:3042
## First 10 features:
## NOMBRE_FAMILIA NOMBRE_LUGAR_CAS
## 1 Edificios emblemáticos LA EQUITATIVA
## 2 Edificios emblemáticos PALACIO IBAIGANE
## 3 Edificios emblemáticos INSTITUTO UNAMUNO
## 4 Edificios emblemáticos EDIFICIO CORREOS
## 5 Nueva arquitectura GRAN HOTEL DOMINE BILBAO
## 6 Nueva arquitectura DEPARTAMENTO VASCO DE SANIDAD
## 7 Museos Bilbao MUSEO GUGGENHEIM BILBAO
## 8 Arte al aire libre DODECLATHOS
## 9 Arte al aire libre TERPSÍCORE
## 10 Arte al aire libre PUPPY
## NOMBRE_LUGAR_EUS COD_CALLE NOMBRE_CALLE
## 1 LA EQUITATIVA 6090 MAZARREDO
## 2 IBAIGANE JAUREGIA 6090 MAZARREDO
## 3 UNAMUNO INSTITUTUA ETA UNIBERTSITATE ESKOLA 9340 URQUIJO
## 4 POSTA ERAIKINA 9340 URQUIJO
## 5 BILBAO DOMINE HOTELA 6090 MAZARREDO
## 6 OSASUN SAILEKO EGOITZA 7770 RECALDE
## 7 GUGGENHEIM BILBAO MUSEOA 15 ABANDOIBARRA
## 8 DODECLATHOS 15 ABANDOIBARRA
## 9 TERPSÍCORE 15 ABANDOIBARRA
## 10 PUPPY 15 ABANDOIBARRA
## COD_TIPO_VIA NOMBRE_TIPO_VIA BLOQUE NUMERO BIS X geometry
## 1 AL ALAMEDA NA 7 NA POINT (505850.1 4790238)
## 2 AL ALAMEDA NA 23 NA POINT (505775 4790557)
## 3 AL ALAMEDA NA 10 NA POINT (505705.8 4789953)
## 4 AL ALAMEDA NA 19 NA POINT (505641.6 4789883)
## 5 AL ALAMEDA NA 61 NA POINT (505471.1 4790728)
## 6 AL ALAMEDA NA 39 NA POINT (505317.5 4789969)
## 7 AV AVENIDA NA 2 NA POINT (505438.5 4790850)
## 8 AV AVENIDA NA 4 NA POINT (504577.8 4790649)
## 9 AV AVENIDA NA 4 NA POINT (504577.8 4790649)
## 10 AV AVENIDA NA 2 NA POINT (505438.5 4790850)
ggplot() +
geom_sf(data = barrios) +
geom_sf(data = ria , color='blue') +
geom_sf(data = turistico, color = "salmon",size = 2, alpha = .3) +
labs(title = "Mapa puntos turísticos ciudad de Bilbao", caption = "Fuente: portal de datos abiertos de BILBAO https://www.bilbao.eus/opendata/es/catalogo", fill="Puntos turísticos", y="Latitud", x="Longitud") +
theme_light()
turistico_con_barrios <- st_join(turistico, barrios)
names(turistico_con_barrios)
## [1] "NOMBRE_FAMILIA" "NOMBRE_LUGAR_CAS" "NOMBRE_LUGAR_EUS" "COD_CALLE"
## [5] "NOMBRE_CALLE" "COD_TIPO_VIA" "NOMBRE_TIPO_VIA" "BLOQUE"
## [9] "NUMERO" "BIS" "X" "BAR_CL"
## [13] "BAR_BARR" "barrios_bilbao" "BAR_MUNI" "BAR_MUNI_D"
## [17] "BAR_PROV" "BAR_PROV_D" "Shape_Leng" "Shape_Area"
## [21] "distrito" "geometry"
turistico_con_barrios %>%
group_by(barrios_bilbao) %>%
summarise(cantidad = n())
## Simple feature collection with 6 features and 2 fields
## geometry type: GEOMETRY
## dimension: XY
## bbox: xmin: 503856.3 ymin: 4788591 xmax: 507093.7 ymax: 4791059
## CRS: EPSG:3042
## # A tibble: 6 x 3
## barrios_bilbao cantidad geometry
## * <chr> <int> <GEOMETRY [m]>
## 1 Abando 61 MULTIPOINT ((504400.2 4790452), (504580.8 47904~
## 2 Bilbao la Vieja 91 MULTIPOINT ((505926.7 4789443), (506036.2 47885~
## 3 Bolueta 1 POINT (506564.5 4789696)
## 4 Deusto 77 MULTIPOINT ((504476.2 4790591), (504577.8 47906~
## 5 Diseminado Basurtu-~ 2 MULTIPOINT ((503856.3 4789991), (504191.8 47902~
## 6 Uribarri 34 MULTIPOINT ((505210.7 4790834), (505438.5 47908~
ggplot() +
geom_sf(data = barrios) +
geom_sf(data = ria , color='blue') +
geom_sf(data = turistico_con_barrios, aes(color = barrios_bilbao),size = 2) +
labs(title = "Mapa puntos turísticos ciudad de Bilbao", caption = "Fuente: portal de datos abiertos de BILBAO https://www.bilbao.eus/opendata/es/catalogo", fill="Puntos turísticos", y="Latitud", x="Longitud") +
theme_light()
turistico_barras <- turistico_con_barrios %>%
group_by(barrios_bilbao, NOMBRE_FAMILIA) %>%
summarise(cantidad = n())
head(turistico_barras)
## Simple feature collection with 6 features and 3 fields
## geometry type: MULTIPOINT
## dimension: XY
## bbox: xmin: 504400.2 ymin: 4789430 xmax: 506109.8 ymax: 4790739
## CRS: EPSG:3042
## # A tibble: 6 x 4
## # Groups: barrios_bilbao [1]
## barrios_bilbao NOMBRE_FAMILIA cantidad geometry
## <chr> <chr> <int> <MULTIPOINT [m]>
## 1 Abando Arte al aire li~ 11 ((504580.8 4790444), (505068.8 47894~
## 2 Abando Edificios emble~ 14 ((504400.2 4790452), (504919.7 47898~
## 3 Abando Museos Bilbao 2 ((505149 4790561), (505266.6 4789430~
## 4 Abando Música y ópera 17 ((505252.2 4789888), (505686.4 47898~
## 5 Abando Nueva arquitect~ 8 ((504828 4790729), (505084.5 4790614~
## 6 Abando Qué ver 9 ((505015 4790361), (505389.3 4790168~
ggplot(turistico_barras) +
geom_bar(aes(x = barrios_bilbao, weight = cantidad, fill=NOMBRE_FAMILIA)) +
coord_flip() +
labs(title = "Hitos turísticos ciudad de Bilbao", caption = "Fuente: portal de datos abiertos de BILBAO https://www.bilbao.eus/opendata/es/catalogo", x="Barrios", y="Cantidad hitos") + scale_fill_viridis_d() +
theme_light()
barrios_bilbao <- turistico_con_barrios %>%
filter(!is.na(barrios_bilbao)) %>%
group_by(barrios_bilbao) %>%
summarise(cantidad=n())
barrios_bilbao <- barrios_bilbao %>%
st_set_geometry(NULL)
head(barrios_bilbao)
## # A tibble: 6 x 2
## barrios_bilbao cantidad
## <chr> <int>
## 1 Abando 61
## 2 Bilbao la Vieja 91
## 3 Bolueta 1
## 4 Deusto 77
## 5 Diseminado Basurtu-Zorrotza 2
## 6 Uribarri 34
barrios <- barrios %>%
left_join(barrios_bilbao, by="barrios_bilbao")
head(barrios)
## Simple feature collection with 6 features and 11 fields
## geometry type: MULTIPOLYGON
## dimension: XY
## bbox: xmin: 502179.5 ymin: 4784550 xmax: 509717.6 ymax: 4792560
## CRS: 3042
## BAR_CL BAR_BARR barrios_bilbao BAR_MUNI BAR_MUNI_D BAR_PROV
## 1 44802000000200 702 Iralabarri 020 Bilbao 48
## 2 44802000000200 301 Otxarkoaga 020 Bilbao 48
## 3 44802000000400 204 Uribarri 020 Bilbao 48
## 4 44802000000100 403 Bolueta 020 Bilbao 48
## 5 44802000000100 506 Bilbao la Vieja 020 Bilbao 48
## 6 44802000000000 601 Abando 020 Bilbao 48
## BAR_PROV_D Shape_Leng Shape_Area distrito cantidad
## 1 Bizkaia 3013.924 382538.0 7 NA
## 2 Bizkaia 4073.511 584765.0 3 NA
## 3 Bizkaia 2944.946 323226.1 2 34
## 4 Bizkaia 7268.457 768816.2 4 1
## 5 Bizkaia 2206.221 134503.2 5 91
## 6 Bizkaia 4972.360 1174614.1 6 61
## geometry
## 1 MULTIPOLYGON (((505282.5 47...
## 2 MULTIPOLYGON (((508364.1 47...
## 3 MULTIPOLYGON (((506268.6 47...
## 4 MULTIPOLYGON (((507642.2 47...
## 5 MULTIPOLYGON (((506363.5 47...
## 6 MULTIPOLYGON (((504818.3 47...
ggplot() +
geom_sf(data = barrios, aes(fill=(cantidad/Shape_Area)*10000)) +
geom_sf(data = ria , color='blue') +
geom_sf_text(data=barrios, aes(label = barrios_bilbao), size=3 , colour = "black")+
labs(title = "Oferta turística por barrio",
subtitle = "Ciudad de Bilbao - España",
fill = "Cantidad",
caption= "Fuente: portal de datos abiertos de BILBAO https://www.bilbao.eus/opendata/es/catalogo",
y="Latitud",
x="Longitud") +
scale_fill_viridis_c() +
theme_light()
Como se puede observar, los principales lugares turísticos que encuentran ubicados en el centro de la ciudad, a en las inmediaciones del Ria de Bilbao, encontrándose en esta área importantes edificios históricos portuarios reciclados en su mayoría en lugares relacionadas con el ámbito cultural.
Con este ultimo Chunk damos por finalizado el TP1.-