TRABAJO PRACTICO FINAL _ INSTRUMENTOS DE ANALISIS TERRITORIAL_ MEU

En el presente trabajo pretendemos analizar la relación que existe entre el desarrollo de las distintas actividades economicas ubicadas en planta baja y la localizacion de los alojamientos turisticos en la ciudad de Barcelona.

Para ello seleccionamos diversos datasets de la pagina oficial del “Servicios de datos abiertos del Ayuntamiento de Barcelona”.

De estos utilizaremos:

###- Censo de actividades economicas en planta baja 2019 ###- Alojamientos de la ciudad de Barcelona ###- Pensiones de la ciudad de Barcelona ###- Hoteles de la ciudad de Barcelona

1- Comenzamos cargando las librerias que utilizaremos a lo largo del trabajo

library(tidyverse)  
## -- Attaching packages ----------------------------------------------------------------------------------------------------------------- tidyverse 1.3.0 --
## v ggplot2 3.3.0     v purrr   0.3.4
## v tibble  3.0.1     v dplyr   0.8.5
## v tidyr   1.0.2     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(sf) 
## Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(leaflet)
library(wrapar)
library(osmdata)
## Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
library(tmap)
library(areal)

2- Caragamos y observamos los datasets seleccionados, relacionados a los alojamientos turísticos.

Alojamientos:

Alojamientos <- read.csv("01_Alojamientos.csv")
head(Alojamientos)
##   CODI_EQUIPAMENT                               EQUIPAMENT SECCIO TIPUS_VIA
## 1       146175914       Residència Universitària Lesseps      #        Pl
## 2       146175914       Residència Universitària Lesseps      #        Pl
## 3       146175914       Residència Universitària Lesseps      #        Pl
## 4       146180329 Residència Universitària La Ciutadella      #        Pg
## 5       146180329 Residència Universitària La Ciutadella      #        Pg
## 6       146180329 Residència Universitària La Ciutadella      #        Pg
##   NOM_CARRER NUM_CARRER_1 NUM_CARRER_2 CODI_BARRI
## 1    Lesseps           12           12         31
## 2    Lesseps           12           12         31
## 3    Lesseps           12           12         31
## 4    Pujades           33           37         66
## 5    Pujades           33           37         66
## 6    Pujades           33           37         66
##                           NUM_BARRI CODI_DISTRICTE NOM_DISTRICTE CODI_POSTAL
## 1                la Vila de Gràcia              6       Gràcia        8023
## 2                la Vila de Gràcia              6       Gràcia        8023
## 3                la Vila de Gràcia              6       Gràcia        8023
## 4 el Parc i la Llacuna del Poblenou             10   Sant Martí        8018
## 5 el Parc i la Llacuna del Poblenou             10   Sant Martí        8018
## 6 el Parc i la Llacuna del Poblenou             10   Sant Martí        8018
##   CODI_POBLACIO  POBLACIO  LATITUD LONGITUD X_ETRS89 Y_ETRS89   X_ED50  Y_ED50
## 1            19 BARCELONA 41.40717 2.151154 429051.5  4584306 429143.5 4584507
## 2            19 BARCELONA 41.40717 2.151154 429051.5  4584306 429143.5 4584507
## 3            19 BARCELONA 41.40717 2.151154 429051.5  4584306 429143.5 4584507
## 4            19 BARCELONA 41.39156 2.186115 431957.4  4582545 432049.4 4582746
## 5            19 BARCELONA 41.39156 2.186115 431957.4  4582545 432049.4 4582746
## 6            19 BARCELONA 41.39156 2.186115 431957.4  4582545 432049.4 4582746
##   TELEFON_NUM TELEFON_TIPUS TELEFON_INFO_COM HORARI_PERIODE_INICI
## 1   932183250           Fax                                      
## 2   902444447      Reserves                                      
## 3   932384802          Tel.                                      
## 4   932183250           Fax                                      
## 5   932384802          Tel.                                      
## 6   902444447      Reserves                                      
##   HORARI_PERIODE_FI HORARI_DIES HORARI_HORES_INICI HORARI_HORES_FI
## 1                            NA                                   
## 2                            NA                                   
## 3                            NA                                   
## 4                            NA                                   
## 5                            NA                                   
## 6                            NA                                   
##   HORARI_OBSERVACIONS X3ER_NIVELL                X2N_NIVELL X1ER_NIVELL  X
## 1                  NA             Residències d'estudiants Allotjament NA
## 2                  NA             Residències d'estudiants Allotjament NA
## 3                  NA             Residències d'estudiants Allotjament NA
## 4                  NA             Residències d'estudiants Allotjament NA
## 5                  NA             Residències d'estudiants Allotjament NA
## 6                  NA             Residències d'estudiants Allotjament NA

Utilizamos el comando summary para detectar si existen alojamientos turísticos en este dataset

summary(Alojamientos)
##  CODI_EQUIPAMENT    
##  Min.   :1.462e+08  
##  1st Qu.:9.892e+10  
##  Median :9.940e+10  
##  Mean   :9.482e+10  
##  3rd Qu.:9.940e+10  
##  Max.   :9.940e+10  
##                     
##                                                        EQUIPAMENT 
##  Pis Modernista Aribau                                      : 16  
##  Casa Marsans - Alberg Mare de Déu de Montserrat - AJ000084: 12  
##  Residència d'Estudiants  Barcelona Diagonal - AJ000658    :  8  
##  Residència Universitària Internacional Ã\200gora BCN        :  8  
##  Residència Universitària Sants - AJ000640                :  8  
##  Barcelona Residencias                                      :  6  
##  (Other)                                                    :522  
##                     SECCIO      TIPUS_VIA                   NOM_CARRER 
##  #                     :558   C      :434   Aribau               : 18  
##  Residència Estudiants:  3   Pg     : 48   Bruc                 : 18  
##  Residència Sardenya  :  3   Av     : 24   Gràcia              : 16  
##  Banys                 :  2   Rda    : 23   València            : 16  
##  Biblioteca            :  2   Ptge   : 14   Sant Pere            : 15  
##  Cambres               :  2   G.V.   : 13   Mare de Déu del Coll: 14  
##  (Other)               : 10   (Other): 24   (Other)              :483  
##   NUM_CARRER_1    NUM_CARRER_2     CODI_BARRI   
##  Min.   :  1.0   Min.   :  1.0   Min.   : 1.00  
##  1st Qu.: 21.0   1st Qu.: 21.0   1st Qu.: 7.00  
##  Median : 48.5   Median : 51.0   Median :10.00  
##  Mean   :107.1   Mean   :107.7   Mean   :16.89  
##  3rd Qu.:116.0   3rd Qu.:116.0   3rd Qu.:25.00  
##  Max.   :716.0   Max.   :716.0   Max.   :68.00  
##                                                 
##                            NUM_BARRI   CODI_DISTRICTE  
##  la Dreta de Eixample           :144   Min.   : 1.000  
##  l'Antiga Esquerra de l'Eixample: 48   1st Qu.: 2.000  
##  la Vila de Gràcia             : 37   Median : 2.000  
##  Sants                          : 30   Mean   : 3.472  
##  el Poble-sec                   : 27   3rd Qu.: 5.000  
##  Sant Gervasi - Galvany         : 26   Max.   :10.000  
##  (Other)                        :268                   
##               NOM_DISTRICTE  CODI_POSTAL   CODI_POBLACIO      POBLACIO  
##  Eixample            :240   Min.   :8001   Min.   :19    BARCELONA:580  
##  Sarrià-Sant Gervasi: 84   1st Qu.:8007   1st Qu.:19                   
##  Sants-Montjuïc     : 65   Median :8012   Median :19                   
##  Ciutat Vella        : 61   Mean   :8015   Mean   :19                   
##  Gràcia             : 55   3rd Qu.:8023   3rd Qu.:19                   
##  Les Corts           : 26   Max.   :8037   Max.   :19                   
##  (Other)             : 49                                               
##     LATITUD         LONGITUD        X_ETRS89         Y_ETRS89      
##  Min.   :41.37   Min.   :2.102   Min.   :424945   Min.   :4579869  
##  1st Qu.:41.38   1st Qu.:2.147   1st Qu.:428704   1st Qu.:4581781  
##  Median :41.39   Median :2.161   Median :429907   Median :4582643  
##  Mean   :41.39   Mean   :2.158   Mean   :429636   Mean   :4582786  
##  3rd Qu.:41.40   3rd Qu.:2.172   3rd Qu.:430751   3rd Qu.:4583471  
##  Max.   :41.44   Max.   :2.206   Max.   :433617   Max.   :4587884  
##                                                                    
##      X_ED50           Y_ED50             TELEFON_NUM 
##  Min.   :425037   Min.   :4580070   650 941 910: 16  
##  1st Qu.:428796   1st Qu.:4581982   902444447  :  6  
##  Median :429999   Median :4582844   625577453  :  4  
##  Mean   :429728   Mean   :4582987   630321284  :  4  
##  3rd Qu.:430843   3rd Qu.:4583672   635669021  :  4  
##  Max.   :433709   Max.   :4588085   653699234  :  4  
##                                     (Other)    :542  
##                 TELEFON_TIPUS         TELEFON_INFO_COM HORARI_PERIODE_INICI
##  Centraleta            :  7                   :566          :565           
##  Fax                   : 78   allotjament     :  1     01/01: 15           
##  Informació           :  4   Check-in        :  1                         
##  Informació i reserves:  2   Col.legi SIL    :  1                         
##  Reserves              :  5   i reserves      :  4                         
##  Tel.                  :484   Recepció       :  6                         
##                               religioses grans:  1                         
##  HORARI_PERIODE_FI  HORARI_DIES      HORARI_HORES_INICI HORARI_HORES_FI
##       :565         Min.   :      0           :565               :565   
##  31/12: 15         1st Qu.:1111111   08:00:00:  6       15:00:00:  6   
##                    Median :1111111   09:00:00:  3       20:00:00:  3   
##                    Mean   : 888889   16:00:00:  6       23:00:00:  6   
##                    3rd Qu.:1111111                                     
##                    Max.   :1111111                                     
##                    NA's   :565                                         
##  HORARI_OBSERVACIONS                    X3ER_NIVELL 
##  Mode:logical                                 :369  
##  NA's:580            Albergs juvenils         :173  
##                      Apartaments              : 26  
##                      Col.legis majors         :  2  
##                      Residències d'estudiants: 10  
##                                                     
##                                                     
##                      X2N_NIVELL       X1ER_NIVELL     X          
##  Albergs juvenils         :173   Allotjament:580   Mode:logical  
##  Altres allotjaments      :211                     NA's:580      
##  Apartaments              : 46                                   
##  Col.legis majors         : 25                                   
##  Residències d'estudiants:125                                   
##                                                                  
## 

Observando el dataset, verificamos que existen alojamientos que no serían exclusivamente turísticos, por lo que decidimos trabajar solamente con lo alojamientos nombrados en la columna “X2N_NIVELL” como: -Albergs juvenils. -Altres allotjaments. -Apartaments.

ALOJAMIENTOS <- filter(Alojamientos, X2N_NIVELL %in% c("Albergs juvenils","Altres allotjaments" , "Apartaments"))
head(ALOJAMIENTOS)
##   CODI_EQUIPAMENT                                EQUIPAMENT SECCIO TIPUS_VIA
## 1     75990024905 Apartament Turístic Mur-Mar - ATB-000042      #         C
## 2     75990024905 Apartament Turístic Mur-Mar - ATB-000042      #         C
## 3     75990024905 Apartament Turístic Mur-Mar - ATB-000042      #         C
## 4     75990024905 Apartament Turístic Mur-Mar - ATB-000042      #         C
## 5     75990026619            Aparthotel Bertran - HB-003804      #         C
## 6     75990028628  Apartament Turístic Silver - ATB-000005      #         C
##                NOM_CARRER NUM_CARRER_1 NUM_CARRER_2 CODI_BARRI
## 1                  Rambla           34           34          2
## 2                  Rambla           34           34          2
## 3                  Rambla           34           34          2
## 4                  Rambla           34           34          2
## 5                 Bertran          150          150         27
## 6 Bretón de los Herreros           26           26         31
##               NUM_BARRI CODI_DISTRICTE        NOM_DISTRICTE CODI_POSTAL
## 1       el Barri Gòtic              1         Ciutat Vella        8002
## 2       el Barri Gòtic              1         Ciutat Vella        8002
## 3       el Barri Gòtic              1         Ciutat Vella        8002
## 4       el Barri Gòtic              1         Ciutat Vella        8002
## 5 el Putxet i el Farró              5 Sarrià-Sant Gervasi        8023
## 6    la Vila de Gràcia              6              Gràcia        8012
##   CODI_POBLACIO  POBLACIO  LATITUD LONGITUD X_ETRS89 Y_ETRS89   X_ED50  Y_ED50
## 1            19 BARCELONA 41.37889 2.175867 431087.3  4581147 431179.3 4581348
## 2            19 BARCELONA 41.37889 2.175867 431087.3  4581147 431179.3 4581348
## 3            19 BARCELONA 41.37889 2.175867 431087.3  4581147 431179.3 4581348
## 4            19 BARCELONA 41.37889 2.175867 431087.3  4581147 431179.3 4581348
## 5            19 BARCELONA 41.41041 2.139752 428102.1  4584675 428194.0 4584876
## 6            19 BARCELONA 41.40211 2.151199 429049.9  4583745 429141.8 4583946
##   TELEFON_NUM TELEFON_TIPUS TELEFON_INFO_COM HORARI_PERIODE_INICI
## 1   934125039           Fax                                      
## 2   933182612          Tel.                                      
## 3   933182612          Tel.                                      
## 4   934125039           Fax                                      
## 5   932127550    Centraleta                                      
## 6   934161447           Fax                                      
##   HORARI_PERIODE_FI HORARI_DIES HORARI_HORES_INICI HORARI_HORES_FI
## 1                            NA                                   
## 2                            NA                                   
## 3                            NA                                   
## 4                            NA                                   
## 5                            NA                                   
## 6                            NA                                   
##   HORARI_OBSERVACIONS X3ER_NIVELL          X2N_NIVELL X1ER_NIVELL  X
## 1                  NA Apartaments Altres allotjaments Allotjament NA
## 2                  NA Apartaments Altres allotjaments Allotjament NA
## 3                  NA                     Apartaments Allotjament NA
## 4                  NA                     Apartaments Allotjament NA
## 5                  NA                     Apartaments Allotjament NA
## 6                  NA Apartaments Altres allotjaments Allotjament NA
summary(ALOJAMIENTOS)
##  CODI_EQUIPAMENT    
##  Min.   :7.599e+10  
##  1st Qu.:9.940e+10  
##  Median :9.940e+10  
##  Mean   :9.761e+10  
##  3rd Qu.:9.940e+10  
##  Max.   :9.940e+10  
##                     
##                                                        EQUIPAMENT 
##  Pis Modernista Aribau                                      : 16  
##  Casa Marsans - Alberg Mare de Déu de Montserrat - AJ000084: 12  
##  Residència d'Estudiants  Barcelona Diagonal - AJ000658    :  6  
##  Residència Universitària Sants - AJ000640                :  6  
##  After Hostel - AJ000543                                    :  4  
##  Alberg  Don Moustache! - AJ000540                          :  4  
##  (Other)                                                    :382  
##         SECCIO      TIPUS_VIA                   NOM_CARRER   NUM_CARRER_1   
##  #         :416   C      :331   Aribau               : 16   Min.   :  2.00  
##  Banys     :  2   Pg     : 33   Bruc                 : 16   1st Qu.: 24.25  
##  Biblioteca:  2   Rda    : 22   València            : 16   Median : 51.00  
##  Cambres   :  2   Av     : 11   Mare de Déu del Coll: 14   Mean   :103.16  
##  Cuina     :  2   G.V.   : 10   Sant Pere            : 14   3rd Qu.: 98.00  
##  Hall      :  2   Via    : 10   Augusta              : 10   Max.   :716.00  
##  (Other)   :  4   (Other): 13   (Other)              :344                   
##   NUM_CARRER_2      CODI_BARRI                           NUM_BARRI  
##  Min.   :  2.00   Min.   : 1   la Dreta de Eixample           :122  
##  1st Qu.: 24.25   1st Qu.: 7   l'Antiga Esquerra de l'Eixample: 41  
##  Median : 51.00   Median : 8   Sants                          : 27  
##  Mean   :103.81   Mean   :16   la Vila de Gràcia             : 25  
##  3rd Qu.: 98.00   3rd Qu.:23   el Poble-sec                   : 24  
##  Max.   :716.00   Max.   :68   el Barri Gòtic                : 19  
##                                (Other)                        :172  
##  CODI_DISTRICTE                NOM_DISTRICTE  CODI_POSTAL   CODI_POBLACIO
##  Min.   : 1.000   Eixample            :200   Min.   :8001   Min.   :19   
##  1st Qu.: 2.000   Sants-Montjuïc     : 59   1st Qu.:8007   1st Qu.:19   
##  Median : 2.000   Ciutat Vella        : 44   Median :8011   Median :19   
##  Mean   : 3.314   Gràcia             : 43   Mean   :8015   Mean   :19   
##  3rd Qu.: 5.000   Sarrià-Sant Gervasi: 33   3rd Qu.:8023   3rd Qu.:19   
##  Max.   :10.000   Sant Martí         : 17   Max.   :8037   Max.   :19   
##                   (Other)             : 34                               
##       POBLACIO      LATITUD         LONGITUD        X_ETRS89     
##  BARCELONA:430   Min.   :41.37   Min.   :2.102   Min.   :424945  
##                  1st Qu.:41.38   1st Qu.:2.151   1st Qu.:429058  
##                  Median :41.39   Median :2.165   Median :430139  
##                  Mean   :41.39   Mean   :2.161   Mean   :429874  
##                  3rd Qu.:41.40   3rd Qu.:2.173   3rd Qu.:430883  
##                  Max.   :41.44   Max.   :2.206   Max.   :433617  
##                                                                  
##     Y_ETRS89           X_ED50           Y_ED50             TELEFON_NUM 
##  Min.   :4579869   Min.   :425037   Min.   :4580070   650 941 910: 16  
##  1st Qu.:4581455   1st Qu.:429150   1st Qu.:4581656   625577453  :  4  
##  Median :4582550   Median :430231   Median :4582751   630321284  :  4  
##  Mean   :4582677   Mean   :429965   Mean   :4582878   635669021  :  4  
##  3rd Qu.:4583266   3rd Qu.:430975   3rd Qu.:4583467   932100798  :  4  
##  Max.   :4587884   Max.   :433709   Max.   :4588085   932105151  :  4  
##                                                       (Other)    :394  
##                 TELEFON_TIPUS         TELEFON_INFO_COM HORARI_PERIODE_INICI
##  Centraleta            :  7                   :419          :415           
##  Fax                   : 28   allotjament     :  0     01/01: 15           
##  Informació           :  4   Check-in        :  1                         
##  Informació i reserves:  0   Col.legi SIL    :  0                         
##  Reserves              :  0   i reserves      :  4                         
##  Tel.                  :391   Recepció       :  6                         
##                               religioses grans:  0                         
##  HORARI_PERIODE_FI  HORARI_DIES      HORARI_HORES_INICI HORARI_HORES_FI
##       :415         Min.   :      0           :415               :415   
##  31/12: 15         1st Qu.:1111111   08:00:00:  6       15:00:00:  6   
##                    Median :1111111   09:00:00:  3       20:00:00:  3   
##                    Mean   : 888889   16:00:00:  6       23:00:00:  6   
##                    3rd Qu.:1111111                                     
##                    Max.   :1111111                                     
##                    NA's   :415                                         
##  HORARI_OBSERVACIONS                    X3ER_NIVELL 
##  Mode:logical                                 :219  
##  NA's:430            Albergs juvenils         :173  
##                      Apartaments              : 26  
##                      Col.legis majors         :  2  
##                      Residències d'estudiants: 10  
##                                                     
##                                                     
##                      X2N_NIVELL       X1ER_NIVELL     X          
##  Albergs juvenils         :173   Allotjament:430   Mode:logical  
##  Altres allotjaments      :211                     NA's:430      
##  Apartaments              : 46                                   
##  Col.legis majors         :  0                                   
##  Residències d'estudiants:  0                                   
##                                                                  
## 

Del resumen se desprende que de las 430 observaciones hay 12 que no corresponderían a alojamientos turisticos: - Col.legis majors (Colegios mayores): 2 - Residències d’estudiants (Residencia de estudiantes): 10

Ahora seleccionamos las variables del dataset que son de nuestro interes:

Alojamientos_Final <- select(ALOJAMIENTOS, CODI_EQUIPAMENT, EQUIPAMENT, NOM_CARRER, NUM_CARRER_1, NUM_CARRER_2, CODI_BARRI, NUM_BARRI, CODI_DISTRICTE, NOM_DISTRICTE, LATITUD, LONGITUD,X3ER_NIVELL, X2N_NIVELL, X1ER_NIVELL)
head(Alojamientos_Final)
##   CODI_EQUIPAMENT                                EQUIPAMENT
## 1     75990024905 Apartament Turístic Mur-Mar - ATB-000042
## 2     75990024905 Apartament Turístic Mur-Mar - ATB-000042
## 3     75990024905 Apartament Turístic Mur-Mar - ATB-000042
## 4     75990024905 Apartament Turístic Mur-Mar - ATB-000042
## 5     75990026619            Aparthotel Bertran - HB-003804
## 6     75990028628  Apartament Turístic Silver - ATB-000005
##                NOM_CARRER NUM_CARRER_1 NUM_CARRER_2 CODI_BARRI
## 1                  Rambla           34           34          2
## 2                  Rambla           34           34          2
## 3                  Rambla           34           34          2
## 4                  Rambla           34           34          2
## 5                 Bertran          150          150         27
## 6 Bretón de los Herreros           26           26         31
##               NUM_BARRI CODI_DISTRICTE        NOM_DISTRICTE  LATITUD LONGITUD
## 1       el Barri Gòtic              1         Ciutat Vella 41.37889 2.175867
## 2       el Barri Gòtic              1         Ciutat Vella 41.37889 2.175867
## 3       el Barri Gòtic              1         Ciutat Vella 41.37889 2.175867
## 4       el Barri Gòtic              1         Ciutat Vella 41.37889 2.175867
## 5 el Putxet i el Farró              5 Sarrià-Sant Gervasi 41.41041 2.139752
## 6    la Vila de Gràcia              6              Gràcia 41.40211 2.151199
##   X3ER_NIVELL          X2N_NIVELL X1ER_NIVELL
## 1 Apartaments Altres allotjaments Allotjament
## 2 Apartaments Altres allotjaments Allotjament
## 3                     Apartaments Allotjament
## 4                     Apartaments Allotjament
## 5                     Apartaments Allotjament
## 6 Apartaments Altres allotjaments Allotjament

Pensiones:

Pensiones <- read.csv("02_Pensiones.csv")
head(Pensiones)
##   CODI_EQUIPAMENT                              EQUIPAMENT SECCIO TIPUS_VIA
## 1       166180029                 Hostal Eden - HB-004039      #         C
## 2       166180029                 Hostal Eden - HB-004039      #         C
## 3       167082307                 Hostal Grau - HB-002211      #         C
## 4       167082307                 Hostal Grau - HB-002211      #         C
## 5       320124701 Hostal Barcelona City Rooms - HB-004028      #         C
## 6       320124701 Hostal Barcelona City Rooms - HB-004028      #         C
##   NOM_CARRER NUM_CARRER_1 NUM_CARRER_2 CODI_BARRI
## 1     Balmes           55           55          8
## 2     Balmes           55           55          8
## 3 Ramelleres           27           27          1
## 4 Ramelleres           27           27          1
## 5 Indústria           81           81         32
## 6 Indústria           81           81         32
##                             NUM_BARRI CODI_DISTRICTE NOM_DISTRICTE CODI_POSTAL
## 1     l'Antiga Esquerra de l'Eixample              2      Eixample        8007
## 2     l'Antiga Esquerra de l'Eixample              2      Eixample        8007
## 3                            el Raval              1  Ciutat Vella        8001
## 4                            el Raval              1  Ciutat Vella        8001
## 5 el Camp d'en Grassot i Gràcia Nova              6       Gràcia        8025
## 6 el Camp d'en Grassot i Gràcia Nova              6       Gràcia        8025
##   CODI_POBLACIO  POBLACIO  LATITUD LONGITUD X_ETRS89 Y_ETRS89   X_ED50  Y_ED50
## 1            19 BARCELONA 41.38953 2.162229 429958.3  4582338 430050.2 4582539
## 2            19 BARCELONA 41.38953 2.162229 429958.3  4582338 430050.2 4582539
## 3            19 BARCELONA 41.38476 2.168168 430449.8  4581805 430541.7 4582006
## 4            19 BARCELONA 41.38476 2.168168 430449.8  4581805 430541.7 4582006
## 5            19 BARCELONA 41.40575 2.169145 430553.8  4584133 430645.7 4584334
## 6            19 BARCELONA 41.40575 2.169145 430553.8  4584133 430645.7 4584334
##   TELEFON_NUM TELEFON_TIPUS TELEFON_INFO_COM HORARI_PERIODE_INICI
## 1   934526620          Tel.               NA                   NA
## 2   934526620          Tel.               NA                   NA
## 3   933018135          Tel.               NA                   NA
## 4   933018135          Tel.               NA                   NA
## 5   934879762          Tel.               NA                   NA
## 6   934879762          Tel.               NA                   NA
##   HORARI_PERIODE_FI HORARI_DIES HORARI_HORES_INICI HORARI_HORES_FI
## 1                NA          NA                 NA              NA
## 2                NA          NA                 NA              NA
## 3                NA          NA                 NA              NA
## 4                NA          NA                 NA              NA
## 5                NA          NA                 NA              NA
## 6                NA          NA                 NA              NA
##   HORARI_OBSERVACIONS X3ER_NIVELL X2N_NIVELL X1ER_NIVELL  X
## 1                  NA               Pensions Allotjament NA
## 2                  NA    Pensions   Pensions Allotjament NA
## 3                  NA    Pensions   Pensions Allotjament NA
## 4                  NA               Pensions Allotjament NA
## 5                  NA    Pensions   Pensions Allotjament NA
## 6                  NA               Pensions Allotjament NA
summary(Pensiones)
##  CODI_EQUIPAMENT                                    EQUIPAMENT  SECCIO 
##  Min.   :1.662e+08   Ally's Guest House III - HB-004701  :  4   #:564  
##  1st Qu.:7.599e+10   Aparthotel Betrés - HB-004171      :  4          
##  Median :9.940e+10   Hostal Bèjar - HB-003673           :  4          
##  Mean   :9.147e+10   Hostal Bèjar 2 - HB-003872         :  4          
##  3rd Qu.:9.940e+10   Hostal Barna House - HB-004705      :  4          
##  Max.   :9.940e+10   Hostal Casa Bella Gracia - HB-004560:  4          
##                      (Other)                             :540          
##    TIPUS_VIA                  NOM_CARRER   NUM_CARRER_1    NUM_CARRER_2  
##  C      :458   Balmes              : 26   Min.   :  1.0   Min.   :  1.0  
##  Av     : 30   Corts Catalanes     : 26   1st Qu.: 15.0   1st Qu.: 15.0  
##  G.V.   : 26   Bruc                : 18   Median : 53.0   Median : 53.0  
##  Pl     : 12   Riera de Sant Miquel: 18   Mean   :113.7   Mean   :113.8  
##  Rda    : 10   Girona              : 16   3rd Qu.:129.0   3rd Qu.:129.0  
##  Rbla   :  8   Mallorca            : 16   Max.   :688.0   Max.   :688.0  
##  (Other): 20   (Other)             :444                                  
##    CODI_BARRI                              NUM_BARRI   CODI_DISTRICTE  
##  Min.   : 1.00   la Dreta de Eixample           :160   Min.   : 1.000  
##  1st Qu.: 2.00   el Barri Gòtic                : 96   1st Qu.: 1.000  
##  Median : 7.00   l'Antiga Esquerra de l'Eixample: 62   Median : 2.000  
##  Mean   :10.29   el Raval                       : 56   Mean   : 2.415  
##  3rd Qu.:10.00   la Vila de Gràcia             : 32   3rd Qu.: 2.000  
##  Max.   :68.00   el Poble-sec                   : 22   Max.   :10.000  
##                  (Other)                        :136                   
##               NOM_DISTRICTE  CODI_POSTAL   CODI_POBLACIO      POBLACIO  
##  Eixample            :258   Min.   :8001   Min.   :19    BARCELONA:564  
##  Ciutat Vella        :172   1st Qu.:8002   1st Qu.:19                   
##  Sants-Montjuïc     : 48   Median :8008   Median :19                   
##  Gràcia             : 44   Mean   :8011   Mean   :19                   
##  Sarrià-Sant Gervasi: 20   3rd Qu.:8012   3rd Qu.:19                   
##  Sant Martí         :  8   Max.   :8037   Max.   :19                   
##  (Other)             : 14                                               
##     LATITUD         LONGITUD        X_ETRS89         Y_ETRS89      
##  Min.   :41.37   Min.   :2.123   Min.   :426639   Min.   :4579994  
##  1st Qu.:41.38   1st Qu.:2.160   1st Qu.:429784   1st Qu.:4581436  
##  Median :41.39   Median :2.169   Median :430514   Median :4582294  
##  Mean   :41.39   Mean   :2.166   Mean   :430273   Mean   :4582236  
##  3rd Qu.:41.39   3rd Qu.:2.174   3rd Qu.:430943   3rd Qu.:4582832  
##  Max.   :41.43   Max.   :2.204   Max.   :433494   Max.   :4587119  
##                                                                    
##      X_ED50           Y_ED50           TELEFON_NUM 
##  Min.   :426730   Min.   :4580195   934879762: 12  
##  1st Qu.:429876   1st Qu.:4581637   932389307: 10  
##  Median :430606   Median :4582495            :  8  
##  Mean   :430365   Mean   :4582437   932955360:  8  
##  3rd Qu.:431035   3rd Qu.:4583033   934526620:  6  
##  Max.   :433586   Max.   :4587320   935510516:  6  
##                                     (Other)  :514  
##                 TELEFON_TIPUS TELEFON_INFO_COM HORARI_PERIODE_INICI
##                        :  8   Mode:logical     Mode:logical        
##  Centraleta            :  6   NA's:564         NA's:564            
##  Fax                   : 16                                        
##  Informació i reserves:  2                                        
##  Tel.                  :532                                        
##                                                                    
##                                                                    
##  HORARI_PERIODE_FI HORARI_DIES    HORARI_HORES_INICI HORARI_HORES_FI
##  Mode:logical      Mode:logical   Mode:logical       Mode:logical   
##  NA's:564          NA's:564       NA's:564           NA's:564       
##                                                                     
##                                                                     
##                                                                     
##                                                                     
##                                                                     
##  HORARI_OBSERVACIONS   X3ER_NIVELL     X2N_NIVELL       X1ER_NIVELL 
##  Mode:logical                :282   Pensions:564   Allotjament:564  
##  NA's:564            Pensions:282                                   
##                                                                     
##                                                                     
##                                                                     
##                                                                     
##                                                                     
##     X          
##  Mode:logical  
##  NA's:564      
##                
##                
##                
##                
## 
Pensiones_Final <- select(ALOJAMIENTOS, CODI_EQUIPAMENT, EQUIPAMENT, NOM_CARRER, NUM_CARRER_1, NUM_CARRER_2, CODI_BARRI, NUM_BARRI, CODI_DISTRICTE, NOM_DISTRICTE, LATITUD, LONGITUD,X3ER_NIVELL, X2N_NIVELL, X1ER_NIVELL)

head(Pensiones_Final)
##   CODI_EQUIPAMENT                                EQUIPAMENT
## 1     75990024905 Apartament Turístic Mur-Mar - ATB-000042
## 2     75990024905 Apartament Turístic Mur-Mar - ATB-000042
## 3     75990024905 Apartament Turístic Mur-Mar - ATB-000042
## 4     75990024905 Apartament Turístic Mur-Mar - ATB-000042
## 5     75990026619            Aparthotel Bertran - HB-003804
## 6     75990028628  Apartament Turístic Silver - ATB-000005
##                NOM_CARRER NUM_CARRER_1 NUM_CARRER_2 CODI_BARRI
## 1                  Rambla           34           34          2
## 2                  Rambla           34           34          2
## 3                  Rambla           34           34          2
## 4                  Rambla           34           34          2
## 5                 Bertran          150          150         27
## 6 Bretón de los Herreros           26           26         31
##               NUM_BARRI CODI_DISTRICTE        NOM_DISTRICTE  LATITUD LONGITUD
## 1       el Barri Gòtic              1         Ciutat Vella 41.37889 2.175867
## 2       el Barri Gòtic              1         Ciutat Vella 41.37889 2.175867
## 3       el Barri Gòtic              1         Ciutat Vella 41.37889 2.175867
## 4       el Barri Gòtic              1         Ciutat Vella 41.37889 2.175867
## 5 el Putxet i el Farró              5 Sarrià-Sant Gervasi 41.41041 2.139752
## 6    la Vila de Gràcia              6              Gràcia 41.40211 2.151199
##   X3ER_NIVELL          X2N_NIVELL X1ER_NIVELL
## 1 Apartaments Altres allotjaments Allotjament
## 2 Apartaments Altres allotjaments Allotjament
## 3                     Apartaments Allotjament
## 4                     Apartaments Allotjament
## 5                     Apartaments Allotjament
## 6 Apartaments Altres allotjaments Allotjament

Hoteles:

Hoteles <- read.csv("03_Hoteles.csv")
head(Hoteles)
##   CODI_EQUIPAMENT                            EQUIPAMENT SECCIO TIPUS_VIA
## 1        12124527      Hotel Amrey Sant Pau - HB-004046      #         C
## 2        12124527      Hotel Amrey Sant Pau - HB-004046      #         C
## 3        75145812     Hotel Sansi Pedralbes - HB-004086      #        Av
## 4        75145812     Hotel Sansi Pedralbes - HB-004086      #        Av
## 5       139120246 Hotel Silken Sant Gervasi - HB-004054      #         C
## 6       139120246 Hotel Silken Sant Gervasi - HB-004054      #         C
##                 NOM_CARRER NUM_CARRER_1 NUM_CARRER_2 CODI_BARRI
## 1 Sant Antoni Maria Claret          173          173         35
## 2 Sant Antoni Maria Claret          173          173         35
## 3                  Pearson            1            3         21
## 4                  Pearson            1            3         21
## 5 Sant Gervasi de Cassoles           26           26         25
## 6 Sant Gervasi de Cassoles           26           26         25
##                    NUM_BARRI CODI_DISTRICTE        NOM_DISTRICTE CODI_POSTAL
## 1               el Guinardó              7      Horta-Guinardó        8041
## 2               el Guinardó              7      Horta-Guinardó        8041
## 3                  Pedralbes              4            Les Corts        8034
## 4                  Pedralbes              4            Les Corts        8034
## 5 Sant Gervasi - la Bonanova              5 Sarrià-Sant Gervasi        8022
## 6 Sant Gervasi - la Bonanova              5 Sarrià-Sant Gervasi        8022
##   CODI_POBLACIO  POBLACIO  LATITUD LONGITUD X_ETRS89 Y_ETRS89   X_ED50  Y_ED50
## 1            19 BARCELONA 41.41401 2.177888 431293.3  4585044 431385.2 4585245
## 2            19 BARCELONA 41.41401 2.177888 431293.3  4585044 431385.2 4585245
## 3            19 BARCELONA 41.39370 2.111575 425728.1  4582844 425820.0 4583045
## 4            19 BARCELONA 41.39370 2.111575 425728.1  4582844 425820.0 4583045
## 5            19 BARCELONA 41.40471 2.138854 428020.8  4584043 428112.7 4584244
## 6            19 BARCELONA 41.40471 2.138854 428020.8  4584043 428112.7 4584244
##   TELEFON_NUM TELEFON_TIPUS TELEFON_INFO_COM HORARI_PERIODE_INICI
## 1   934335151          Tel.               NA                   NA
## 2   934335151          Tel.               NA                   NA
## 3   932063880    Centraleta               NA                   NA
## 4   932063880    Centraleta               NA                   NA
## 5   932531740    Centraleta               NA                   NA
## 6   932531740    Centraleta               NA                   NA
##   HORARI_PERIODE_FI HORARI_DIES HORARI_HORES_INICI HORARI_HORES_FI
## 1                NA          NA                 NA              NA
## 2                NA          NA                 NA              NA
## 3                NA          NA                 NA              NA
## 4                NA          NA                 NA              NA
## 5                NA          NA                 NA              NA
## 6                NA          NA                 NA              NA
##   HORARI_OBSERVACIONS    X3ER_NIVELL X2N_NIVELL X1ER_NIVELL  X
## 1                  NA Hotels 2 estr.     Hotels Allotjament NA
## 2                  NA    2 estrelles     Hotels Allotjament NA
## 3                  NA Hotels 4 estr.     Hotels Allotjament NA
## 4                  NA    4 estrelles     Hotels Allotjament NA
## 5                  NA    3 estrelles     Hotels Allotjament NA
## 6                  NA Hotels 3 estr.     Hotels Allotjament NA
summary(Hoteles)
##  CODI_EQUIPAMENT                                             EQUIPAMENT 
##  Min.   :1.212e+07   Hotel Comercio - HB-000050                   :  8  
##  1st Qu.:7.599e+10   Hotel 54 Barceloneta - HB-004371             :  6  
##  Median :9.940e+10   Hotel Alguer Camp Nou - HB-003643            :  6  
##  Mean   :8.615e+10   Gran Hotel Havana Silken - HB-003916         :  4  
##  3rd Qu.:9.940e+10   Hotel & Spa Villa Olimpic@ Suites - HB-004383:  4  
##  Max.   :9.940e+10   Hotel Advance - HB-004450                    :  4  
##                      (Other)                                      :852  
##  SECCIO    TIPUS_VIA             NOM_CARRER   NUM_CARRER_1    NUM_CARRER_2  
##  #:884   C      :568   Corts Catalanes: 46   Min.   :  0.0   Min.   :  1.0  
##          Av     : 74   Rambla         : 38   1st Qu.: 14.0   1st Qu.: 15.0  
##          Pg     : 50   Catalunya      : 26   Median : 46.0   Median : 48.0  
##          G.V.   : 46   Gràcia        : 24   Mean   :119.6   Mean   :121.0  
##          Pl     : 38   Pelai          : 22   3rd Qu.:157.0   3rd Qu.:158.2  
##          Rbla   : 26   Diputació     : 20   Max.   :700.0   Max.   :700.0  
##          (Other): 82   (Other)        :708                   NA's   :4      
##    CODI_BARRI                                    NUM_BARRI   CODI_DISTRICTE  
##  Min.   : 1.00   la Dreta de Eixample                 :186   Min.   : 1.000  
##  1st Qu.: 3.00   el Barri Gòtic                      :116   1st Qu.: 1.000  
##  Median : 7.00   el Raval                             : 98   Median : 2.000  
##  Mean   :14.47   l'Antiga Esquerra de l'Eixample      : 58   Mean   : 3.052  
##  3rd Qu.:19.00   Sant Pere, Santa Caterina i la Ribera: 44   3rd Qu.: 4.000  
##  Max.   :71.00   la Nova Esquerra de l'Eixample       : 36   Max.   :10.000  
##                  (Other)                              :346                   
##               NOM_DISTRICTE  CODI_POSTAL   CODI_POBLACIO      POBLACIO  
##  Eixample            :334   Min.   :8001   Min.   :19    BARCELONA:884  
##  Ciutat Vella        :272   1st Qu.:8003   1st Qu.:19                   
##  Sant Martí         : 86   Median :8008   Median :19                   
##  Sarrià-Sant Gervasi: 62   Mean   :8012   Mean   :19                   
##  Les Corts           : 46   3rd Qu.:8018   3rd Qu.:19                   
##  Sants-Montjuïc     : 46   Max.   :8041   Max.   :19                   
##  (Other)             : 38                                               
##     LATITUD         LONGITUD        X_ETRS89         Y_ETRS89      
##  Min.   :41.33   Min.   :2.110   Min.   :425559   Min.   :4575617  
##  1st Qu.:41.38   1st Qu.:2.157   1st Qu.:429511   1st Qu.:4581562  
##  Median :41.39   Median :2.169   Median :430553   Median :4582123  
##  Mean   :41.39   Mean   :2.167   Mean   :430351   Mean   :4582345  
##  3rd Qu.:41.39   3rd Qu.:2.176   3rd Qu.:431117   3rd Qu.:4582893  
##  Max.   :41.44   Max.   :2.219   Max.   :434702   Max.   :4587834  
##                                                                    
##      X_ED50           Y_ED50           TELEFON_NUM 
##  Min.   :425651   Min.   :4575818   932689070: 12  
##  1st Qu.:429603   1st Qu.:4581762   900818320: 10  
##  Median :430645   Median :4582324   916008146: 10  
##  Mean   :430443   Mean   :4582546   934922244:  8  
##  3rd Qu.:431209   3rd Qu.:4583094   933437167:  6  
##  Max.   :434794   Max.   :4588035   932157255:  4  
##                                     (Other)  :834  
##                 TELEFON_TIPUS TELEFON_INFO_COM HORARI_PERIODE_INICI
##  Atenció al client    :  2   Mode:logical     Mode:logical        
##  Centraleta            :184   NA's:884         NA's:884            
##  Fax                   : 16                                        
##  Informació           :  8                                        
##  Informació i reserves: 12                                        
##  Reserves              : 66                                        
##  Tel.                  :596                                        
##  HORARI_PERIODE_FI HORARI_DIES    HORARI_HORES_INICI HORARI_HORES_FI
##  Mode:logical      Mode:logical   Mode:logical       Mode:logical   
##  NA's:884          NA's:884       NA's:884           NA's:884       
##                                                                     
##                                                                     
##                                                                     
##                                                                     
##                                                                     
##  HORARI_OBSERVACIONS         X3ER_NIVELL   X2N_NIVELL       X1ER_NIVELL 
##  Mode:logical        4 estrelles   :195   Hotels:884   Allotjament:884  
##  NA's:884            Hotels 4 estr.:195                                 
##                      3 estrelles   :125                                 
##                      Hotels 3 estr.:125                                 
##                      2 estrelles   : 46                                 
##                      Hotels 2 estr.: 46                                 
##                      (Other)       :152                                 
##     X          
##  Mode:logical  
##  NA's:884      
##                
##                
##                
##                
## 
Hoteles_Final <- select(ALOJAMIENTOS, CODI_EQUIPAMENT, EQUIPAMENT, NOM_CARRER, NUM_CARRER_1, NUM_CARRER_2, CODI_BARRI, NUM_BARRI, CODI_DISTRICTE, NOM_DISTRICTE, LATITUD, LONGITUD,X3ER_NIVELL, X2N_NIVELL, X1ER_NIVELL)

head(Hoteles_Final)
##   CODI_EQUIPAMENT                                EQUIPAMENT
## 1     75990024905 Apartament Turístic Mur-Mar - ATB-000042
## 2     75990024905 Apartament Turístic Mur-Mar - ATB-000042
## 3     75990024905 Apartament Turístic Mur-Mar - ATB-000042
## 4     75990024905 Apartament Turístic Mur-Mar - ATB-000042
## 5     75990026619            Aparthotel Bertran - HB-003804
## 6     75990028628  Apartament Turístic Silver - ATB-000005
##                NOM_CARRER NUM_CARRER_1 NUM_CARRER_2 CODI_BARRI
## 1                  Rambla           34           34          2
## 2                  Rambla           34           34          2
## 3                  Rambla           34           34          2
## 4                  Rambla           34           34          2
## 5                 Bertran          150          150         27
## 6 Bretón de los Herreros           26           26         31
##               NUM_BARRI CODI_DISTRICTE        NOM_DISTRICTE  LATITUD LONGITUD
## 1       el Barri Gòtic              1         Ciutat Vella 41.37889 2.175867
## 2       el Barri Gòtic              1         Ciutat Vella 41.37889 2.175867
## 3       el Barri Gòtic              1         Ciutat Vella 41.37889 2.175867
## 4       el Barri Gòtic              1         Ciutat Vella 41.37889 2.175867
## 5 el Putxet i el Farró              5 Sarrià-Sant Gervasi 41.41041 2.139752
## 6    la Vila de Gràcia              6              Gràcia 41.40211 2.151199
##   X3ER_NIVELL          X2N_NIVELL X1ER_NIVELL
## 1 Apartaments Altres allotjaments Allotjament
## 2 Apartaments Altres allotjaments Allotjament
## 3                     Apartaments Allotjament
## 4                     Apartaments Allotjament
## 5                     Apartaments Allotjament
## 6 Apartaments Altres allotjaments Allotjament

3- Unificamos los dataset de Alojamientos, Pensiones y Hoteles:

Alojamientos_Unificados = rbind(Alojamientos_Final, Pensiones_Final,Hoteles_Final)
summary(Alojamientos_Unificados)
##  CODI_EQUIPAMENT    
##  Min.   :7.599e+10  
##  1st Qu.:9.940e+10  
##  Median :9.940e+10  
##  Mean   :9.761e+10  
##  3rd Qu.:9.940e+10  
##  Max.   :9.940e+10  
##                     
##                                                        EQUIPAMENT  
##  Pis Modernista Aribau                                      :  48  
##  Casa Marsans - Alberg Mare de Déu de Montserrat - AJ000084:  36  
##  Residència d'Estudiants  Barcelona Diagonal - AJ000658    :  18  
##  Residència Universitària Sants - AJ000640                :  18  
##  After Hostel - AJ000543                                    :  12  
##  Alberg  Don Moustache! - AJ000540                          :  12  
##  (Other)                                                    :1146  
##                  NOM_CARRER    NUM_CARRER_1    NUM_CARRER_2     CODI_BARRI
##  Aribau               :  48   Min.   :  2.0   Min.   :  2.0   Min.   : 1  
##  Bruc                 :  48   1st Qu.: 24.0   1st Qu.: 24.0   1st Qu.: 7  
##  València            :  48   Median : 51.0   Median : 51.0   Median : 8  
##  Mare de Déu del Coll:  42   Mean   :103.2   Mean   :103.8   Mean   :16  
##  Sant Pere            :  42   3rd Qu.: 98.0   3rd Qu.: 98.0   3rd Qu.:23  
##  Augusta              :  30   Max.   :716.0   Max.   :716.0   Max.   :68  
##  (Other)              :1032                                               
##                            NUM_BARRI   CODI_DISTRICTE  
##  la Dreta de Eixample           :366   Min.   : 1.000  
##  l'Antiga Esquerra de l'Eixample:123   1st Qu.: 2.000  
##  Sants                          : 81   Median : 2.000  
##  la Vila de Gràcia             : 75   Mean   : 3.314  
##  el Poble-sec                   : 72   3rd Qu.: 5.000  
##  el Barri Gòtic                : 57   Max.   :10.000  
##  (Other)                        :516                   
##               NOM_DISTRICTE    LATITUD         LONGITUD    
##  Eixample            :600   Min.   :41.37   Min.   :2.102  
##  Sants-Montjuïc     :177   1st Qu.:41.38   1st Qu.:2.151  
##  Ciutat Vella        :132   Median :41.39   Median :2.165  
##  Gràcia             :129   Mean   :41.39   Mean   :2.161  
##  Sarrià-Sant Gervasi: 99   3rd Qu.:41.40   3rd Qu.:2.173  
##  Sant Martí         : 51   Max.   :41.44   Max.   :2.206  
##  (Other)             :102                                  
##                     X3ER_NIVELL                      X2N_NIVELL 
##                           :657   Albergs juvenils         :519  
##  Albergs juvenils         :519   Altres allotjaments      :633  
##  Apartaments              : 78   Apartaments              :138  
##  Col.legis majors         :  6   Col.legis majors         :  0  
##  Residències d'estudiants: 30   Residències d'estudiants:  0  
##                                                                 
##                                                                 
##       X1ER_NIVELL  
##  Allotjament:1290  
##                    
##                    
##                    
##                    
##                    
## 

Para nuestro analisis contamos con un total de 1290 alojamientos turisticosen la ciudad de Barcelona.

4- Observamos el dataset vinculado a las actividades económicas en planta baja:

Actividades_Económicas_PB <- read.csv("11_Censo_Actividades_Económicas_2019.csv")

head(Actividades_Económicas_PB)
##   ï..ID_Bcn_2019 ID_Bcn_2016 Codi_Principal_Activitat Nom_Principal_Activitat
## 1        1075454          NA                        1                   Actiu
## 2        1075453          NA                        1                   Actiu
## 3        1075451          NA                        1                   Actiu
## 4        1075449          NA                        1                   Actiu
## 5        1075448          NA                        1                   Actiu
## 6        1075447          NA                        1                   Actiu
##   Codi_Sector_Activitat Nom_Sector_Activitat Codi_Grup_Activitat
## 1                     2              Serveis                  16
## 2                     2              Serveis                  16
## 3                     2              Serveis                  16
## 4                     3               Altres                  17
## 5                     2              Serveis                  16
## 6                     2              Serveis                  16
##   Nom_Grup_Activitat Codi_Activitat_2019                     Nom_Activitat
## 1             Altres             1600400 Serveis a les empreses i oficines
## 2             Altres             1600102         Activitats emmagatzematge
## 3             Altres             1600400 Serveis a les empreses i oficines
## 4             Altres             1700100                    Administració
## 5             Altres             1600101          Activitats de transport 
## 6             Altres             1600102         Activitats emmagatzematge
##   Codi_Activitat_2016               Nom_Local SN_Oci_Nocturn SN_Coworking
## 1               16004                 SORIGUE              1            1
## 2             1600102      CEJIDOS SIVILA S.A              1            1
## 3               16004         QUALITY ESPRESO              1            1
## 4               17001                     CLD              1            1
## 5             1600101 CATALANA DEL BUTANO,S.A              1            1
## 6             1600102  JOSE MESTRES CARCERENY              1            1
##   SN_Servei_Degustacio SN_Obert24h SN_Mixtura SN_Carrer SN_Mercat Nom_Mercat
## 1                    1           1          1         0         1           
## 2                    1           1          1         0         1           
## 3                    1           1          1         0         1           
## 4                    1           1          1         0         1           
## 5                    1           1          1         0         1           
## 6                    1           1          1         0         1           
##   SN_Galeria Nom_Galeria SN_CComercial Nom_CComercial SN_Eix Nom_Eix
## 1          1                         1                     1        
## 2          1                         1                     1        
## 3          1                         1                     1        
## 4          1                         1                     1        
## 5          1                         1                     1        
## 6          1                         1                     1        
##   X_UTM_ETRS89 Y_UTM_ETRS89  Latitud Longitud          Direccio_Unica Codi_Via
## 1     427229.3      4577544 41.34610 2.130166   222206, 19-19, LOC 10   222206
## 2     427178.4      4577526 41.34594 2.129560 222206, 278-282, LOC 10   222206
## 3     427092.9      4577488 41.34559 2.128543     222206, 1-9, LOC 10   222206
## 4     427265.7      4577561 41.34626 2.130599   222206, 21-21, LOC 10   222206
## 5     427322.2      4577589 41.34651 2.131271   222206, 25-27, LOC 10   222206
## 6     427394.6      4577622 41.34683 2.132132   222206, 29-39, LOC 10   222206
##   Nom_Via Planta Porta Num_Policia_Inicial Lletra_Inicial Num_Policia_Final
## 1  MOTORS    LOC    10                  19                               19
## 2  MOTORS    LOC    10                 278                              282
## 3  MOTORS    LOC    10                   1                                9
## 4  MOTORS    LOC    10                  21                               21
## 5  MOTORS    LOC    10                  25                               27
## 6  MOTORS    LOC    10                  29                               39
##   Lletra_Final Solar Codi_Parcela Codi_Illa Seccio_Censal Codi_Barri
## 1                 NA           NA        NA            25         12
## 2                 NA           NA        NA            25         12
## 3                 NA           NA        NA            25         12
## 4                 NA           NA        NA            25         12
## 5                 NA           NA        NA            25         12
## 6                 NA           NA        NA            25         12
##                    Nom_Barri Codi_Districte   Nom_Districte
## 1 la Marina del Prat Vermell              3 Sants-Montjuïc
## 2 la Marina del Prat Vermell              3 Sants-Montjuïc
## 3 la Marina del Prat Vermell              3 Sants-Montjuïc
## 4 la Marina del Prat Vermell              3 Sants-Montjuïc
## 5 la Marina del Prat Vermell              3 Sants-Montjuïc
## 6 la Marina del Prat Vermell              3 Sants-Montjuïc
##   Referencia_cadastral Data_Revisio
## 1                          20190925
## 2                          20190925
## 3                          20190925
## 4                          20190925
## 5                          20190925
## 6                          20190925
summary(Actividades_Económicas_PB)
##  ï..ID_Bcn_2019     ID_Bcn_2016    Codi_Principal_Activitat
##  Min.   : 994347   Min.   : 4215   Min.   :0.0000          
##  1st Qu.:1015314   1st Qu.:22810   1st Qu.:1.0000          
##  Median :1036245   Median :41288   Median :1.0000          
##  Mean   :1036249   Mean   :41203   Mean   :0.7642          
##  3rd Qu.:1057203   3rd Qu.:59653   3rd Qu.:1.0000          
##  Max.   :1078043   Max.   :78056   Max.   :1.0000          
##                    NA's   :10025                           
##                Nom_Principal_Activitat Codi_Sector_Activitat
##  Actiu                     :61558      Min.   :1.000        
##  Sense activitat Econòmica:18996      1st Qu.:1.000        
##                                        Median :2.000        
##                                        Mean   :2.221        
##                                        3rd Qu.:3.000        
##                                        Max.   :5.000        
##                                                             
##                                           Nom_Sector_Activitat
##  Serveis                                            :33402    
##  Comerç al detall                                  :21326    
##  Sense informació                                  :11164    
##  Altres                                             : 6148    
##  Sense informació - Havia tingut activitat (rètol): 4276    
##  Locals buits en lloguer                            : 1396    
##  (Other)                                            : 2842    
##  Codi_Grup_Activitat
##  Min.   : 0.000     
##  1st Qu.: 1.000     
##  Median : 7.000     
##  Mean   : 7.947     
##  3rd Qu.:15.000     
##  Max.   :17.000     
##                     
##                                                        Nom_Grup_Activitat
##  Altres                                                         :21496   
##  Grup no definit                                                :18996   
##  Restaurants, bars i hotels (Inclòs hostals, pensions i fondes):11157   
##  Quotidià alimentari                                           : 7850   
##  Equipament personal                                            : 4918   
##  Quotidià no alimentari                                        : 2592   
##  (Other)                                                        :13545   
##  Codi_Activitat_2019
##  Min.   :     10    
##  1st Qu.:1000020    
##  Median :1400003    
##  Mean   :1825614    
##  3rd Qu.:1700500    
##  Max.   :9000000    
##                     
##                                              Nom_Activitat  
##  Sense informació                                  :11164  
##  Restaurants                                        : 5599  
##  Sense informació - Havia tingut activitat (rètol): 4276  
##  Serveis a les empreses i oficines                  : 3464  
##  Bars   / CIBERCAFÃ\210                                : 3290  
##  Vestir                                             : 3157  
##  (Other)                                            :49604  
##  Codi_Activitat_2016       Nom_Local     SN_Oci_Nocturn    SN_Coworking   
##  *0000041:11164      SN         :17274   Min.   :0.0000   Min.   :0.0000  
##  1400002 : 5599      S/N        :  452   1st Qu.:1.0000   1st Qu.:1.0000  
##  *0000042: 4276      CAIXABANK  :  304   Median :1.0000   Median :1.0000  
##  16004   : 3464      FARMACIA   :  223   Mean   :0.9971   Mean   :0.9959  
##  1400001 : 3290      SUPERMERCAT:  162   3rd Qu.:1.0000   3rd Qu.:1.0000  
##  4003    : 3157      CONDIS     :  127   Max.   :1.0000   Max.   :1.0000  
##  (Other) :49604      (Other)    :62012                                    
##  SN_Servei_Degustacio  SN_Obert24h       SN_Mixtura       SN_Carrer      
##  Min.   :0.0000       Min.   :0.0000   Min.   :0.0000   Min.   :0.00000  
##  1st Qu.:1.0000       1st Qu.:1.0000   1st Qu.:1.0000   1st Qu.:0.00000  
##  Median :1.0000       Median :1.0000   Median :1.0000   Median :0.00000  
##  Mean   :0.9902       Mean   :0.9967   Mean   :0.9771   Mean   :0.04246  
##  3rd Qu.:1.0000       3rd Qu.:1.0000   3rd Qu.:1.0000   3rd Qu.:0.00000  
##  Max.   :1.0000       Max.   :1.0000   Max.   :1.0000   Max.   :1.00000  
##                                                                          
##    SN_Mercat            Nom_Mercat      SN_Galeria    
##  Min.   :0.0000              :78367   Min.   :0.0000  
##  1st Qu.:1.0000   Boqueria   :  231   1st Qu.:1.0000  
##  Median :1.0000   Galvany    :  116   Median :1.0000  
##  Mean   :0.9729   E.S.Antoni :   99   Mean   :0.9947  
##  3rd Qu.:1.0000   Hostafrancs:   98   3rd Qu.:1.0000  
##  Max.   :1.0000   Ninot      :   86   Max.   :1.0000  
##                   (Other)    : 1557                   
##                Nom_Galeria    SN_CComercial                Nom_CComercial 
##                      :80125   Min.   :0.0000                      :79658  
##  EncantsBcn-Bellcaire:  155   1st Qu.:1.0000   La Maquinista      :  208  
##  ANTICUARI           :   49   Median :1.0000   Diagonal Mar Centre:  172  
##  MALDA               :   45   Mean   :0.9889   L'Illa Diagonal    :  153  
##  Sants Estació      :   37   3rd Qu.:1.0000   Glòries           :  112  
##  MERCAT GRAN VIA     :   36   Max.   :1.0000   Arenas de Barcelona:   85  
##  (Other)             :  107                    (Other)            :  166  
##      SN_Eix                    Nom_Eix       X_UTM_ETRS89     Y_UTM_ETRS89    
##  Min.   :0.0000                    :56832   Min.   :423801   Min.   :4577403  
##  1st Qu.:0.0000   Sant Gervasi     : 3186   1st Qu.:428911   1st Qu.:4581809  
##  Median :1.0000   Raval            : 2137   Median :430303   Median :4583558  
##  Mean   :0.7056   Sant Antoni Comer: 2130   Mean   :430239   Mean   :4583729  
##  3rd Qu.:1.0000   Sant Mart        : 1535   3rd Qu.:431474   3rd Qu.:4585291  
##  Max.   :1.0000   Sagrada Fam�lia: 1430   Max.   :434872   Max.   :4590873  
##                   (Other)          :13304                                     
##     Latitud         Longitud                     Direccio_Unica 
##  Min.   :41.34   Min.   :2.088   034308, 89B-89, LOC NA :  231  
##  1st Qu.:41.38   1st Qu.:2.150   701357, 2-2, LOC NA    :  208  
##  Median :41.40   Median :2.166   144601, 3-3, LOC NA    :  172  
##  Mean   :41.40   Mean   :2.165   349706, 1-1, LOC NA    :  170  
##  3rd Qu.:41.42   3rd Qu.:2.180   073900, 158-158, LOC NA:  155  
##  Max.   :41.47   Max.   :2.221   144601, 557-557, LOC NA:  153  
##                                  (Other)                :79465  
##     Codi_Via                      Nom_Via      Planta          Porta       
##  Min.   :   306   G.V. CORTS CATALANES: 1138   LOC:80554   Min.   : 10.00  
##  1st Qu.: 94605   AV DIAGONAL         : 1034               1st Qu.: 10.00  
##  Median :189100   VALÃ\210NCIA           :  823               Median : 10.00  
##  Mean   :199124   MALLORCA            :  770               Mean   : 22.63  
##  3rd Qu.:288703   ARAGÓ              :  692               3rd Qu.: 20.00  
##  Max.   :701818   CONSELL DE CENT     :  688               Max.   :570.00  
##                   (Other)             :75409               NA's   :3217    
##  Num_Policia_Inicial Lletra_Inicial  Num_Policia_Final  Lletra_Final  
##  1      : 2190              :77998   6      : 1556            :78019  
##  2      : 1943       B      : 2037   8      : 1545     B      : 1961  
##  10     : 1484       A      :  126   5      : 1514     A      :  170  
##  6      : 1471       C      :   86   2      : 1513     C      :   90  
##  5      : 1438       I      :   71   3      : 1490     I      :   74  
##  3      : 1355       X      :   46   7      : 1442     D      :   46  
##  (Other):70673       (Other):  190   (Other):71494     (Other):  194  
##      Solar         Codi_Parcela      Codi_Illa     Seccio_Censal   
##  Min.   :   792   Min.   :  1.00   Min.   : 5010   Min.   :  1.00  
##  1st Qu.:120592   1st Qu.:  3.00   1st Qu.:21180   1st Qu.: 27.00  
##  Median :147630   Median :  9.00   Median :40590   Median : 52.00  
##  Mean   :245261   Mean   : 11.77   Mean   :48691   Mean   : 59.05  
##  3rd Qu.:305438   3rd Qu.: 16.00   3rd Qu.:81271   3rd Qu.: 82.00  
##  Max.   :584017   Max.   :302.00   Max.   :99535   Max.   :237.00  
##  NA's   :102      NA's   :94       NA's   :94      NA's   :5       
##    Codi_Barri                              Nom_Barri     Codi_Districte  
##  Min.   : 1.00   la Vila de Gràcia             : 4457   Min.   : 1.000  
##  1st Qu.: 9.00   la Dreta de l'Eixample         : 4279   1st Qu.: 2.000  
##  Median :26.00   Sant Gervasi - Galvany         : 3200   Median : 5.000  
##  Mean   :29.55   l'Antiga Esquerra de l'Eixample: 2984   Mean   : 5.187  
##  3rd Qu.:46.00   el Raval                       : 2968   3rd Qu.: 8.000  
##  Max.   :73.00   la Sagrada Família            : 2515   Max.   :10.000  
##                  (Other)                        :60151                   
##               Nom_Districte       Referencia_cadastral  Data_Revisio     
##  Eixample            :15914   0816955DF3801F:  231     Min.   :20190319  
##  Sant Martí         :10133   3082702DF3838A:  209     1st Qu.:20190528  
##  Sants-Montjuïc     : 8234   4647401DF3844H:  172     Median :20190701  
##  Ciutat Vella        : 8166   0013201DF3801C:  170     Mean   :20190657  
##  Sarrià-Sant Gervasi: 7718   2038901DF3823G:  158     3rd Qu.:20190724  
##  Gràcia             : 7484   7825917DF2872F:  155     Max.   :20200131  
##  (Other)             :22905   (Other)       :79459     NA's   :69

Seleccionamos los datos que queremos conservar para nuestro trabajo:

Actividades_Económicas_PB <- select(Actividades_Económicas_PB, ï..ID_Bcn_2019 , Codi_Principal_Activitat, Nom_Principal_Activitat, Codi_Sector_Activitat, Nom_Sector_Activitat, Codi_Grup_Activitat, Nom_Grup_Activitat, Latitud, Longitud, Codi_Via, Nom_Via, Codi_Barri, Nom_Barri, Codi_Districte, Nom_Districte)

head(Actividades_Económicas_PB)
##   ï..ID_Bcn_2019 Codi_Principal_Activitat Nom_Principal_Activitat
## 1        1075454                        1                   Actiu
## 2        1075453                        1                   Actiu
## 3        1075451                        1                   Actiu
## 4        1075449                        1                   Actiu
## 5        1075448                        1                   Actiu
## 6        1075447                        1                   Actiu
##   Codi_Sector_Activitat Nom_Sector_Activitat Codi_Grup_Activitat
## 1                     2              Serveis                  16
## 2                     2              Serveis                  16
## 3                     2              Serveis                  16
## 4                     3               Altres                  17
## 5                     2              Serveis                  16
## 6                     2              Serveis                  16
##   Nom_Grup_Activitat  Latitud Longitud Codi_Via Nom_Via Codi_Barri
## 1             Altres 41.34610 2.130166   222206  MOTORS         12
## 2             Altres 41.34594 2.129560   222206  MOTORS         12
## 3             Altres 41.34559 2.128543   222206  MOTORS         12
## 4             Altres 41.34626 2.130599   222206  MOTORS         12
## 5             Altres 41.34651 2.131271   222206  MOTORS         12
## 6             Altres 41.34683 2.132132   222206  MOTORS         12
##                    Nom_Barri Codi_Districte   Nom_Districte
## 1 la Marina del Prat Vermell              3 Sants-Montjuïc
## 2 la Marina del Prat Vermell              3 Sants-Montjuïc
## 3 la Marina del Prat Vermell              3 Sants-Montjuïc
## 4 la Marina del Prat Vermell              3 Sants-Montjuïc
## 5 la Marina del Prat Vermell              3 Sants-Montjuïc
## 6 la Marina del Prat Vermell              3 Sants-Montjuïc
summary(Actividades_Económicas_PB)
##  ï..ID_Bcn_2019    Codi_Principal_Activitat
##  Min.   : 994347   Min.   :0.0000          
##  1st Qu.:1015314   1st Qu.:1.0000          
##  Median :1036245   Median :1.0000          
##  Mean   :1036249   Mean   :0.7642          
##  3rd Qu.:1057203   3rd Qu.:1.0000          
##  Max.   :1078043   Max.   :1.0000          
##                                            
##                Nom_Principal_Activitat Codi_Sector_Activitat
##  Actiu                     :61558      Min.   :1.000        
##  Sense activitat Econòmica:18996      1st Qu.:1.000        
##                                        Median :2.000        
##                                        Mean   :2.221        
##                                        3rd Qu.:3.000        
##                                        Max.   :5.000        
##                                                             
##                                           Nom_Sector_Activitat
##  Serveis                                            :33402    
##  Comerç al detall                                  :21326    
##  Sense informació                                  :11164    
##  Altres                                             : 6148    
##  Sense informació - Havia tingut activitat (rètol): 4276    
##  Locals buits en lloguer                            : 1396    
##  (Other)                                            : 2842    
##  Codi_Grup_Activitat
##  Min.   : 0.000     
##  1st Qu.: 1.000     
##  Median : 7.000     
##  Mean   : 7.947     
##  3rd Qu.:15.000     
##  Max.   :17.000     
##                     
##                                                        Nom_Grup_Activitat
##  Altres                                                         :21496   
##  Grup no definit                                                :18996   
##  Restaurants, bars i hotels (Inclòs hostals, pensions i fondes):11157   
##  Quotidià alimentari                                           : 7850   
##  Equipament personal                                            : 4918   
##  Quotidià no alimentari                                        : 2592   
##  (Other)                                                        :13545   
##     Latitud         Longitud        Codi_Via                      Nom_Via     
##  Min.   :41.34   Min.   :2.088   Min.   :   306   G.V. CORTS CATALANES: 1138  
##  1st Qu.:41.38   1st Qu.:2.150   1st Qu.: 94605   AV DIAGONAL         : 1034  
##  Median :41.40   Median :2.166   Median :189100   VALÃ\210NCIA           :  823  
##  Mean   :41.40   Mean   :2.165   Mean   :199124   MALLORCA            :  770  
##  3rd Qu.:41.42   3rd Qu.:2.180   3rd Qu.:288703   ARAGÓ              :  692  
##  Max.   :41.47   Max.   :2.221   Max.   :701818   CONSELL DE CENT     :  688  
##                                                   (Other)             :75409  
##    Codi_Barri                              Nom_Barri     Codi_Districte  
##  Min.   : 1.00   la Vila de Gràcia             : 4457   Min.   : 1.000  
##  1st Qu.: 9.00   la Dreta de l'Eixample         : 4279   1st Qu.: 2.000  
##  Median :26.00   Sant Gervasi - Galvany         : 3200   Median : 5.000  
##  Mean   :29.55   l'Antiga Esquerra de l'Eixample: 2984   Mean   : 5.187  
##  3rd Qu.:46.00   el Raval                       : 2968   3rd Qu.: 8.000  
##  Max.   :73.00   la Sagrada Família            : 2515   Max.   :10.000  
##                  (Other)                        :60151                   
##               Nom_Districte  
##  Eixample            :15914  
##  Sant Martí         :10133  
##  Sants-Montjuïc     : 8234  
##  Ciutat Vella        : 8166  
##  Sarrià-Sant Gervasi: 7718  
##  Gràcia             : 7484  
##  (Other)             :22905

Seleccionamos los datos que queremos conservar para nuestro trabajo:

Actividades_Económicas_PB <- select(Actividades_Económicas_PB,  ï..ID_Bcn_2019, Codi_Principal_Activitat, Nom_Principal_Activitat, Codi_Sector_Activitat, Nom_Sector_Activitat, Codi_Grup_Activitat, Nom_Grup_Activitat, Latitud, Longitud, Codi_Via, Nom_Via, Codi_Barri, Nom_Barri, Codi_Districte, Nom_Districte)

head(Actividades_Económicas_PB)
##   ï..ID_Bcn_2019 Codi_Principal_Activitat Nom_Principal_Activitat
## 1        1075454                        1                   Actiu
## 2        1075453                        1                   Actiu
## 3        1075451                        1                   Actiu
## 4        1075449                        1                   Actiu
## 5        1075448                        1                   Actiu
## 6        1075447                        1                   Actiu
##   Codi_Sector_Activitat Nom_Sector_Activitat Codi_Grup_Activitat
## 1                     2              Serveis                  16
## 2                     2              Serveis                  16
## 3                     2              Serveis                  16
## 4                     3               Altres                  17
## 5                     2              Serveis                  16
## 6                     2              Serveis                  16
##   Nom_Grup_Activitat  Latitud Longitud Codi_Via Nom_Via Codi_Barri
## 1             Altres 41.34610 2.130166   222206  MOTORS         12
## 2             Altres 41.34594 2.129560   222206  MOTORS         12
## 3             Altres 41.34559 2.128543   222206  MOTORS         12
## 4             Altres 41.34626 2.130599   222206  MOTORS         12
## 5             Altres 41.34651 2.131271   222206  MOTORS         12
## 6             Altres 41.34683 2.132132   222206  MOTORS         12
##                    Nom_Barri Codi_Districte   Nom_Districte
## 1 la Marina del Prat Vermell              3 Sants-Montjuïc
## 2 la Marina del Prat Vermell              3 Sants-Montjuïc
## 3 la Marina del Prat Vermell              3 Sants-Montjuïc
## 4 la Marina del Prat Vermell              3 Sants-Montjuïc
## 5 la Marina del Prat Vermell              3 Sants-Montjuïc
## 6 la Marina del Prat Vermell              3 Sants-Montjuïc
summary(Actividades_Económicas_PB)
##  ï..ID_Bcn_2019    Codi_Principal_Activitat
##  Min.   : 994347   Min.   :0.0000          
##  1st Qu.:1015314   1st Qu.:1.0000          
##  Median :1036245   Median :1.0000          
##  Mean   :1036249   Mean   :0.7642          
##  3rd Qu.:1057203   3rd Qu.:1.0000          
##  Max.   :1078043   Max.   :1.0000          
##                                            
##                Nom_Principal_Activitat Codi_Sector_Activitat
##  Actiu                     :61558      Min.   :1.000        
##  Sense activitat Econòmica:18996      1st Qu.:1.000        
##                                        Median :2.000        
##                                        Mean   :2.221        
##                                        3rd Qu.:3.000        
##                                        Max.   :5.000        
##                                                             
##                                           Nom_Sector_Activitat
##  Serveis                                            :33402    
##  Comerç al detall                                  :21326    
##  Sense informació                                  :11164    
##  Altres                                             : 6148    
##  Sense informació - Havia tingut activitat (rètol): 4276    
##  Locals buits en lloguer                            : 1396    
##  (Other)                                            : 2842    
##  Codi_Grup_Activitat
##  Min.   : 0.000     
##  1st Qu.: 1.000     
##  Median : 7.000     
##  Mean   : 7.947     
##  3rd Qu.:15.000     
##  Max.   :17.000     
##                     
##                                                        Nom_Grup_Activitat
##  Altres                                                         :21496   
##  Grup no definit                                                :18996   
##  Restaurants, bars i hotels (Inclòs hostals, pensions i fondes):11157   
##  Quotidià alimentari                                           : 7850   
##  Equipament personal                                            : 4918   
##  Quotidià no alimentari                                        : 2592   
##  (Other)                                                        :13545   
##     Latitud         Longitud        Codi_Via                      Nom_Via     
##  Min.   :41.34   Min.   :2.088   Min.   :   306   G.V. CORTS CATALANES: 1138  
##  1st Qu.:41.38   1st Qu.:2.150   1st Qu.: 94605   AV DIAGONAL         : 1034  
##  Median :41.40   Median :2.166   Median :189100   VALÃ\210NCIA           :  823  
##  Mean   :41.40   Mean   :2.165   Mean   :199124   MALLORCA            :  770  
##  3rd Qu.:41.42   3rd Qu.:2.180   3rd Qu.:288703   ARAGÓ              :  692  
##  Max.   :41.47   Max.   :2.221   Max.   :701818   CONSELL DE CENT     :  688  
##                                                   (Other)             :75409  
##    Codi_Barri                              Nom_Barri     Codi_Districte  
##  Min.   : 1.00   la Vila de Gràcia             : 4457   Min.   : 1.000  
##  1st Qu.: 9.00   la Dreta de l'Eixample         : 4279   1st Qu.: 2.000  
##  Median :26.00   Sant Gervasi - Galvany         : 3200   Median : 5.000  
##  Mean   :29.55   l'Antiga Esquerra de l'Eixample: 2984   Mean   : 5.187  
##  3rd Qu.:46.00   el Raval                       : 2968   3rd Qu.: 8.000  
##  Max.   :73.00   la Sagrada Família            : 2515   Max.   :10.000  
##                  (Other)                        :60151                   
##               Nom_Districte  
##  Eixample            :15914  
##  Sant Martí         :10133  
##  Sants-Montjuïc     : 8234  
##  Ciutat Vella        : 8166  
##  Sarrià-Sant Gervasi: 7718  
##  Gràcia             : 7484  
##  (Other)             :22905

Nos focalizamos en la columna Nom_Grup_Activitat, ya que cuenta con mayor detallle de las actividades económicas desarrolladas.

ggplot(Actividades_Económicas_PB) +
  geom_bar(aes(x=Nom_Grup_Activitat))+
  coord_flip()

Analizamos que hay una gran cantidad de actividades que no estan asignadas a ningún grupo, categorizadas como “Altres=Otras”, asimismo, existe otra gran cantidad asignadas a la categorgía “Grup no definit=Grupo no definido”. Pero es relvante observar que “Restaurants, bars i hotels=Restarrants, bares y hoteles” como “Quotidia alimentari=Cotidiano alimentario”, son las categorías que más cantidad de observaciones tienen de aquellas que estan clasificadas. Luego, sobreviene “Equipament personal=Equipamiento personal”, seguido del resto de las actividades que van descendinedo de una forma más progresiva.

Ajustamos nuestro dataset filtrando las actividades económicas que queremos utilizar para el análisis de la localización de alojamientos turísitcos. Para ello, seleccionamos: - Oci i cultura = Ocio y cultura - Equipaments culturals i recreatius = Equipamientos culturales y recreativos

Actividades_Económicas_Turisticas_PB <- filter(Actividades_Económicas_PB, Nom_Grup_Activitat %in% c("Oci i cultura", "Equipaments culturals i recreatius"))

summary(Actividades_Económicas_Turisticas_PB)
##  ï..ID_Bcn_2019    Codi_Principal_Activitat
##  Min.   : 994371   Min.   :1               
##  1st Qu.:1013483   1st Qu.:1               
##  Median :1034032   Median :1               
##  Mean   :1034436   Mean   :1               
##  3rd Qu.:1055352   3rd Qu.:1               
##  Max.   :1077907   Max.   :1               
##                                            
##                Nom_Principal_Activitat Codi_Sector_Activitat
##  Actiu                     :2681       Min.   :1.000        
##  Sense activitat Econòmica:   0       1st Qu.:1.000        
##                                        Median :1.000        
##                                        Mean   :1.387        
##                                        3rd Qu.:2.000        
##                                        Max.   :2.000        
##                                                             
##                  Nom_Sector_Activitat Codi_Grup_Activitat
##  Comerç al detall         :1644      Min.   : 5.000     
##  Serveis                   :1037      1st Qu.: 5.000     
##  Altres                    :   0      Median : 5.000     
##  Comerç al detall /Engròs:   0      Mean   : 6.934     
##  En reforma                :   0      3rd Qu.:10.000     
##  Locals buits en lloguer   :   0      Max.   :10.000     
##  (Other)                   :   0                         
##                           Nom_Grup_Activitat    Latitud         Longitud    
##  Oci i cultura                     :1644     Min.   :41.35   Min.   :2.091  
##  Equipaments culturals i recreatius:1037     1st Qu.:41.38   1st Qu.:2.154  
##  Activitats immobiliàries         :   0     Median :41.40   Median :2.166  
##  Altres                            :   0     Mean   :41.40   Mean   :2.165  
##  Automoció                        :   0     3rd Qu.:41.41   3rd Qu.:2.178  
##  Ensenyament                       :   0     Max.   :41.46   Max.   :2.221  
##  (Other)                           :   0                                    
##     Codi_Via                      Nom_Via       Codi_Barri   
##  Min.   :   408   G.V. CORTS CATALANES:  55   Min.   : 1.00  
##  1st Qu.: 94809   AV DIAGONAL         :  51   1st Qu.: 7.00  
##  Median :191204   CONSELL DE CENT     :  37   Median :18.00  
##  Mean   :203508   SEPÚLVEDA          :  33   Mean   :24.44  
##  3rd Qu.:292507   BALMES              :  30   3rd Qu.:35.00  
##  Max.   :701686   DIPUTACIÓ          :  29   Max.   :73.00  
##                   (Other)             :2446                  
##                            Nom_Barri    Codi_Districte  
##  la Dreta de l'Eixample         : 219   Min.   : 1.000  
##  el Raval                       : 195   1st Qu.: 2.000  
##  la Vila de Gràcia             : 177   Median : 3.000  
##  l'Antiga Esquerra de l'Eixample: 152   Mean   : 4.435  
##  Sant Antoni                    : 131   3rd Qu.: 7.000  
##  el Barri Gòtic                : 117   Max.   :10.000  
##  (Other)                        :1690                   
##               Nom_Districte
##  Eixample            :740  
##  Ciutat Vella        :416  
##  Sant Martí         :268  
##  Gràcia             :267  
##  Sants-Montjuïc     :238  
##  Sarrià-Sant Gervasi:192  
##  (Other)             :560

Ahora contamos con un número de observaciones más ajustado para realizar el trabajo 2.681: - Oci i cultura: 1.644 - Equipaments culturals i recreatius: 1.037

Aprovechamos y realizamos un nuevo gráfico para entener como es la distribuciones de las actividades por barrio y luego porder ver si éstas se correponden con los barrios donde se localizan la mayor cantidad de alojamientos turísticos.

ggplot(Actividades_Económicas_Turisticas_PB) +
  geom_bar(aes(x=Nom_Barri, fill=Nom_Grup_Activitat))+
  coord_flip()+
  labs(title = "DISTRIBUCION DE LAS ACTIVIDADES ECONOMICAS TURISTICAS EN P.B.",
         subtitle = "Barcelona",
         caption ="Fuente:https://opendata-ajuntament.barcelona.cat/es/",
         x = "BARRIOS",
         y = "TIPO DE ACTIVIDAD",
         fill = "TIPO DE ACTIVIDAD ECONOMICA")

5- Cargamos el plano de de la ciudad de Barcelona y lo ploteamos para verificar.

Barcelona_Poligonos <- st_read("00_Bcn_Unidades_Administrativas_Poligonos.json")
## Reading layer `00_Bcn_Unidades_Administrativas_Poligonos' from data source `C:\Users\ELEONORA\Documents\utdt\INSTRUMENTOS DE ANALISIS TERRITORIAL I\FINAL\00_Bcn_Unidades_Administrativas_Poligonos.json' using driver `GeoJSON'
## Simple feature collection with 1501 features and 35 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 420812.5 ymin: 4574282 xmax: 435480.4 ymax: 4591066
## projected CRS:  ETRS89 / UTM zone 31N
ggplot() +
  geom_sf(data = Barcelona_Poligonos) 

Por algún motivo el dataset indica que está ausente de CRS. Esto nos genera un problema para poder continuar y trabajar con el plano de base y luego articular información sobre el. Para ello, primero seteamos las coordenadas que tienen todos nuestros dataset CRS=25831 y luego transformaremos los dataset que utilizamos para graficar al mercator crs=4326. De este modo estaremos trabajando con el mercator comunmente utilizado.

Barcelona_Poligonos <- st_transform(Barcelona_Poligonos, 4326)

head(Barcelona_Poligonos)
## Simple feature collection with 6 features and 35 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 2.052333 ymin: 41.31704 xmax: 2.228045 ymax: 41.4683
## geographic CRS: WGS 84
##   FID ID_ANNEX ANNEXDESCR ID_TEMA              TEMA_DESCR ID_CONJUNT
## 1   0       01   Grup - I    0104 Unitats Administratives     010411
## 2   1       01   Grup - I    0104 Unitats Administratives     010412
## 3   2       01   Grup - I    0104 Unitats Administratives     010412
## 4   3       01   Grup - I    0104 Unitats Administratives     010412
## 5   4       01   Grup - I    0104 Unitats Administratives     010412
## 6   5       01   Grup - I    0104 Unitats Administratives     010412
##        CONJ_DESCR ID_SUBCONJ      SCONJ_DESC ID_ELEMENT
## 1 Terme Municipal   01041101 Terme Municipal 0104110101
## 2      Districtes   01041201       Districte 0104120101
## 3      Districtes   01041201       Districte 0104120101
## 4      Districtes   01041201       Districte 0104120101
## 5      Districtes   01041201       Districte 0104120101
## 6      Districtes   01041201       Districte 0104120101
##                 ELEM_DESCR    NIVELL                          NDESCR_CA
## 1 Límit de terme municipal ADM_01_PL Límit de terme municipal (polígon)
## 2       Límit de districte ADM_02_PL       Límit de districte (polígon)
## 3       Límit de districte ADM_02_PL       Límit de districte (polígon)
## 4       Límit de districte ADM_02_PL       Límit de districte (polígon)
## 5       Límit de districte ADM_02_PL       Límit de districte (polígon)
## 6       Límit de districte ADM_02_PL       Límit de districte (polígon)
##                                NDESCR_ES                       NDESCR_EN  TERME
## 1 Límite de término municipal (polígono) Municipality boundary (polygon) 080193
## 2          Límite de distrito (polígono)     District boundary (polygon) 080193
## 3          Límite de distrito (polígono)     District boundary (polygon) 080193
## 4          Límite de distrito (polígono)     District boundary (polygon) 080193
## 5          Límite de distrito (polígono)     District boundary (polygon) 080193
## 6          Límite de distrito (polígono)     District boundary (polygon) 080193
##   DISTRICTE BARRI AEB SEC_CENS GRANBARRI ZUA AREA_I LITERAL PERIMETRE      AREA
## 1         -     -   -        -         -   -      -  080193 114036.62 101704974
## 2        01     -   -        -         -   -      -      01  21366.96   4204931
## 3        02     -   -        -         -   -      -      02  13931.64   7464303
## 4        03     -   -        -         -   -      -      03  46711.86  22879850
## 5        04     -   -        -         -   -      -      04  12551.60   6010769
## 6        05     -   -        -         -   -      -      05  35757.40  19915566
##   CODI_UA  TIPUS_UA                 NOM                                  WEB1
## 1  080193     TERME           Barcelona                    http://www.bcn.cat
## 2      01 DISTRICTE        Ciutat Vella        http://www.bcn.cat/ciutatvella
## 3      02 DISTRICTE            Eixample           http://www.bcn.cat/eixample
## 4      03 DISTRICTE      Sants-Montjuïc     http://www.bcn.cat/sants-montjuic
## 5      04 DISTRICTE           Les Corts           http://www.bcn.cat/lescorts
## 6      05 DISTRICTE Sarrià-Sant Gervasi http://www.bcn.cat/sarria-santgervasi
##                                                               WEB2
## 1 http://www.bcn.cat/estadistica/catala/dades/inf/anuari/index.htm
## 2   http://www.bcn.cat/estadistica/catala/dades/guiadt01/index.htm
## 3   http://www.bcn.cat/estadistica/catala/dades/guiadt02/index.htm
## 4   http://www.bcn.cat/estadistica/catala/dades/guiadt03/index.htm
## 5   http://www.bcn.cat/estadistica/catala/dades/guiadt04/index.htm
## 6   http://www.bcn.cat/estadistica/catala/dades/guiadt05/index.htm
##                                                                                          WEB3
## 1                                   http://www.bcn.cat/estadistica/catala/documents/index.htm
## 2          http://www.bcn.cat/estadistica/catala/documents/districtes/01_CiutatVella_2017.pdf
## 3             http://www.bcn.cat/estadistica/catala/documents/districtes/02_Eixample_2017.pdf
## 4  http://www.bcn.cat/estadistica/catala/documents/districtes/03_Sants_Montju%C3%AFc_2017.pdf
## 5             http://www.bcn.cat/estadistica/catala/documents/districtes/04_LesCorts_2017.pdf
## 6 http://www.bcn.cat/estadistica/catala/documents/districtes/05_Sarria_San%20Gervasi_2017.pdf
##   FHEX_COLOR Shape_Leng Shape_Area                       geometry
## 1    #000000  114036.62  101704974 MULTIPOLYGON (((2.187061 41...
## 2    #000000   21366.96    4204931 MULTIPOLYGON (((2.183451 41...
## 3    #000000   13931.64    7464303 MULTIPOLYGON (((2.186895 41...
## 4    #000000   46711.86   22879850 MULTIPOLYGON (((2.148236 41...
## 5    #000000   12551.60    6010769 MULTIPOLYGON (((2.103418 41...
## 6    #000000   35757.40   19915566 MULTIPOLYGON (((2.073126 41...

6- Incorporamos un nuevo dataset específico con los Barrios de Barcelona y lo trasformamos a mercator 4325, para poder trabajar con el resto de los dataset incorporados. Luego ploteamos para verificar si se visualiza de manera correcta.

Barcelona_Barrios <- st_read("00_Barrios.shp")
## Reading layer `00_Barrios' from data source `C:\Users\ELEONORA\Documents\utdt\INSTRUMENTOS DE ANALISIS TERRITORIAL I\FINAL\00_Barrios.shp' using driver `ESRI Shapefile'
## Simple feature collection with 73 features and 0 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 420812.5 ymin: 4574282 xmax: 435480.4 ymax: 4591066
## CRS:            NA
head(Barcelona_Barrios)
## Simple feature collection with 6 features and 0 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 428282.7 ymin: 4578790 xmax: 433088.3 ymax: 4583792
## CRS:            NA
##                         geometry
## 1 MULTIPOLYGON (((430162.2 45...
## 2 MULTIPOLYGON (((431189.9 45...
## 3 MULTIPOLYGON (((432798.7 45...
## 4 MULTIPOLYGON (((430697 4583...
## 5 MULTIPOLYGON (((429554.9 45...
## 6 MULTIPOLYGON (((428907 4580...
Barcelona_Barrios <- st_transform(Barcelona_Poligonos, 4326)

head(Barcelona_Barrios)
## Simple feature collection with 6 features and 35 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 2.052333 ymin: 41.31704 xmax: 2.228045 ymax: 41.4683
## geographic CRS: WGS 84
##   FID ID_ANNEX ANNEXDESCR ID_TEMA              TEMA_DESCR ID_CONJUNT
## 1   0       01   Grup - I    0104 Unitats Administratives     010411
## 2   1       01   Grup - I    0104 Unitats Administratives     010412
## 3   2       01   Grup - I    0104 Unitats Administratives     010412
## 4   3       01   Grup - I    0104 Unitats Administratives     010412
## 5   4       01   Grup - I    0104 Unitats Administratives     010412
## 6   5       01   Grup - I    0104 Unitats Administratives     010412
##        CONJ_DESCR ID_SUBCONJ      SCONJ_DESC ID_ELEMENT
## 1 Terme Municipal   01041101 Terme Municipal 0104110101
## 2      Districtes   01041201       Districte 0104120101
## 3      Districtes   01041201       Districte 0104120101
## 4      Districtes   01041201       Districte 0104120101
## 5      Districtes   01041201       Districte 0104120101
## 6      Districtes   01041201       Districte 0104120101
##                 ELEM_DESCR    NIVELL                          NDESCR_CA
## 1 Límit de terme municipal ADM_01_PL Límit de terme municipal (polígon)
## 2       Límit de districte ADM_02_PL       Límit de districte (polígon)
## 3       Límit de districte ADM_02_PL       Límit de districte (polígon)
## 4       Límit de districte ADM_02_PL       Límit de districte (polígon)
## 5       Límit de districte ADM_02_PL       Límit de districte (polígon)
## 6       Límit de districte ADM_02_PL       Límit de districte (polígon)
##                                NDESCR_ES                       NDESCR_EN  TERME
## 1 Límite de término municipal (polígono) Municipality boundary (polygon) 080193
## 2          Límite de distrito (polígono)     District boundary (polygon) 080193
## 3          Límite de distrito (polígono)     District boundary (polygon) 080193
## 4          Límite de distrito (polígono)     District boundary (polygon) 080193
## 5          Límite de distrito (polígono)     District boundary (polygon) 080193
## 6          Límite de distrito (polígono)     District boundary (polygon) 080193
##   DISTRICTE BARRI AEB SEC_CENS GRANBARRI ZUA AREA_I LITERAL PERIMETRE      AREA
## 1         -     -   -        -         -   -      -  080193 114036.62 101704974
## 2        01     -   -        -         -   -      -      01  21366.96   4204931
## 3        02     -   -        -         -   -      -      02  13931.64   7464303
## 4        03     -   -        -         -   -      -      03  46711.86  22879850
## 5        04     -   -        -         -   -      -      04  12551.60   6010769
## 6        05     -   -        -         -   -      -      05  35757.40  19915566
##   CODI_UA  TIPUS_UA                 NOM                                  WEB1
## 1  080193     TERME           Barcelona                    http://www.bcn.cat
## 2      01 DISTRICTE        Ciutat Vella        http://www.bcn.cat/ciutatvella
## 3      02 DISTRICTE            Eixample           http://www.bcn.cat/eixample
## 4      03 DISTRICTE      Sants-Montjuïc     http://www.bcn.cat/sants-montjuic
## 5      04 DISTRICTE           Les Corts           http://www.bcn.cat/lescorts
## 6      05 DISTRICTE Sarrià-Sant Gervasi http://www.bcn.cat/sarria-santgervasi
##                                                               WEB2
## 1 http://www.bcn.cat/estadistica/catala/dades/inf/anuari/index.htm
## 2   http://www.bcn.cat/estadistica/catala/dades/guiadt01/index.htm
## 3   http://www.bcn.cat/estadistica/catala/dades/guiadt02/index.htm
## 4   http://www.bcn.cat/estadistica/catala/dades/guiadt03/index.htm
## 5   http://www.bcn.cat/estadistica/catala/dades/guiadt04/index.htm
## 6   http://www.bcn.cat/estadistica/catala/dades/guiadt05/index.htm
##                                                                                          WEB3
## 1                                   http://www.bcn.cat/estadistica/catala/documents/index.htm
## 2          http://www.bcn.cat/estadistica/catala/documents/districtes/01_CiutatVella_2017.pdf
## 3             http://www.bcn.cat/estadistica/catala/documents/districtes/02_Eixample_2017.pdf
## 4  http://www.bcn.cat/estadistica/catala/documents/districtes/03_Sants_Montju%C3%AFc_2017.pdf
## 5             http://www.bcn.cat/estadistica/catala/documents/districtes/04_LesCorts_2017.pdf
## 6 http://www.bcn.cat/estadistica/catala/documents/districtes/05_Sarria_San%20Gervasi_2017.pdf
##   FHEX_COLOR Shape_Leng Shape_Area                       geometry
## 1    #000000  114036.62  101704974 MULTIPOLYGON (((2.187061 41...
## 2    #000000   21366.96    4204931 MULTIPOLYGON (((2.183451 41...
## 3    #000000   13931.64    7464303 MULTIPOLYGON (((2.186895 41...
## 4    #000000   46711.86   22879850 MULTIPOLYGON (((2.148236 41...
## 5    #000000   12551.60    6010769 MULTIPOLYGON (((2.103418 41...
## 6    #000000   35757.40   19915566 MULTIPOLYGON (((2.073126 41...
names(Barcelona_Barrios)
##  [1] "FID"        "ID_ANNEX"   "ANNEXDESCR" "ID_TEMA"    "TEMA_DESCR"
##  [6] "ID_CONJUNT" "CONJ_DESCR" "ID_SUBCONJ" "SCONJ_DESC" "ID_ELEMENT"
## [11] "ELEM_DESCR" "NIVELL"     "NDESCR_CA"  "NDESCR_ES"  "NDESCR_EN" 
## [16] "TERME"      "DISTRICTE"  "BARRI"      "AEB"        "SEC_CENS"  
## [21] "GRANBARRI"  "ZUA"        "AREA_I"     "LITERAL"    "PERIMETRE" 
## [26] "AREA"       "CODI_UA"    "TIPUS_UA"   "NOM"        "WEB1"      
## [31] "WEB2"       "WEB3"       "FHEX_COLOR" "Shape_Leng" "Shape_Area"
## [36] "geometry"
ggplot() +
  geom_sf(data = Barcelona_Barrios)

Filtramos y seleccionamos las variables que deseamos conservar.

Barcelona_Barrios <- filter(Barcelona_Barrios, TIPUS_UA == "BARRI")

head(Barcelona_Barrios)
## Simple feature collection with 6 features and 35 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 2.163089 ymin: 41.35773 xmax: 2.199722 ymax: 41.41204
## geographic CRS: WGS 84
##   FID ID_ANNEX ANNEXDESCR ID_TEMA              TEMA_DESCR ID_CONJUNT CONJ_DESCR
## 1  11       01   Grup - I    0104 Unitats Administratives     010413     Barris
## 2  12       01   Grup - I    0104 Unitats Administratives     010413     Barris
## 3  13       01   Grup - I    0104 Unitats Administratives     010413     Barris
## 4  14       01   Grup - I    0104 Unitats Administratives     010413     Barris
## 5  15       01   Grup - I    0104 Unitats Administratives     010413     Barris
## 6  16       01   Grup - I    0104 Unitats Administratives     010413     Barris
##   ID_SUBCONJ SCONJ_DESC ID_ELEMENT     ELEM_DESCR    NIVELL
## 1   01041301      Barri 0104130101 Límit de barri ADM_03_PL
## 2   01041301      Barri 0104130101 Límit de barri ADM_03_PL
## 3   01041301      Barri 0104130101 Límit de barri ADM_03_PL
## 4   01041301      Barri 0104130101 Límit de barri ADM_03_PL
## 5   01041301      Barri 0104130101 Límit de barri ADM_03_PL
## 6   01041301      Barri 0104130101 Límit de barri ADM_03_PL
##                  NDESCR_CA                    NDESCR_ES
## 1 Límit de barri (polígon) Límite de barrrio (polígono)
## 2 Límit de barri (polígon) Límite de barrrio (polígono)
## 3 Límit de barri (polígon) Límite de barrrio (polígono)
## 4 Límit de barri (polígon) Límite de barrrio (polígono)
## 5 Límit de barri (polígon) Límite de barrrio (polígono)
## 6 Límit de barri (polígon) Límite de barrrio (polígono)
##                         NDESCR_EN  TERME DISTRICTE BARRI AEB SEC_CENS GRANBARRI
## 1 Neighborhood boundary (polygon) 080193        01    01   -        -        01
## 2 Neighborhood boundary (polygon) 080193        01    02   -        -        02
## 3 Neighborhood boundary (polygon) 080193        01    03   -        -        03
## 4 Neighborhood boundary (polygon) 080193        01    04   -        -        04
## 5 Neighborhood boundary (polygon) 080193        02    05   -        -        05
## 6 Neighborhood boundary (polygon) 080193        02    06   -        -        06
##   ZUA AREA_I LITERAL PERIMETRE      AREA CODI_UA TIPUS_UA
## 1   -      -      01  5521.647 1100286.1      01    BARRI
## 2   -      -      02  5198.000  815593.9      02    BARRI
## 3   -      -      03 13853.129 1179382.0      03    BARRI
## 4   -      -      04  4664.483 1109668.8      04    BARRI
## 5   -      -      05  4137.329  929355.8      05    BARRI
## 6   -      -      06  4358.094 1041829.3      06    BARRI
##                                     NOM
## 1                              el Raval
## 2                        el Barri Gòtic
## 3                        la Barceloneta
## 4 Sant Pere, Santa Caterina i la Ribera
## 5                         el Fort Pienc
## 6                    la Sagrada Família
##                                                                                               WEB1
## 1                               http://lameva.barcelona.cat/ciutatvella/ca/home/el-barri-del-raval
## 2                                   http://lameva.barcelona.cat/ciutatvella/ca/home/el-barri-gotic
## 3                       http://lameva.barcelona.cat/ciutatvella/ca/home/el-barri-de-la-barceloneta
## 4 http://lameva.barcelona.cat/ciutatvella/ca/home/el-barri-de-sant-pere-santa-caterina-i-la-ribera
## 5                              http://lameva.barcelona.cat/eixample/ca/home/el-barri-de-fort-pienc
## 6                      http://lameva.barcelona.cat/eixample/ca/home/el-barri-de-la-sagrada-familia
##                                                                      WEB2
## 1 http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2017/barri1.pdf
## 2 http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2017/barri2.pdf
## 3 http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2017/barri3.pdf
## 4 http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2017/barri4.pdf
## 5 http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2017/barri5.pdf
## 6 http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2017/barri6.pdf
##                                                                                      WEB3
## 1             http://www.bcn.cat/estadistica/catala/documents/barris/01_CV_Raval_2017.pdf
## 2            http://www.bcn.cat/estadistica/catala/documents/barris/02_CV_BGotic_2017.pdf
## 3       http://www.bcn.cat/estadistica/catala/documents/barris/03_CV_Barceloneta_2017.pdf
## 4 http://www.bcn.cat/estadistica/catala/documents/barris/04_CV_Pere_Cater_Ribera_2017.pdf
## 5         http://www.bcn.cat/estadistica/catala/documents/barris/05_EI_FortPienc_2017.pdf
## 6        http://www.bcn.cat/estadistica/catala/documents/barris/06_EI_SdaFamilia_2017.pdf
##   FHEX_COLOR Shape_Leng Shape_Area                       geometry
## 1    #E66900   5521.647  1100286.1 MULTIPOLYGON (((2.164714 41...
## 2    #E66900   5198.000   815593.9 MULTIPOLYGON (((2.177014 41...
## 3    #E66900  13853.130  1179382.0 MULTIPOLYGON (((2.196229 41...
## 4    #E66900   4664.483  1109668.8 MULTIPOLYGON (((2.183451 41...
## 5    #E66900   4137.329   929355.8 MULTIPOLYGON (((2.183527 41...
## 6    #E66900   4358.094  1041829.3 MULTIPOLYGON (((2.173368 41...
names(Barcelona_Barrios)
##  [1] "FID"        "ID_ANNEX"   "ANNEXDESCR" "ID_TEMA"    "TEMA_DESCR"
##  [6] "ID_CONJUNT" "CONJ_DESCR" "ID_SUBCONJ" "SCONJ_DESC" "ID_ELEMENT"
## [11] "ELEM_DESCR" "NIVELL"     "NDESCR_CA"  "NDESCR_ES"  "NDESCR_EN" 
## [16] "TERME"      "DISTRICTE"  "BARRI"      "AEB"        "SEC_CENS"  
## [21] "GRANBARRI"  "ZUA"        "AREA_I"     "LITERAL"    "PERIMETRE" 
## [26] "AREA"       "CODI_UA"    "TIPUS_UA"   "NOM"        "WEB1"      
## [31] "WEB2"       "WEB3"       "FHEX_COLOR" "Shape_Leng" "Shape_Area"
## [36] "geometry"
Barcelona_Barrios <- select(Barcelona_Barrios, NDESCR_ES, DISTRICTE, BARRI, GRANBARRI, LITERAL, PERIMETRE, AREA, CODI_UA, TIPUS_UA, NOM, Shape_Leng, Shape_Area, geometry)

Unimos los dataset de Barrios y Polígonos

Barcelona_Poligonos_y_Barrios <- st_join(Barcelona_Barrios, Barcelona_Poligonos)
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
head(Barcelona_Poligonos_y_Barrios)
## Simple feature collection with 6 features and 47 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 2.163089 ymin: 41.37037 xmax: 2.183015 ymax: 41.38593
## geographic CRS: WGS 84
##                      NDESCR_ES.x DISTRICTE.x BARRI.x GRANBARRI.x LITERAL.x
## 1   Límite de barrrio (polígono)          01      01          01        01
## 1.1 Límite de barrrio (polígono)          01      01          01        01
## 1.2 Límite de barrrio (polígono)          01      01          01        01
## 1.3 Límite de barrrio (polígono)          01      01          01        01
## 1.4 Límite de barrrio (polígono)          01      01          01        01
## 1.5 Límite de barrrio (polígono)          01      01          01        01
##     PERIMETRE.x  AREA.x CODI_UA.x TIPUS_UA.x    NOM.x Shape_Leng.x Shape_Area.x
## 1      5521.647 1100286        01      BARRI el Raval     5521.647      1100286
## 1.1    5521.647 1100286        01      BARRI el Raval     5521.647      1100286
## 1.2    5521.647 1100286        01      BARRI el Raval     5521.647      1100286
## 1.3    5521.647 1100286        01      BARRI el Raval     5521.647      1100286
## 1.4    5521.647 1100286        01      BARRI el Raval     5521.647      1100286
## 1.5    5521.647 1100286        01      BARRI el Raval     5521.647      1100286
##     FID ID_ANNEX ANNEXDESCR ID_TEMA              TEMA_DESCR ID_CONJUNT
## 1     0       01   Grup - I    0104 Unitats Administratives     010411
## 1.1   1       01   Grup - I    0104 Unitats Administratives     010412
## 1.2   2       01   Grup - I    0104 Unitats Administratives     010412
## 1.3   3       01   Grup - I    0104 Unitats Administratives     010412
## 1.4  11       01   Grup - I    0104 Unitats Administratives     010413
## 1.5  12       01   Grup - I    0104 Unitats Administratives     010413
##          CONJ_DESCR ID_SUBCONJ      SCONJ_DESC ID_ELEMENT
## 1   Terme Municipal   01041101 Terme Municipal 0104110101
## 1.1      Districtes   01041201       Districte 0104120101
## 1.2      Districtes   01041201       Districte 0104120101
## 1.3      Districtes   01041201       Districte 0104120101
## 1.4          Barris   01041301           Barri 0104130101
## 1.5          Barris   01041301           Barri 0104130101
##                   ELEM_DESCR    NIVELL                          NDESCR_CA
## 1   Límit de terme municipal ADM_01_PL Límit de terme municipal (polígon)
## 1.1       Límit de districte ADM_02_PL       Límit de districte (polígon)
## 1.2       Límit de districte ADM_02_PL       Límit de districte (polígon)
## 1.3       Límit de districte ADM_02_PL       Límit de districte (polígon)
## 1.4           Límit de barri ADM_03_PL           Límit de barri (polígon)
## 1.5           Límit de barri ADM_03_PL           Límit de barri (polígon)
##                                NDESCR_ES.y                       NDESCR_EN
## 1   Límite de término municipal (polígono) Municipality boundary (polygon)
## 1.1          Límite de distrito (polígono)     District boundary (polygon)
## 1.2          Límite de distrito (polígono)     District boundary (polygon)
## 1.3          Límite de distrito (polígono)     District boundary (polygon)
## 1.4           Límite de barrrio (polígono) Neighborhood boundary (polygon)
## 1.5           Límite de barrrio (polígono) Neighborhood boundary (polygon)
##      TERME DISTRICTE.y BARRI.y AEB SEC_CENS GRANBARRI.y ZUA AREA_I LITERAL.y
## 1   080193           -       -   -        -           -   -      -    080193
## 1.1 080193          01       -   -        -           -   -      -        01
## 1.2 080193          02       -   -        -           -   -      -        02
## 1.3 080193          03       -   -        -           -   -      -        03
## 1.4 080193          01      01   -        -          01   -      -        01
## 1.5 080193          01      02   -        -          02   -      -        02
##     PERIMETRE.y      AREA.y CODI_UA.y TIPUS_UA.y          NOM.y
## 1    114036.625 101704973.9    080193      TERME      Barcelona
## 1.1   21366.962   4204930.8        01  DISTRICTE   Ciutat Vella
## 1.2   13931.644   7464303.2        02  DISTRICTE       Eixample
## 1.3   46711.857  22879850.1        03  DISTRICTE Sants-Montjuïc
## 1.4    5521.647   1100286.1        01      BARRI       el Raval
## 1.5    5198.000    815593.9        02      BARRI el Barri Gòtic
##                                                                   WEB1
## 1                                                   http://www.bcn.cat
## 1.1                                     http://www.bcn.cat/ciutatvella
## 1.2                                        http://www.bcn.cat/eixample
## 1.3                                  http://www.bcn.cat/sants-montjuic
## 1.4 http://lameva.barcelona.cat/ciutatvella/ca/home/el-barri-del-raval
## 1.5     http://lameva.barcelona.cat/ciutatvella/ca/home/el-barri-gotic
##                                                                        WEB2
## 1          http://www.bcn.cat/estadistica/catala/dades/inf/anuari/index.htm
## 1.1          http://www.bcn.cat/estadistica/catala/dades/guiadt01/index.htm
## 1.2          http://www.bcn.cat/estadistica/catala/dades/guiadt02/index.htm
## 1.3          http://www.bcn.cat/estadistica/catala/dades/guiadt03/index.htm
## 1.4 http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2017/barri1.pdf
## 1.5 http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2017/barri2.pdf
##                                                                                           WEB3
## 1                                    http://www.bcn.cat/estadistica/catala/documents/index.htm
## 1.1         http://www.bcn.cat/estadistica/catala/documents/districtes/01_CiutatVella_2017.pdf
## 1.2            http://www.bcn.cat/estadistica/catala/documents/districtes/02_Eixample_2017.pdf
## 1.3 http://www.bcn.cat/estadistica/catala/documents/districtes/03_Sants_Montju%C3%AFc_2017.pdf
## 1.4                http://www.bcn.cat/estadistica/catala/documents/barris/01_CV_Raval_2017.pdf
## 1.5               http://www.bcn.cat/estadistica/catala/documents/barris/02_CV_BGotic_2017.pdf
##     FHEX_COLOR Shape_Leng.y Shape_Area.y                       geometry
## 1      #000000   114036.625  101704973.9 MULTIPOLYGON (((2.164714 41...
## 1.1    #000000    21366.962    4204930.8 MULTIPOLYGON (((2.164714 41...
## 1.2    #000000    13931.644    7464303.2 MULTIPOLYGON (((2.164714 41...
## 1.3    #000000    46711.857   22879850.0 MULTIPOLYGON (((2.164714 41...
## 1.4    #E66900     5521.647    1100286.1 MULTIPOLYGON (((2.164714 41...
## 1.5    #E66900     5198.000     815593.9 MULTIPOLYGON (((2.164714 41...

7- Realizamos una unión espacial del plano de Barcelona y las actividades económicas seleccionadas. Para ello, debemos convertir el dataset de las Actividades_Económicas_Turísitcas_PB en un dataset espacial.

anyNA(Actividades_Económicas_Turisticas_PB)
## [1] FALSE
Actividades_Económicas_Turisticas_PB_geo <- st_as_sf(Actividades_Económicas_Turisticas_PB, coords = c("Longitud", "Latitud"), 
    crs = 4326)
st_crs(Actividades_Económicas_Turisticas_PB_geo)
## 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["unknown"],
##         AREA["World"],
##         BBOX[-90,-180,90,180]],
##     ID["EPSG",4326]]

Procedemosa realizar la union espacial.

Barcelona_Comercios_Turisticos_PB <- st_join(Actividades_Económicas_Turisticas_PB_geo, Barcelona_Poligonos_y_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
head(Actividades_Económicas_Turisticas_PB_geo)
## Simple feature collection with 6 features and 13 fields
## geometry type:  POINT
## dimension:      XY
## bbox:           xmin: 2.159577 ymin: 41.37264 xmax: 2.177346 ymax: 41.41635
## geographic CRS: WGS 84
##   ï..ID_Bcn_2019 Codi_Principal_Activitat Nom_Principal_Activitat
## 1        1028630                        1                   Actiu
## 2        1014939                        1                   Actiu
## 3        1015061                        1                   Actiu
## 4        1015241                        1                   Actiu
## 5        1015325                        1                   Actiu
## 6        1015324                        1                   Actiu
##   Codi_Sector_Activitat Nom_Sector_Activitat Codi_Grup_Activitat
## 1                     2              Serveis                  10
## 2                     2              Serveis                  10
## 3                     1    Comerç al detall                   5
## 4                     1    Comerç al detall                   5
## 5                     2              Serveis                  10
## 6                     2              Serveis                  10
##                   Nom_Grup_Activitat Codi_Via        Nom_Via Codi_Barri
## 1 Equipaments culturals i recreatius    33702     PTGE BANCA          2
## 2 Equipaments culturals i recreatius   207600        T MELIS         35
## 3                      Oci i cultura   323203     SEPÚLVEDA         10
## 4                      Oci i cultura   254803 PEU DE LA CREU          1
## 5 Equipaments culturals i recreatius    86301     CONCÃ’RDIA         11
## 6 Equipaments culturals i recreatius    86301     CONCÃ’RDIA         11
##         Nom_Barri Codi_Districte   Nom_Districte                  geometry
## 1 el Barri Gòtic              1    Ciutat Vella POINT (2.177346 41.37737)
## 2    el Guinardó              7 Horta-Guinardó POINT (2.172037 41.41635)
## 3     Sant Antoni              2        Eixample  POINT (2.162692 41.3832)
## 4        el Raval              1    Ciutat Vella POINT (2.166278 41.38067)
## 5    el Poble Sec              3 Sants-Montjuïc POINT (2.159577 41.37264)
## 6    el Poble Sec              3 Sants-Montjuïc POINT (2.159633 41.37271)

Ploteamos los datasets por separado:

ggplot() +
  geom_sf(data = Barcelona_Poligonos_y_Barrios) + 
  geom_point(data = Actividades_Económicas_Turisticas_PB,
             aes(x=Longitud, y=Latitud),
             color="red",
             size= 0.008,
             alpha=0.2)

Y ahora ploteamos a partir de unión espacial generada:

ggplot() +
  geom_sf(data = Barcelona_Poligonos_y_Barrios) +
  geom_sf(data = Barcelona_Comercios_Turisticos_PB, mapping = aes(color=Nom_Grup_Activitat), size= 0.02, alpha=0.5) +
  geom_sf_text(data = Barcelona_Poligonos_y_Barrios, aes(label = BARRI.x), size = 3, colour = "black") +
  labs(title = "Actividades Económicas vinculadas al Turismo",
         subtitle = "Barcelona",
         caption= "Fuente: https://opendata-ajuntament.barcelona.cat/es/",
         y="",
         x="")
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

OJOOOO, INTENTAR PONER INDICE DE NUMEROS CON BARRIOS

Se observa la distribución de actividades económicas vinculadas al turismos en el plano. Desde luego, las mismas poseen la misma distribución por barrios como se había observado en el gráfico de barras realizado en el punto 4. Los barrios con mayor actividad turísitca en Barcelona son: - Raval (Barrio 01) - l´Antigua Esquerra de l´Eixample (Barrio 08) - La Dreta de l´Eixample (Barrio 07)- La Villa de Gracia(Barrio 31)

8- Realizamos un mapa coroplético para ver de forma más clara como es la distribución de éstas actividades económicas. El mismo nos servirá para luego poder analizar la relacion de las mismas con los alojamientos turísticos.

Para ello, primero agrupamos las actividades económicas por barrio y le quitamos la geometría, para luego unirlo al dataset de Barcelona_Polígonos_y_Barrios y poder mapear.

Total_Actividades_Económicas_Por_Poligono_y_Barrio <- Barcelona_Comercios_Turisticos_PB %>%
  group_by(Nom_Barri) %>% 
  summarise(total=n())

head(Total_Actividades_Económicas_Por_Poligono_y_Barrio)
## Simple feature collection with 6 features and 2 fields
## geometry type:  MULTIPOINT
## dimension:      XY
## bbox:           xmin: 2.161992 ymin: 41.40245 xmax: 2.219661 ymax: 41.46106
## geographic CRS: WGS 84
## # A tibble: 6 x 3
##   Nom_Barri                total                                        geometry
##   <fct>                    <int>                                <MULTIPOINT [°]>
## 1 Baró de Viver              63 ((2.199332 41.44806), (2.200048 41.44828), (2.~
## 2 Can Baró                  152 ((2.162468 41.41732), (2.162469 41.41426), (2.~
## 3 Can Peguera                 56       ((2.164525 41.43404), (2.16841 41.43342))
## 4 Canyelles                   82       ((2.161992 41.44208), (2.164398 41.4438))
## 5 Ciutat Meridiana            76 ((2.175542 41.46106), (2.175748 41.4598), (2.1~
## 6 Diagonal Mar i el Front~   697 ((2.210191 41.40245), (2.21084 41.40785), (2.2~
Total_Actividades_Económicas_Por_Poligono_y_Barrio_Sin_Geometria <- Total_Actividades_Económicas_Por_Poligono_y_Barrio %>%
  st_set_geometry(NULL)

head(Total_Actividades_Económicas_Por_Poligono_y_Barrio_Sin_Geometria)
## # A tibble: 6 x 2
##   Nom_Barri                                    total
##   <fct>                                        <int>
## 1 Baró de Viver                                  63
## 2 Can Baró                                      152
## 3 Can Peguera                                     56
## 4 Canyelles                                       82
## 5 Ciutat Meridiana                                76
## 6 Diagonal Mar i el Front Marítim del Poblenou   697

Para poder unir los dataset de Total_Actividades_Económicas_Por_Poligono_y_Barrio con Barcelona_Poligonos_y_Barrios, necesitamos contar con una columna que tenga el mismo nombre para unirlas. Por ello, modificamos en Barcelona_Poligonos_y_Barrios el nombre de la columna “NOM.x” por “Nom_Barri”.

Luego seleccionamos y filtramos el dataset resultante.

colnames(Total_Actividades_Económicas_Por_Poligono_y_Barrio)[colnames(Total_Actividades_Económicas_Por_Poligono_y_Barrio) %in% c('NOM.x')] <- paste0(c('Nom_Barri'))

names(Total_Actividades_Económicas_Por_Poligono_y_Barrio)
## [1] "Nom_Barri" "total"     "geometry"
Barcelona_Poligonos_y_Barrios_Sin_Geometria <- Barcelona_Poligonos_y_Barrios
Actividades_Económicas_Por_Poligono_y_Barrio <- Barcelona_Poligonos_y_Barrios %>% 
  st_join(Total_Actividades_Económicas_Por_Poligono_y_Barrio, by="Nom_Barri")
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
head(Actividades_Económicas_Por_Poligono_y_Barrio)
## Simple feature collection with 6 features and 49 fields
## geometry type:  MULTIPOLYGON
## dimension:      XY
## bbox:           xmin: 2.163089 ymin: 41.37037 xmax: 2.183015 ymax: 41.38593
## geographic CRS: WGS 84
##                      NDESCR_ES.x DISTRICTE.x BARRI.x GRANBARRI.x LITERAL.x
## 1   Límite de barrrio (polígono)          01      01          01        01
## 1.1 Límite de barrrio (polígono)          01      01          01        01
## 1.2 Límite de barrrio (polígono)          01      01          01        01
## 1.3 Límite de barrrio (polígono)          01      01          01        01
## 1.4 Límite de barrrio (polígono)          01      01          01        01
## 1.5 Límite de barrrio (polígono)          01      01          01        01
##     PERIMETRE.x  AREA.x CODI_UA.x TIPUS_UA.x    NOM.x Shape_Leng.x Shape_Area.x
## 1      5521.647 1100286        01      BARRI el Raval     5521.647      1100286
## 1.1    5521.647 1100286        01      BARRI el Raval     5521.647      1100286
## 1.2    5521.647 1100286        01      BARRI el Raval     5521.647      1100286
## 1.3    5521.647 1100286        01      BARRI el Raval     5521.647      1100286
## 1.4    5521.647 1100286        01      BARRI el Raval     5521.647      1100286
## 1.5    5521.647 1100286        01      BARRI el Raval     5521.647      1100286
##     FID ID_ANNEX ANNEXDESCR ID_TEMA              TEMA_DESCR ID_CONJUNT
## 1     0       01   Grup - I    0104 Unitats Administratives     010411
## 1.1   1       01   Grup - I    0104 Unitats Administratives     010412
## 1.2   2       01   Grup - I    0104 Unitats Administratives     010412
## 1.3   3       01   Grup - I    0104 Unitats Administratives     010412
## 1.4  11       01   Grup - I    0104 Unitats Administratives     010413
## 1.5  12       01   Grup - I    0104 Unitats Administratives     010413
##          CONJ_DESCR ID_SUBCONJ      SCONJ_DESC ID_ELEMENT
## 1   Terme Municipal   01041101 Terme Municipal 0104110101
## 1.1      Districtes   01041201       Districte 0104120101
## 1.2      Districtes   01041201       Districte 0104120101
## 1.3      Districtes   01041201       Districte 0104120101
## 1.4          Barris   01041301           Barri 0104130101
## 1.5          Barris   01041301           Barri 0104130101
##                   ELEM_DESCR    NIVELL                          NDESCR_CA
## 1   Límit de terme municipal ADM_01_PL Límit de terme municipal (polígon)
## 1.1       Límit de districte ADM_02_PL       Límit de districte (polígon)
## 1.2       Límit de districte ADM_02_PL       Límit de districte (polígon)
## 1.3       Límit de districte ADM_02_PL       Límit de districte (polígon)
## 1.4           Límit de barri ADM_03_PL           Límit de barri (polígon)
## 1.5           Límit de barri ADM_03_PL           Límit de barri (polígon)
##                                NDESCR_ES.y                       NDESCR_EN
## 1   Límite de término municipal (polígono) Municipality boundary (polygon)
## 1.1          Límite de distrito (polígono)     District boundary (polygon)
## 1.2          Límite de distrito (polígono)     District boundary (polygon)
## 1.3          Límite de distrito (polígono)     District boundary (polygon)
## 1.4           Límite de barrrio (polígono) Neighborhood boundary (polygon)
## 1.5           Límite de barrrio (polígono) Neighborhood boundary (polygon)
##      TERME DISTRICTE.y BARRI.y AEB SEC_CENS GRANBARRI.y ZUA AREA_I LITERAL.y
## 1   080193           -       -   -        -           -   -      -    080193
## 1.1 080193          01       -   -        -           -   -      -        01
## 1.2 080193          02       -   -        -           -   -      -        02
## 1.3 080193          03       -   -        -           -   -      -        03
## 1.4 080193          01      01   -        -          01   -      -        01
## 1.5 080193          01      02   -        -          02   -      -        02
##     PERIMETRE.y      AREA.y CODI_UA.y TIPUS_UA.y          NOM.y
## 1    114036.625 101704973.9    080193      TERME      Barcelona
## 1.1   21366.962   4204930.8        01  DISTRICTE   Ciutat Vella
## 1.2   13931.644   7464303.2        02  DISTRICTE       Eixample
## 1.3   46711.857  22879850.1        03  DISTRICTE Sants-Montjuïc
## 1.4    5521.647   1100286.1        01      BARRI       el Raval
## 1.5    5198.000    815593.9        02      BARRI el Barri Gòtic
##                                                                   WEB1
## 1                                                   http://www.bcn.cat
## 1.1                                     http://www.bcn.cat/ciutatvella
## 1.2                                        http://www.bcn.cat/eixample
## 1.3                                  http://www.bcn.cat/sants-montjuic
## 1.4 http://lameva.barcelona.cat/ciutatvella/ca/home/el-barri-del-raval
## 1.5     http://lameva.barcelona.cat/ciutatvella/ca/home/el-barri-gotic
##                                                                        WEB2
## 1          http://www.bcn.cat/estadistica/catala/dades/inf/anuari/index.htm
## 1.1          http://www.bcn.cat/estadistica/catala/dades/guiadt01/index.htm
## 1.2          http://www.bcn.cat/estadistica/catala/dades/guiadt02/index.htm
## 1.3          http://www.bcn.cat/estadistica/catala/dades/guiadt03/index.htm
## 1.4 http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2017/barri1.pdf
## 1.5 http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2017/barri2.pdf
##                                                                                           WEB3
## 1                                    http://www.bcn.cat/estadistica/catala/documents/index.htm
## 1.1         http://www.bcn.cat/estadistica/catala/documents/districtes/01_CiutatVella_2017.pdf
## 1.2            http://www.bcn.cat/estadistica/catala/documents/districtes/02_Eixample_2017.pdf
## 1.3 http://www.bcn.cat/estadistica/catala/documents/districtes/03_Sants_Montju%C3%AFc_2017.pdf
## 1.4                http://www.bcn.cat/estadistica/catala/documents/barris/01_CV_Raval_2017.pdf
## 1.5               http://www.bcn.cat/estadistica/catala/documents/barris/02_CV_BGotic_2017.pdf
##     FHEX_COLOR Shape_Leng.y Shape_Area.y Nom_Barri total
## 1      #000000   114036.625  101704973.9  el Raval 15210
## 1.1    #000000    21366.962    4204930.8  el Raval 15210
## 1.2    #000000    13931.644    7464303.2  el Raval 15210
## 1.3    #000000    46711.857   22879850.0  el Raval 15210
## 1.4    #E66900     5521.647    1100286.1  el Raval 15210
## 1.5    #E66900     5198.000     815593.9  el Raval 15210
##                           geometry
## 1   MULTIPOLYGON (((2.164714 41...
## 1.1 MULTIPOLYGON (((2.164714 41...
## 1.2 MULTIPOLYGON (((2.164714 41...
## 1.3 MULTIPOLYGON (((2.164714 41...
## 1.4 MULTIPOLYGON (((2.164714 41...
## 1.5 MULTIPOLYGON (((2.164714 41...
names(Actividades_Económicas_Por_Poligono_y_Barrio)
##  [1] "NDESCR_ES.x"  "DISTRICTE.x"  "BARRI.x"      "GRANBARRI.x"  "LITERAL.x"   
##  [6] "PERIMETRE.x"  "AREA.x"       "CODI_UA.x"    "TIPUS_UA.x"   "NOM.x"       
## [11] "Shape_Leng.x" "Shape_Area.x" "FID"          "ID_ANNEX"     "ANNEXDESCR"  
## [16] "ID_TEMA"      "TEMA_DESCR"   "ID_CONJUNT"   "CONJ_DESCR"   "ID_SUBCONJ"  
## [21] "SCONJ_DESC"   "ID_ELEMENT"   "ELEM_DESCR"   "NIVELL"       "NDESCR_CA"   
## [26] "NDESCR_ES.y"  "NDESCR_EN"    "TERME"        "DISTRICTE.y"  "BARRI.y"     
## [31] "AEB"          "SEC_CENS"     "GRANBARRI.y"  "ZUA"          "AREA_I"      
## [36] "LITERAL.y"    "PERIMETRE.y"  "AREA.y"       "CODI_UA.y"    "TIPUS_UA.y"  
## [41] "NOM.y"        "WEB1"         "WEB2"         "WEB3"         "FHEX_COLOR"  
## [46] "Shape_Leng.y" "Shape_Area.y" "Nom_Barri"    "total"        "geometry"
glimpse(Actividades_Económicas_Por_Poligono_y_Barrio)
## Rows: 4,539
## Columns: 50
## $ NDESCR_ES.x  <fct> Límite de barrrio (polígono), Límite de barrrio (políg...
## $ DISTRICTE.x  <fct> 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01...
## $ BARRI.x      <fct> 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01...
## $ GRANBARRI.x  <fct> 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01...
## $ LITERAL.x    <fct> 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01...
## $ PERIMETRE.x  <dbl> 5521.647, 5521.647, 5521.647, 5521.647, 5521.647, 5521...
## $ AREA.x       <dbl> 1100286, 1100286, 1100286, 1100286, 1100286, 1100286, ...
## $ CODI_UA.x    <fct> 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01...
## $ TIPUS_UA.x   <fct> BARRI, BARRI, BARRI, BARRI, BARRI, BARRI, BARRI, BARRI...
## $ NOM.x        <fct> el Raval, el Raval, el Raval, el Raval, el Raval, el R...
## $ Shape_Leng.x <dbl> 5521.647, 5521.647, 5521.647, 5521.647, 5521.647, 5521...
## $ Shape_Area.x <dbl> 1100286, 1100286, 1100286, 1100286, 1100286, 1100286, ...
## $ FID          <int> 0, 1, 2, 3, 11, 12, 17, 20, 21, 22, 84, 85, 86, 87, 88...
## $ ID_ANNEX     <fct> 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01...
## $ ANNEXDESCR   <fct> Grup - I, Grup - I, Grup - I, Grup - I, Grup - I, Grup...
## $ ID_TEMA      <fct> 0104, 0104, 0104, 0104, 0104, 0104, 0104, 0104, 0104, ...
## $ TEMA_DESCR   <fct> Unitats Administratives, Unitats Administratives, Unit...
## $ ID_CONJUNT   <fct> 010411, 010412, 010412, 010412, 010413, 010413, 010413...
## $ CONJ_DESCR   <fct> Terme Municipal, Districtes, Districtes, Districtes, B...
## $ ID_SUBCONJ   <fct> 01041101, 01041201, 01041201, 01041201, 01041301, 0104...
## $ SCONJ_DESC   <fct> Terme Municipal, Districte, Districte, Districte, Barr...
## $ ID_ELEMENT   <fct> 0104110101, 0104120101, 0104120101, 0104120101, 010413...
## $ ELEM_DESCR   <fct> Límit de terme municipal, Límit de districte, Límit de...
## $ NIVELL       <fct> ADM_01_PL, ADM_02_PL, ADM_02_PL, ADM_02_PL, ADM_03_PL,...
## $ NDESCR_CA    <fct> Límit de terme municipal (polígon), Límit de districte...
## $ NDESCR_ES.y  <fct> Límite de término municipal (polígono), Límite de dist...
## $ NDESCR_EN    <fct> Municipality boundary (polygon), District boundary (po...
## $ TERME        <fct> 080193, 080193, 080193, 080193, 080193, 080193, 080193...
## $ DISTRICTE.y  <fct> -, 01, 02, 03, 01, 01, 02, 02, 03, 03, 01, 01, 01, 01,...
## $ BARRI.y      <fct> -, -, -, -, 01, 02, 07, 10, 11, 12, 01, 01, 01, 01, 01...
## $ AEB          <fct> -, -, -, -, -, -, -, -, -, -, 001, 002, 003, 004, 005,...
## $ SEC_CENS     <fct> -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, ...
## $ GRANBARRI.y  <fct> -, -, -, -, 01, 02, 07, 10, 11, 12, -, -, -, -, -, -, ...
## $ ZUA          <fct> -, -, -, -, -, -, -, -, -, -, 01, 01, 01, 01, 02, 02, ...
## $ AREA_I       <fct> -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, -, ...
## $ LITERAL.y    <fct> 080193, 01, 02, 03, 01, 02, 07, 10, 11, 12, 001, 002, ...
## $ PERIMETRE.y  <dbl> 114036.625, 21366.962, 13931.644, 46711.857, 5521.647,...
## $ AREA.y       <dbl> 101704973.85, 4204930.81, 7464303.22, 22879850.05, 110...
## $ CODI_UA.y    <fct> 080193, 01, 02, 03, 01, 02, 07, 10, 11, 12,  ,  ,  ,  ...
## $ TIPUS_UA.y   <fct> TERME, DISTRICTE, DISTRICTE, DISTRICTE, BARRI, BARRI, ...
## $ NOM.y        <fct> Barcelona, Ciutat Vella, Eixample, Sants-Montjuïc, el ...
## $ WEB1         <fct> http://www.bcn.cat, http://www.bcn.cat/ciutatvella, ht...
## $ WEB2         <fct> http://www.bcn.cat/estadistica/catala/dades/inf/anuari...
## $ WEB3         <fct> http://www.bcn.cat/estadistica/catala/documents/index....
## $ FHEX_COLOR   <fct> #000000, #000000, #000000, #000000, #E66900, #E66900, ...
## $ Shape_Leng.y <dbl> 114036.625, 21366.962, 13931.644, 46711.857, 5521.647,...
## $ Shape_Area.y <dbl> 101704973.95, 4204930.80, 7464303.21, 22879850.05, 110...
## $ Nom_Barri    <fct> el Raval, el Raval, el Raval, el Raval, el Raval, el R...
## $ total        <int> 15210, 15210, 15210, 15210, 15210, 15210, 15210, 15210...
## $ geometry     <MULTIPOLYGON [°]> MULTIPOLYGON (((2.164714 41..., MULTIPOLY...

INTENTO IGUALAR NOM.x a Nom_Barri para que el barrio 42 no tenga NA y no quede pintado de gris pero no me sale

FILTRAR Y SELECCIONAR EL DATASET si tenemos tiempo si no lo dejamos como quedo - si no sacamos el “names” que esta en el chunk anterior

ggplot() + 
  geom_sf(data = Actividades_Económicas_Por_Poligono_y_Barrio, aes(fill=total)) + 
  scale_fill_gradient(low="yellow", high="red") +
  geom_sf_text(data = Barcelona_Poligonos_y_Barrios, aes(label = BARRI.x), size = 3, colour = "black") +
  labs(title = "Distribución Actividades Económicas Vinculadas Al Turismo, Por Barrio",
         subtitle = "Barcelona",
         caption= "Fuente: https://opendata-ajuntament.barcelona.cat/es/",
         y="",
         x="")
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

9- Ubicamos en el plano los alojamientos turísticos.

ggplot() +
  geom_sf(data = Barcelona_Poligonos_y_Barrios) +
  geom_point(data = Alojamientos_Unificados,
             aes(x=LONGITUD, y=LATITUD),
             color="red",
             size= 1,
             alpha=0.2) +
  geom_sf_text(data = Barcelona_Poligonos_y_Barrios, aes(label = BARRI.x), size = 3, colour = "black") +
  labs(title = "Distribución Alojamientos Turísticos, Por Barrio",
         subtitle = "Barcelona",
         caption= "Fuente: https://opendata-ajuntament.barcelona.cat/es/",
         y="",
         x="")
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

Realizamos un gráfico de barras para ver la distribución de los alojamientos por barrio.

ggplot(Alojamientos_Unificados) +
  geom_bar(aes(x=NUM_BARRI, fill=X2N_NIVELL))+
  coord_flip()+
  labs(title = "Distribución De Alojamientos",
         subtitle = "Barcelona",
         caption ="Fuente:https://opendata-ajuntament.barcelona.cat/es/",
         x = "BARRIOS",
         y = "TIPO DE ALOJAMIENTO",
         fill = "TIPO DE ALOJAMIENTO")

10-Habiendo analizado los mapas y graficos anteriores podemos concluir que el Barrio 7, llamado ‘la Dreta de l’Eixample’ es de los que mas actividades turisticas concentran, asi como alojamientos turisticos tambien. De todos modos lo verificamos obsrvando el dataset de Actividades economicas .

Total_Actividades_Económicas_Por_Poligono_y_Barrio
## Simple feature collection with 72 features and 2 fields
## geometry type:  GEOMETRY
## dimension:      XY
## bbox:           xmin: 2.090932 ymin: 41.35257 xmax: 2.220659 ymax: 41.46273
## geographic CRS: WGS 84
## # A tibble: 72 x 3
##    Nom_Barri                total                                       geometry
##    <fct>                    <int>                               <MULTIPOINT [°]>
##  1 Baró de Viver              63 ((2.199332 41.44806), (2.200048 41.44828), (2~
##  2 Can Baró                  152 ((2.162468 41.41732), (2.162469 41.41426), (2~
##  3 Can Peguera                 56      ((2.164525 41.43404), (2.16841 41.43342))
##  4 Canyelles                   82      ((2.161992 41.44208), (2.164398 41.4438))
##  5 Ciutat Meridiana            76 ((2.175542 41.46106), (2.175748 41.4598), (2.~
##  6 Diagonal Mar i el Front~   697 ((2.210191 41.40245), (2.21084 41.40785), (2.~
##  7 el Baix Guinardó         1656 ((2.163337 41.41129), (2.164398 41.41136), (2~
##  8 el Barri Gòtic           6552 ((2.170712 41.385), (2.171266 41.38471), (2.1~
##  9 el Besòs i el Maresme     616 ((2.21034 41.41885), (2.210687 41.42054), (2.~
## 10 el Bon Pastor             1104 ((2.198065 41.44125), (2.198102 41.43919), (2~
## # ... with 62 more rows

OJO!! ESTO QUE VIENE AHORA LO SACARAIA, A MENOS QUE SE TE OCURRA HACER ALGO CON LOS CENTROIDES DE TOOOODOS LOS BARRIOS!!!!

centroides_barrios <- Barcelona_Barrios %>%
  st_centroid()
## Warning in st_centroid.sf(.): st_centroid assumes attributes are constant over
## geometries of x
## Warning in st_centroid.sfc(st_geometry(x), of_largest_polygon =
## of_largest_polygon): st_centroid does not give correct centroids for longitude/
## latitude data
ggplot()+
  geom_sf(data=Barcelona_Barrios, fill="gray")+
  geom_sf(data=centroides_barrios, color="blue", shape=1, stroke=1, size=0.4)+
  labs(title = "Barrios de la Ciudad de Barcelona",
         subtitle = "Ubicación de los centroides",
         caption= "Fuente:https://opendata-ajuntament.barcelona.cat/es/")+
  theme_minimal()

Elegimos el Barrio 7 , para analizar en torno a el mismo que alojamientos quedarian dentro de un area de influencia, que permita acceder al mismo caminando un maximo de 30’, ya que al ser una ciudad turistica y al estar analizando actividades y alojamientos turisticos consideramos que es una de las formas mas utilizadas para trasladarse y conocer la ciudad. Para ello lo graficamos y luego calculamos el centroide del poligono que lo conforma y luego elegimos 4 puntos al azar dentro del mismo ya que tiene una superficie considerable.

Barrio_7 <- Barcelona_Barrios %>% 
                   filter(NOM == "la Dreta de l'Eixample") %>% 
                   st_transform(4326)
leaflet (Barrio_7) %>% 
  addProviderTiles(providers$CartoDB.Positron) %>%
  addPolygons()
centroide_Barrio_7 <- st_centroid(Barrio_7)
## Warning in st_centroid.sf(Barrio_7): st_centroid assumes attributes are constant
## over geometries of x
## Warning in st_centroid.sfc(st_geometry(x), of_largest_polygon =
## of_largest_polygon): st_centroid does not give correct centroids for longitude/
## latitude data
set.seed(1)
puntos_Barrio_7 <- st_sample(Barrio_7,size = 4)
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
leaflet() %>% 
  addTiles %>% 
  addPolygons(data=Barrio_7 %>% st_transform(4326)) %>% 
  addCircleMarkers(data=puntos_Barrio_7 %>% st_transform(4326), color='red') %>% 
  addCircleMarkers(data=centroide_Barrio_7 %>% st_transform(4326),color ='yellow') 

En el grafico anterior graficamos el centroide y los 4 puntos detro del barrio elegido. Con la ayuda de la libreria hereR vamos a calcular el area de influencia del poligono, para llegar caminando en menos de 30’.

library(hereR)
set_key("QBGpS7_ehdHmrZMdnmtvqSLFpHJElLvTCUqKVz6n3L4")
puntos_Barrio_7SF <- st_as_sf(puntos_Barrio_7)
class(puntos_Barrio_7SF)
## [1] "sf"         "data.frame"
isoCronaCentroide <- isoline(centroide_Barrio_7,mode = "pedestrian",range = 60*30)
leaflet(isoCronaCentroide) %>% 
  addTiles() %>% 
  addPolygons(data=Barrio_7 %>% st_transform(4326)) %>% 
  addPolygons()

En este grafico, podemos observar el area que abarca todos los puntos desde los cuales no se tardaria mas que 30’ en llegar al centroide del poligono del Barrio 7.

map(c(1:5),function(x) x+5)
## [[1]]
## [1] 6
## 
## [[2]]
## [1] 7
## 
## [[3]]
## [1] 8
## 
## [[4]]
## [1] 9
## 
## [[5]]
## [1] 10
isocronaPuntos <- map(1:nrow(puntos_Barrio_7SF),
                         function(x) { isoline(puntos_Barrio_7SF[x,],mode = "pedestrian",range = 60*30) })
isocronaPuntos <- do.call("rbind",isocronaPuntos)
leaflet(isocronaPuntos) %>% 
  addTiles() %>% 
  addPolygons(data=Barrio_7 %>% st_transform(4326)) %>% 
  addPolygons()

Y en este otro podemos observar la isolinea que delimita el area desde la que podemos tardar como maximo 30’ hasta llegar a alguno de los puntos elegidos al azar dentro del poligono del barrio.

isocronaPuntos <- st_union(isocronaPuntos)

Ahora realizaremos un grafico que muestre la totalidad de la ciudad de Barcelona,con todos sus barrios y con la ubicacion de los puntos de alojamientos turisticos y las 2 areas de influencia delimitadas en los graficos anteriores, respecto del barrio con mayor concentracion de actividades turisticas.

ggplot() +
  geom_sf(data=Barcelona_Barrios, fill="gray")+
  geom_point(data = Alojamientos_Unificados,
             aes(x=LONGITUD, y=LATITUD),
             color="red",
             size= 1,
             alpha=0.5) +
  geom_sf(data=Barrio_7,fill="white",alpha=0.8) +
  geom_sf(data=isoCronaCentroide, fill="blue",alpha=0.3) +
  geom_sf(data=isocronaPuntos, fill="green", alpha=0.2)+
  geom_sf_text(data = Barcelona_Poligonos_y_Barrios, aes(label = BARRI.x), size = 3, colour = "black") +
  labs(title = "Zona de influencia pedestre del Barrio 7 'la Dreta de l'Eixample' ",
         subtitle = "Barcelona",
         caption= "Fuente:https://opendata-ajuntament.barcelona.cat/es/")+
  theme_void()
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

Calculamos las superficies de dichas areas.

st_area(isoCronaCentroide)
## 7006460 [m^2]
st_area(isocronaPuntos)
## 12367975 [m^2]

Ahora calcularemos las distancias del centroide del barrio mas alejados que contienen algun tipo de alojamiento turistico, respecto del centroide del barrio 7 que tomamos como referencia.Luego calcularemos cuanto tardariamos caminando de un punto a otro.Y luego graficaremos la isolinea de esa distancia caminando, para verificar si efectivamente es el mas alejado.

Barrio_22 <- Barcelona_Barrios %>% 
                   filter(NOM == "Vallvidrera, el Tibidabo i les Planes") %>% 
                   st_transform(4326)
centroide_Barrio_22 <- st_centroid(Barrio_22)
## Warning in st_centroid.sf(Barrio_22): st_centroid assumes attributes are
## constant over geometries of x
## Warning in st_centroid.sfc(st_geometry(x), of_largest_polygon =
## of_largest_polygon): st_centroid does not give correct centroids for longitude/
## latitude data
distancia_7_22 <-st_distance(x = centroide_Barrio_7, y=centroide_Barrio_22)
distancia_7_22
## Units: [m]
##          [,1]
## [1,] 7172.697
viaje_7_22 <- route(origin = centroide_Barrio_22,
               destination = centroide_Barrio_7,
               mode = "pedestrian",
              datetime = as.POSIXct(x = "21/09/2020 18:00:00",format="%d/%m/%Y %H:%M:%S"))
glimpse(viaje_7_22)
## Rows: 1
## Columns: 12
## $ id          <dbl> 1
## $ departure   <dttm> 2020-09-21 18:00:00
## $ origin      <fct> 
## $ arrival     <dttm> 2020-09-21 20:35:44
## $ destination <fct> Carrer de Roger de Llúria
## $ mode        <fct> pedestrian
## $ traffic     <fct> disabled
## $ distance    <int> 9238
## $ baseTime    <int> 9344
## $ travelTime  <int> 9344
## $ co2Emission <dbl> 1.341
## $ geometry    <LINESTRING [°]> LINESTRING (2.090278 41.419...

Aca podemos ver que el tiempo estimado para recorrer lo 9238 mts que separan el centroide del barrio 22 y el del barrio 7 es de 2:35:44 ( 156 min aprox.).

isoCronaCentroide_2 <- isoline(centroide_Barrio_7,mode = "pedestrian",range = 60*156)
leaflet(isoCronaCentroide_2) %>% 
  addTiles() %>% 
  addPolygons(data=Barrio_7 %>% st_transform(4326)) %>% 
  addPolygons()
ggplot() +
  geom_sf(data=Barcelona_Barrios, fill="gray")+
  geom_point(data = Alojamientos_Unificados,
             aes(x=LONGITUD, y=LATITUD),
             color="red",
             size= 1,
             alpha=0.5) +
  geom_sf(data=Barrio_7,fill="white",alpha=0.8) +
  geom_sf(data=isoCronaCentroide_2, fill="blue",alpha=0.3) +
  geom_sf_text(data = Barcelona_Poligonos_y_Barrios, aes(label = BARRI.x), size = 3, colour = "black") +
  labs(title = "Maxima distancia desde un alojamiento turistico hasya el centroide  del Barrio 7 'la Dreta de l'Eixample' ",
         subtitle = "Barcelona",
         caption= "Fuente:https://opendata-ajuntament.barcelona.cat/es/")+
  theme_void()
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

Observando el mapa podemos concluir que no hay ningun alojamiento que se encuentre a mas de 2 h 35’ del centroide del barrio 7, y tambien que si bien el ubicado en el barrio 22 parecia ser el mas lejano y el que mas se iba a tardar, los ubicados en los barrios 16, 17 y 20 se encuentran mas al limite del tiempo establecido.