Trabajo Práctico Final - Instrumentos de Análisis Territorial, MEU

En el presente trabajo pretendemos analizar la relación que existe entre la localizacioñn de los alojamientos turísitcos y el desarrollo de actividades económicas ubicadas en planta baja en la ciudad de Barcelona.

Para ello, seleccionamos diversos datasets de la página oficial del “Servicio de datos abiertos del Ayuntamiento de Barcelona”.

De estos, utilizaremos:

- Censo de actividades económicas en planta baja de la ciudad de Barcelona 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 podemos llegar a utilizar a lo largo del trabajo:

library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ ggplot2 3.3.0     ✓ purrr   0.3.3
## ✓ tibble  2.1.3     ✓ dplyr   0.8.5
## ✓ tidyr   1.0.2     ✓ stringr 1.4.0
## ✓ readr   1.3.1     ✓ 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.7.2, GDAL 2.4.2, PROJ 5.2.0
library(leaflet)
library(wrapr)
## 
## Attaching package: 'wrapr'
## The following object is masked from 'package:dplyr':
## 
##     coalesce
## The following object is masked from 'package:tidyr':
## 
##     unpack
## The following object is masked from 'package:tibble':
## 
##     view
library(osmdata)
## Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
library(tmap)
library(areal)
library(hereR)
library(vip)
## 
## Attaching package: 'vip'
## The following object is masked from 'package:utils':
## 
##     vi
library(ggthemes)
library(spdep)
## Loading required package: sp
## Loading required package: spData
## To access larger datasets in this package, install the spDataLarge
## package with: `install.packages('spDataLarge',
## repos='https://nowosad.github.io/drat/', type='source')`
require(spatialreg)
## Loading required package: spatialreg
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## The following object is masked from 'package:wrapr':
## 
##     unpack
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
## Registered S3 methods overwritten by 'spatialreg':
##   method                   from 
##   residuals.stsls          spdep
##   deviance.stsls           spdep
##   coef.stsls               spdep
##   print.stsls              spdep
##   summary.stsls            spdep
##   print.summary.stsls      spdep
##   residuals.gmsar          spdep
##   deviance.gmsar           spdep
##   coef.gmsar               spdep
##   fitted.gmsar             spdep
##   print.gmsar              spdep
##   summary.gmsar            spdep
##   print.summary.gmsar      spdep
##   print.lagmess            spdep
##   summary.lagmess          spdep
##   print.summary.lagmess    spdep
##   residuals.lagmess        spdep
##   deviance.lagmess         spdep
##   coef.lagmess             spdep
##   fitted.lagmess           spdep
##   logLik.lagmess           spdep
##   fitted.SFResult          spdep
##   print.SFResult           spdep
##   fitted.ME_res            spdep
##   print.ME_res             spdep
##   print.lagImpact          spdep
##   plot.lagImpact           spdep
##   summary.lagImpact        spdep
##   HPDinterval.lagImpact    spdep
##   print.summary.lagImpact  spdep
##   print.sarlm              spdep
##   summary.sarlm            spdep
##   residuals.sarlm          spdep
##   deviance.sarlm           spdep
##   coef.sarlm               spdep
##   vcov.sarlm               spdep
##   fitted.sarlm             spdep
##   logLik.sarlm             spdep
##   anova.sarlm              spdep
##   predict.sarlm            spdep
##   print.summary.sarlm      spdep
##   print.sarlm.pred         spdep
##   as.data.frame.sarlm.pred spdep
##   residuals.spautolm       spdep
##   deviance.spautolm        spdep
##   coef.spautolm            spdep
##   fitted.spautolm          spdep
##   print.spautolm           spdep
##   summary.spautolm         spdep
##   logLik.spautolm          spdep
##   print.summary.spautolm   spdep
##   print.WXImpact           spdep
##   summary.WXImpact         spdep
##   print.summary.WXImpact   spdep
##   predict.SLX              spdep
## 
## Attaching package: 'spatialreg'
## The following objects are masked from 'package:spdep':
## 
##     anova.sarlm, as_dgRMatrix_listw, as_dsCMatrix_I, as_dsCMatrix_IrW,
##     as_dsTMatrix_listw, as.spam.listw, bptest.sarlm, can.be.simmed,
##     cheb_setup, coef.gmsar, coef.sarlm, coef.spautolm, coef.stsls,
##     create_WX, deviance.gmsar, deviance.sarlm, deviance.spautolm,
##     deviance.stsls, do_ldet, eigen_pre_setup, eigen_setup, eigenw,
##     errorsarlm, fitted.gmsar, fitted.ME_res, fitted.sarlm,
##     fitted.SFResult, fitted.spautolm, get.ClusterOption,
##     get.coresOption, get.mcOption, get.VerboseOption,
##     get.ZeroPolicyOption, GMargminImage, GMerrorsar, griffith_sone,
##     gstsls, Hausman.test, HPDinterval.lagImpact, impacts, intImpacts,
##     Jacobian_W, jacobianSetup, l_max, lagmess, lagsarlm, lextrB,
##     lextrS, lextrW, lmSLX, logLik.sarlm, logLik.spautolm, LR.sarlm,
##     LR1.sarlm, LR1.spautolm, LU_prepermutate_setup, LU_setup,
##     Matrix_J_setup, Matrix_setup, mcdet_setup, MCMCsamp, ME, mom_calc,
##     mom_calc_int2, moments_setup, powerWeights, predict.sarlm,
##     predict.SLX, print.gmsar, print.ME_res, print.sarlm,
##     print.sarlm.pred, print.SFResult, print.spautolm, print.stsls,
##     print.summary.gmsar, print.summary.sarlm, print.summary.spautolm,
##     print.summary.stsls, residuals.gmsar, residuals.sarlm,
##     residuals.spautolm, residuals.stsls, sacsarlm, SE_classic_setup,
##     SE_interp_setup, SE_whichMin_setup, set.ClusterOption,
##     set.coresOption, set.mcOption, set.VerboseOption,
##     set.ZeroPolicyOption, similar.listw, spam_setup, spam_update_setup,
##     SpatialFiltering, spautolm, spBreg_err, spBreg_lag, spBreg_sac,
##     stsls, subgraph_eigenw, summary.gmsar, summary.sarlm,
##     summary.spautolm, summary.stsls, trW, vcov.sarlm, Wald1.sarlm
require(splitstackshape)
## Loading required package: splitstackshape

2- Cargamos y observamos los dataset seleccionados relacionados a los alojamientos turisticos:

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ísitcos 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 Àgora 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ísitcos, por lo que decidimos trabajar solamente con los 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.:430974   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                                   
##                                                                 
## 

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

Peniones:

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 Barna House - HB-004705      :  4          
##  Mean   :9.147e+10   Hostal Bèjar - HB-003673            :  4          
##  3rd Qu.:9.940e+10   Hostal Bèjar 2 - HB-003872          :  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.   :426638   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.:430942   3rd Qu.:4582832  
##  Max.   :41.43   Max.   :2.204   Max.   :433494   Max.   :4587119  
##                                                                    
##      X_ED50           Y_ED50           TELEFON_NUM                TELEFON_TIPUS
##  Min.   :426730   Min.   :4580195   934879762: 12                        :  8  
##  1st Qu.:429876   1st Qu.:4581637   932389307: 10   Centraleta           :  6  
##  Median :430606   Median :4582495            :  8   Fax                  : 16  
##  Mean   :430365   Mean   :4582437   932955360:  8   Informació i reserves:  2  
##  3rd Qu.:431034   3rd Qu.:4583033   934526620:  6   Tel.                 :532  
##  Max.   :433586   Max.   :4587320   935510516:  6                              
##                                     (Other)  :514                              
##  TELEFON_INFO_COM HORARI_PERIODE_INICI HORARI_PERIODE_FI HORARI_DIES   
##  Mode:logical     Mode:logical         Mode:logical      Mode:logical  
##  NA's:564         NA's:564             NA's:564          NA's:564      
##                                                                        
##                                                                        
##                                                                        
##                                                                        
##                                                                        
##  HORARI_HORES_INICI HORARI_HORES_FI HORARI_OBSERVACIONS   X3ER_NIVELL 
##  Mode:logical       Mode:logical    Mode:logical                :282  
##  NA's:564           NA's:564        NA's:564            Pensions:282  
##                                                                       
##                                                                       
##                                                                       
##                                                                       
##                                                                       
##     X2N_NIVELL       X1ER_NIVELL     X          
##  Pensions:564   Allotjament:564   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.:431116   3rd Qu.:4582893  
##  Max.   :41.44   Max.   :2.219   Max.   :434702   Max.   :4587834  
##                                                                    
##      X_ED50           Y_ED50           TELEFON_NUM                TELEFON_TIPUS
##  Min.   :425651   Min.   :4575818   932689070: 12   Atenció al client    :  2  
##  1st Qu.:429603   1st Qu.:4581762   900818320: 10   Centraleta           :184  
##  Median :430645   Median :4582324   916008146: 10   Fax                  : 16  
##  Mean   :430443   Mean   :4582546   934922244:  8   Informació           :  8  
##  3rd Qu.:431208   3rd Qu.:4583094   933437167:  6   Informació i reserves: 12  
##  Max.   :434794   Max.   :4588035   932157255:  4   Reserves             : 66  
##                                     (Other)  :834   Tel.                 :596  
##  TELEFON_INFO_COM HORARI_PERIODE_INICI HORARI_PERIODE_FI HORARI_DIES   
##  Mode:logical     Mode:logical         Mode:logical      Mode:logical  
##  NA's:884         NA's:884             NA's:884          NA's:884      
##                                                                        
##                                                                        
##                                                                        
##                                                                        
##                                                                        
##  HORARI_HORES_INICI HORARI_HORES_FI HORARI_OBSERVACIONS         X3ER_NIVELL 
##  Mode:logical       Mode:logical    Mode:logical        4 estrelles   :195  
##  NA's:884           NA's:884        NA's:884            Hotels 4 estr.:195  
##                                                         3 estrelles   :125  
##                                                         Hotels 3 estr.:125  
##                                                         2 estrelles   : 46  
##                                                         Hotels 2 estr.: 46  
##                                                         (Other)       :152  
##   X2N_NIVELL       X1ER_NIVELL     X          
##  Hotels:884   Allotjament:884   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 análisis contamos con un total de 1.290 alojamientos turisticos en 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 Referencia_cadastral
## 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                     
##   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 :1036244   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                                           Nom_Activitat  
##  Min.   :     10     Sense informació                                 :11164  
##  1st Qu.:1000020     Restaurants                                      : 5599  
##  Median :1400003     Sense informació - Havia tingut activitat (rètol): 4276  
##  Mean   :1825614     Serveis a les empreses i oficines                : 3464  
##  3rd Qu.:1700500     Bars   / CIBERCAFÈ                               : 3290  
##  Max.   :9000000     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ÈNCIA            :  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 :1036244   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ÈNCIA            :  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 detalle 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 estan vinculadas 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 con los Polígonos 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 `/Users/ani/Desktop/UTDT - materias/Trimestre 2/02 - MU123 - Instrumentos de Análisis Urbano II/TP Final/TP 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
## CRS:            25831
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
## CRS:            EPSG:4326
##   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 `/Users/ani/Desktop/UTDT - materias/Trimestre 2/02 - MU123 - Instrumentos de Análisis Urbano II/TP Final/TP 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
## CRS:            EPSG:4326
##   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
## CRS:            EPSG:4326
##   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
## CRS:            EPSG:4326
##                      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:
## GEOGCS["WGS 84",
##     DATUM["WGS_1984",
##         SPHEROID["WGS 84",6378137,298.257223563,
##             AUTHORITY["EPSG","7030"]],
##         AUTHORITY["EPSG","6326"]],
##     PRIMEM["Greenwich",0,
##         AUTHORITY["EPSG","8901"]],
##     UNIT["degree",0.0174532925199433,
##         AUTHORITY["EPSG","9122"]],
##     AUTHORITY["EPSG","4326"]]
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
## CRS:            EPSG:4326
##   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)

Procedemos a realizar la unión 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(Barcelona_Comercios_Turisticos_PB)
## Simple feature collection with 6 features and 60 fields
## geometry type:  POINT
## dimension:      XY
## bbox:           xmin: 2.177346 ymin: 41.37737 xmax: 2.177346 ymax: 41.37737
## CRS:            EPSG:4326
##     ID_Bcn_2019 Codi_Principal_Activitat Nom_Principal_Activitat
## 1       1028630                        1                   Actiu
## 1.1     1028630                        1                   Actiu
## 1.2     1028630                        1                   Actiu
## 1.3     1028630                        1                   Actiu
## 1.4     1028630                        1                   Actiu
## 1.5     1028630                        1                   Actiu
##     Codi_Sector_Activitat Nom_Sector_Activitat Codi_Grup_Activitat
## 1                       2              Serveis                  10
## 1.1                     2              Serveis                  10
## 1.2                     2              Serveis                  10
## 1.3                     2              Serveis                  10
## 1.4                     2              Serveis                  10
## 1.5                     2              Serveis                  10
##                     Nom_Grup_Activitat Codi_Via    Nom_Via Codi_Barri
## 1   Equipaments culturals i recreatius    33702 PTGE BANCA          2
## 1.1 Equipaments culturals i recreatius    33702 PTGE BANCA          2
## 1.2 Equipaments culturals i recreatius    33702 PTGE BANCA          2
## 1.3 Equipaments culturals i recreatius    33702 PTGE BANCA          2
## 1.4 Equipaments culturals i recreatius    33702 PTGE BANCA          2
## 1.5 Equipaments culturals i recreatius    33702 PTGE BANCA          2
##          Nom_Barri Codi_Districte Nom_Districte                  NDESCR_ES.x
## 1   el Barri Gòtic              1  Ciutat Vella Límite de barrrio (polígono)
## 1.1 el Barri Gòtic              1  Ciutat Vella Límite de barrrio (polígono)
## 1.2 el Barri Gòtic              1  Ciutat Vella Límite de barrrio (polígono)
## 1.3 el Barri Gòtic              1  Ciutat Vella Límite de barrrio (polígono)
## 1.4 el Barri Gòtic              1  Ciutat Vella Límite de barrrio (polígono)
## 1.5 el Barri Gòtic              1  Ciutat Vella Límite de barrrio (polígono)
##     DISTRICTE.x BARRI.x GRANBARRI.x LITERAL.x PERIMETRE.x   AREA.x CODI_UA.x
## 1            01      02          02        02        5198 815593.9        02
## 1.1          01      02          02        02        5198 815593.9        02
## 1.2          01      02          02        02        5198 815593.9        02
## 1.3          01      02          02        02        5198 815593.9        02
## 1.4          01      02          02        02        5198 815593.9        02
## 1.5          01      02          02        02        5198 815593.9        02
##     TIPUS_UA.x          NOM.x Shape_Leng.x Shape_Area.x FID ID_ANNEX ANNEXDESCR
## 1        BARRI el Barri Gòtic         5198     815593.9   0       01   Grup - I
## 1.1      BARRI el Barri Gòtic         5198     815593.9   1       01   Grup - I
## 1.2      BARRI el Barri Gòtic         5198     815593.9   2       01   Grup - I
## 1.3      BARRI el Barri Gòtic         5198     815593.9  11       01   Grup - I
## 1.4      BARRI el Barri Gòtic         5198     815593.9  12       01   Grup - I
## 1.5      BARRI el Barri Gòtic         5198     815593.9  13       01   Grup - I
##     ID_TEMA              TEMA_DESCR ID_CONJUNT      CONJ_DESCR ID_SUBCONJ
## 1      0104 Unitats Administratives     010411 Terme Municipal   01041101
## 1.1    0104 Unitats Administratives     010412      Districtes   01041201
## 1.2    0104 Unitats Administratives     010412      Districtes   01041201
## 1.3    0104 Unitats Administratives     010413          Barris   01041301
## 1.4    0104 Unitats Administratives     010413          Barris   01041301
## 1.5    0104 Unitats Administratives     010413          Barris   01041301
##          SCONJ_DESC ID_ELEMENT               ELEM_DESCR    NIVELL
## 1   Terme Municipal 0104110101 Límit de terme municipal ADM_01_PL
## 1.1       Districte 0104120101       Límit de districte ADM_02_PL
## 1.2       Districte 0104120101       Límit de districte ADM_02_PL
## 1.3           Barri 0104130101           Límit de barri ADM_03_PL
## 1.4           Barri 0104130101           Límit de barri ADM_03_PL
## 1.5           Barri 0104130101           Límit de barri ADM_03_PL
##                              NDESCR_CA                            NDESCR_ES.y
## 1   Límit de terme municipal (polígon) Límite de término municipal (polígono)
## 1.1       Límit de districte (polígon)          Límite de distrito (polígono)
## 1.2       Límit de districte (polígon)          Límite de distrito (polígono)
## 1.3           Límit de barri (polígon)           Límite de barrrio (polígono)
## 1.4           Límit de barri (polígon)           Límite de barrrio (polígono)
## 1.5           Límit de barri (polígon)           Límite de barrrio (polígono)
##                           NDESCR_EN  TERME DISTRICTE.y BARRI.y AEB SEC_CENS
## 1   Municipality boundary (polygon) 080193           -       -   -        -
## 1.1     District boundary (polygon) 080193          01       -   -        -
## 1.2     District boundary (polygon) 080193          02       -   -        -
## 1.3 Neighborhood boundary (polygon) 080193          01      01   -        -
## 1.4 Neighborhood boundary (polygon) 080193          01      02   -        -
## 1.5 Neighborhood boundary (polygon) 080193          01      03   -        -
##     GRANBARRI.y ZUA AREA_I LITERAL.y PERIMETRE.y      AREA.y CODI_UA.y
## 1             -   -      -    080193  114036.625 101704973.9    080193
## 1.1           -   -      -        01   21366.962   4204930.8        01
## 1.2           -   -      -        02   13931.644   7464303.2        02
## 1.3          01   -      -        01    5521.647   1100286.1        01
## 1.4          02   -      -        02    5198.000    815593.9        02
## 1.5          03   -      -        03   13853.129   1179382.0        03
##     TIPUS_UA.y          NOM.y
## 1        TERME      Barcelona
## 1.1  DISTRICTE   Ciutat Vella
## 1.2  DISTRICTE       Eixample
## 1.3      BARRI       el Raval
## 1.4      BARRI el Barri Gòtic
## 1.5      BARRI la Barceloneta
##                                                                           WEB1
## 1                                                           http://www.bcn.cat
## 1.1                                             http://www.bcn.cat/ciutatvella
## 1.2                                                http://www.bcn.cat/eixample
## 1.3         http://lameva.barcelona.cat/ciutatvella/ca/home/el-barri-del-raval
## 1.4             http://lameva.barcelona.cat/ciutatvella/ca/home/el-barri-gotic
## 1.5 http://lameva.barcelona.cat/ciutatvella/ca/home/el-barri-de-la-barceloneta
##                                                                        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/inf/barris/a2017/barri1.pdf
## 1.4 http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2017/barri2.pdf
## 1.5 http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2017/barri3.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/barris/01_CV_Raval_2017.pdf
## 1.4       http://www.bcn.cat/estadistica/catala/documents/barris/02_CV_BGotic_2017.pdf
## 1.5  http://www.bcn.cat/estadistica/catala/documents/barris/03_CV_Barceloneta_2017.pdf
##     FHEX_COLOR Shape_Leng.y Shape_Area.y                  geometry
## 1      #000000   114036.625  101704973.9 POINT (2.177346 41.37737)
## 1.1    #000000    21366.962    4204930.8 POINT (2.177346 41.37737)
## 1.2    #000000    13931.644    7464303.2 POINT (2.177346 41.37737)
## 1.3    #E66900     5521.647    1100286.1 POINT (2.177346 41.37737)
## 1.4    #E66900     5198.000     815593.9 POINT (2.177346 41.37737)
## 1.5    #E66900    13853.130    1179382.0 POINT (2.177346 41.37737)

Ploteamos con los dataset 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)

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 = 4, 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

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 que relación tienen 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
## CRS:            EPSG:4326
## # 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"
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
## CRS:            EPSG:4326
##                      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...
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 = 4, 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

Observamos que en el Barrio 42, “la Clota”, queda gris, lo que significaría que no tendría actividades económicas vinculadas al turismo, en el dataset no aparecen datos “NA”.

Ahora realizamos el mapa de coropletas contemplando la densidad de actividades económicas por barrio, para verificar si los barrios de mayor superficie tienen la mayor cantidad de actividades económicas:

ggplot() + 
  geom_sf(data = Actividades_Económicas_Por_Poligono_y_Barrio, aes(fill=total/Shape_Area.x)) + 
  scale_fill_gradient(low="yellow", high="red") +
  geom_sf_text(data = Barcelona_Poligonos_y_Barrios, aes(label = BARRI.x), size = 4, colour = "black") +
  labs(title = "Distribución Actividades Económicas Vinculadas Al Turismo, Total Actividades/Área 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

Observamos que la distribución de las actividades económicas vinculadas al turismo varía, pero no en gran medida. Éstas como vimos en el mapa anterior, siguen aglomeradas en torno a los Barrios 08 “l´Antigua Esquerra de l´Eixample” y 07 “La Dreta de l´Eixample”, aunque se distingue con mayor preponderancia el Barrio 10 “Sant Antoni”, que si analizamos es el barrio que en gráfico de barras se posiciona en el quinto lugar con mayor cantidad de actividades económicas.

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 = 4, 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- Nuevamente realizamos un mapa de coropletas para ver como se distribuyen los alojamientos por barrio en Barcelona. Realizamos el mismo procedimiento que hicimos para las actividades económicas.

Primero realizamos una unión espacial del plano de Barcelona y los alojamientos turísticos. Para ello, debemos convertir el dataset de los Alojamientos_Unificados en un dataset espacial.

anyNA(Alojamientos_Unificados)
## [1] FALSE
Alojamientos_Unificados_geo <- st_as_sf(Alojamientos_Unificados, coords = c("LONGITUD", "LATITUD"), 
    crs = 4326)
st_crs(Alojamientos_Unificados_geo)
## Coordinate Reference System:
##   User input: EPSG:4326 
##   wkt:
## GEOGCS["WGS 84",
##     DATUM["WGS_1984",
##         SPHEROID["WGS 84",6378137,298.257223563,
##             AUTHORITY["EPSG","7030"]],
##         AUTHORITY["EPSG","6326"]],
##     PRIMEM["Greenwich",0,
##         AUTHORITY["EPSG","8901"]],
##     UNIT["degree",0.0174532925199433,
##         AUTHORITY["EPSG","9122"]],
##     AUTHORITY["EPSG","4326"]]

Unificamos los data set de Alojamientos_Unificados con Barcelona_Poígonos_y_Barrios.

Barcelona_Alojamientos_Turisticos <- st_join(Alojamientos_Unificados_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(Barcelona_Alojamientos_Turisticos)
## Simple feature collection with 6 features and 59 fields
## geometry type:  POINT
## dimension:      XY
## bbox:           xmin: 2.175867 ymin: 41.37889 xmax: 2.175867 ymax: 41.37889
## CRS:            EPSG:4326
##     CODI_EQUIPAMENT                               EQUIPAMENT NOM_CARRER
## 1       75990024905 Apartament Turístic Mur-Mar - ATB-000042     Rambla
## 1.1     75990024905 Apartament Turístic Mur-Mar - ATB-000042     Rambla
## 1.2     75990024905 Apartament Turístic Mur-Mar - ATB-000042     Rambla
## 1.3     75990024905 Apartament Turístic Mur-Mar - ATB-000042     Rambla
## 1.4     75990024905 Apartament Turístic Mur-Mar - ATB-000042     Rambla
## 1.5     75990024905 Apartament Turístic Mur-Mar - ATB-000042     Rambla
##     NUM_CARRER_1 NUM_CARRER_2 CODI_BARRI      NUM_BARRI CODI_DISTRICTE
## 1             34           34          2 el Barri Gòtic              1
## 1.1           34           34          2 el Barri Gòtic              1
## 1.2           34           34          2 el Barri Gòtic              1
## 1.3           34           34          2 el Barri Gòtic              1
## 1.4           34           34          2 el Barri Gòtic              1
## 1.5           34           34          2 el Barri Gòtic              1
##     NOM_DISTRICTE X3ER_NIVELL          X2N_NIVELL X1ER_NIVELL
## 1    Ciutat Vella Apartaments Altres allotjaments Allotjament
## 1.1  Ciutat Vella Apartaments Altres allotjaments Allotjament
## 1.2  Ciutat Vella Apartaments Altres allotjaments Allotjament
## 1.3  Ciutat Vella Apartaments Altres allotjaments Allotjament
## 1.4  Ciutat Vella Apartaments Altres allotjaments Allotjament
## 1.5  Ciutat Vella Apartaments Altres allotjaments Allotjament
##                      NDESCR_ES.x DISTRICTE.x BARRI.x GRANBARRI.x LITERAL.x
## 1   Límite de barrrio (polígono)          01      02          02        02
## 1.1 Límite de barrrio (polígono)          01      02          02        02
## 1.2 Límite de barrrio (polígono)          01      02          02        02
## 1.3 Límite de barrrio (polígono)          01      02          02        02
## 1.4 Límite de barrrio (polígono)          01      02          02        02
## 1.5 Límite de barrrio (polígono)          01      02          02        02
##     PERIMETRE.x   AREA.x CODI_UA.x TIPUS_UA.x          NOM.x Shape_Leng.x
## 1          5198 815593.9        02      BARRI el Barri Gòtic         5198
## 1.1        5198 815593.9        02      BARRI el Barri Gòtic         5198
## 1.2        5198 815593.9        02      BARRI el Barri Gòtic         5198
## 1.3        5198 815593.9        02      BARRI el Barri Gòtic         5198
## 1.4        5198 815593.9        02      BARRI el Barri Gòtic         5198
## 1.5        5198 815593.9        02      BARRI el Barri Gòtic         5198
##     Shape_Area.x FID ID_ANNEX ANNEXDESCR ID_TEMA              TEMA_DESCR
## 1       815593.9   0       01   Grup - I    0104 Unitats Administratives
## 1.1     815593.9   1       01   Grup - I    0104 Unitats Administratives
## 1.2     815593.9   2       01   Grup - I    0104 Unitats Administratives
## 1.3     815593.9  11       01   Grup - I    0104 Unitats Administratives
## 1.4     815593.9  12       01   Grup - I    0104 Unitats Administratives
## 1.5     815593.9  13       01   Grup - I    0104 Unitats Administratives
##     ID_CONJUNT      CONJ_DESCR ID_SUBCONJ      SCONJ_DESC ID_ELEMENT
## 1       010411 Terme Municipal   01041101 Terme Municipal 0104110101
## 1.1     010412      Districtes   01041201       Districte 0104120101
## 1.2     010412      Districtes   01041201       Districte 0104120101
## 1.3     010413          Barris   01041301           Barri 0104130101
## 1.4     010413          Barris   01041301           Barri 0104130101
## 1.5     010413          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 barri ADM_03_PL           Límit de barri (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 barrrio (polígono) Neighborhood 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          01      01   -        -          01   -      -        01
## 1.4 080193          01      02   -        -          02   -      -        02
## 1.5 080193          01      03   -        -          03   -      -        03
##     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    5521.647   1100286.1        01      BARRI       el Raval
## 1.4    5198.000    815593.9        02      BARRI el Barri Gòtic
## 1.5   13853.129   1179382.0        03      BARRI la Barceloneta
##                                                                           WEB1
## 1                                                           http://www.bcn.cat
## 1.1                                             http://www.bcn.cat/ciutatvella
## 1.2                                                http://www.bcn.cat/eixample
## 1.3         http://lameva.barcelona.cat/ciutatvella/ca/home/el-barri-del-raval
## 1.4             http://lameva.barcelona.cat/ciutatvella/ca/home/el-barri-gotic
## 1.5 http://lameva.barcelona.cat/ciutatvella/ca/home/el-barri-de-la-barceloneta
##                                                                        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/inf/barris/a2017/barri1.pdf
## 1.4 http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2017/barri2.pdf
## 1.5 http://www.bcn.cat/estadistica/catala/dades/inf/barris/a2017/barri3.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/barris/01_CV_Raval_2017.pdf
## 1.4       http://www.bcn.cat/estadistica/catala/documents/barris/02_CV_BGotic_2017.pdf
## 1.5  http://www.bcn.cat/estadistica/catala/documents/barris/03_CV_Barceloneta_2017.pdf
##     FHEX_COLOR Shape_Leng.y Shape_Area.y                  geometry
## 1      #000000   114036.625  101704973.9 POINT (2.175867 41.37889)
## 1.1    #000000    21366.962    4204930.8 POINT (2.175867 41.37889)
## 1.2    #000000    13931.644    7464303.2 POINT (2.175867 41.37889)
## 1.3    #E66900     5521.647    1100286.1 POINT (2.175867 41.37889)
## 1.4    #E66900     5198.000     815593.9 POINT (2.175867 41.37889)
## 1.5    #E66900    13853.130    1179382.0 POINT (2.175867 41.37889)

Ahora agrupamos los alojamientos turísticos por barrio y le quitamos la geometría. Después lo unimos al dataset de Barcelona_Polígonos_y_Barrios para poder mapear.

Total_Alojamientos_Turísticos_Por_Poligonos_y_Barrios <- Barcelona_Alojamientos_Turisticos %>%
  group_by(NUM_BARRI) %>% 
  summarise(total=n())

head(Total_Alojamientos_Turísticos_Por_Poligonos_y_Barrios)
## Simple feature collection with 6 features and 2 fields
## geometry type:  GEOMETRY
## dimension:      XY
## bbox:           xmin: 2.167285 ymin: 41.37889 xmax: 2.186572 ymax: 41.42211
## CRS:            EPSG:4326
## # A tibble: 6 x 3
##   NUM_BARRI             total                                           geometry
##   <fct>                 <int>                                     <GEOMETRY [°]>
## 1 el Barri Gòtic         3192 MULTIPOINT ((2.174942 41.38101), (2.175294 41.379…
## 2 el Camp d'en Grassot…   510                          POINT (2.167285 41.40646)
## 3 el Camp de l'Arpa de…  1848 MULTIPOINT ((2.179153 41.40993), (2.179238 41.411…
## 4 el Clot                 456                          POINT (2.186572 41.40696)
## 5 el Congrés i els Ind…   312                          POINT (2.181182 41.42211)
## 6 el Fort Pienc          1491 MULTIPOINT ((2.177451 41.396), (2.177717 41.39363…
Total_Alojamientos_Turísticos_Por_Poligonos_y_Barrios_Sin_Geometria <- Total_Alojamientos_Turísticos_Por_Poligonos_y_Barrios %>% 
   st_set_geometry(NULL)

head(Total_Alojamientos_Turísticos_Por_Poligonos_y_Barrios_Sin_Geometria)
## # A tibble: 6 x 2
##   NUM_BARRI                          total
##   <fct>                              <int>
## 1 el Barri Gòtic                      3192
## 2 el Camp d'en Grassot i Gràcia Nova   510
## 3 el Camp de l'Arpa del Clot          1848
## 4 el Clot                              456
## 5 el Congrés i els Indians             312
## 6 el Fort Pienc                       1491

Como en el caso anterior para poder unir los dataset Total_Alojamientos_Turísticos_Por_Poligono_y_Barrio con Barcelona_Poligonos_y_Barrios, necesitamos que una columna de ambos dataset tenga el mismo nombre. Por ello, modificamos en Barcelona_Poligonos_y_Barrios el nombre de la columna “NOM.x” por “NUM_BARRI”.

colnames(Barcelona_Poligonos_y_Barrios)[colnames(Barcelona_Poligonos_y_Barrios) %in% c('NOM.x')] <- paste0(c('NUM_BARRI'))

names(Barcelona_Poligonos_y_Barrios)
##  [1] "NDESCR_ES.x"  "DISTRICTE.x"  "BARRI.x"      "GRANBARRI.x"  "LITERAL.x"   
##  [6] "PERIMETRE.x"  "AREA.x"       "CODI_UA.x"    "TIPUS_UA.x"   "NUM_BARRI"   
## [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" "geometry"
Alojamientos_Turísticos_Por_Poligono_y_Barrio <- Barcelona_Poligonos_y_Barrios %>% 
  st_join(Total_Alojamientos_Turísticos_Por_Poligonos_y_Barrios, by="NUM_BARRI")
## although coordinates are longitude/latitude, st_intersects assumes that they are planar
head(Alojamientos_Turísticos_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
## CRS:            EPSG:4326
##                      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 NUM_BARRI.x Shape_Leng.x
## 1      5521.647 1100286        01      BARRI    el Raval     5521.647
## 1.1    5521.647 1100286        01      BARRI    el Raval     5521.647
## 1.2    5521.647 1100286        01      BARRI    el Raval     5521.647
## 1.3    5521.647 1100286        01      BARRI    el Raval     5521.647
## 1.4    5521.647 1100286        01      BARRI    el Raval     5521.647
## 1.5    5521.647 1100286        01      BARRI    el Raval     5521.647
##     Shape_Area.x FID ID_ANNEX ANNEXDESCR ID_TEMA              TEMA_DESCR
## 1        1100286   0       01   Grup - I    0104 Unitats Administratives
## 1.1      1100286   1       01   Grup - I    0104 Unitats Administratives
## 1.2      1100286   2       01   Grup - I    0104 Unitats Administratives
## 1.3      1100286   3       01   Grup - I    0104 Unitats Administratives
## 1.4      1100286  11       01   Grup - I    0104 Unitats Administratives
## 1.5      1100286  12       01   Grup - I    0104 Unitats Administratives
##     ID_CONJUNT      CONJ_DESCR ID_SUBCONJ      SCONJ_DESC ID_ELEMENT
## 1       010411 Terme Municipal   01041101 Terme Municipal 0104110101
## 1.1     010412      Districtes   01041201       Districte 0104120101
## 1.2     010412      Districtes   01041201       Districte 0104120101
## 1.3     010412      Districtes   01041201       Districte 0104120101
## 1.4     010413          Barris   01041301           Barri 0104130101
## 1.5     010413          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 NUM_BARRI.y total
## 1      #000000   114036.625  101704973.9    el Raval  3276
## 1.1    #000000    21366.962    4204930.8    el Raval  3276
## 1.2    #000000    13931.644    7464303.2    el Raval  3276
## 1.3    #000000    46711.857   22879850.0    el Raval  3276
## 1.4    #E66900     5521.647    1100286.1    el Raval  3276
## 1.5    #E66900     5198.000     815593.9    el Raval  3276
##                           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...

Ahora mapeamos los resultados:

ggplot() + 
  geom_sf(data = Alojamientos_Turísticos_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 = 4, colour = "black") +
  labs(title = "Distribución Alojamientos 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

Observamos, como en el gráfico de barras y en el mapa con puntos, la mayor gradiente en el Barrio 07 y notoriamente como desciende a los barrios circundantes. Se distingue un tinte en los Barrios 08, 31, 26 y 18.

Nuevamente realizamos el mapa de coropletas contemplando la densidad de alojamientos por superficie de barrio, para verificar si los como es la distribución de los mismo:

ggplot() + 
  geom_sf(data = Alojamientos_Turísticos_Por_Poligono_y_Barrio, aes(fill=total/Shape_Area.x)) + 
  scale_fill_gradient(low="yellow", high="red") +
  geom_sf_text(data = Barcelona_Poligonos_y_Barrios, aes(label = BARRI.x), size = 4, colour = "black") +
  labs(title = "Distribución Alojamientos Turístico, Total Alojamientos/Área 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

Se verifica que la tendencia de la localización de alojamientos turísitcos en el Barrio 07 es notablemente superior. Aunque, podemos apreciar que los Barrios circundantes toman algo de mayor preponderancia, con un color algo más notable. A su vez, entre éstos surgen los Barrios 01, 02, 05, 06, 10, 19, 28 y 64, que antes no tenían relevancia.

11- Habiendo analizado los mapas y graficos anteriores podemos concluir que el Barrio 07 “la Dreta de l’Eixample” es uno de los barrios que más actividades turisticas concentra, así como alojamientos turísticos. De todos modos lo verificaremos observando 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
## CRS:            EPSG:4326
## # 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

12- Seleccionamos el Barrio 07, para analizar en torno a el mismo que alojamientos quedarían dentro de un area de influencia, que permita acceder al mismo caminando un maximo de 30 minutos, ya que al ser una ciudad turística y al estar analizando actividades y alojamientos vinculadas a dicha dinámica consideramos que es una de las formas más utilizadas para trasladarse y conocer la ciudad. Para ello, lo graficamos y luego calculamos el centroide del poligono que lo conforma. 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 4 puntos al azar dentro 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 minutos.

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 gráfico, podemos observar el área que abarca todos los puntos desde los cuales no se tardaría mas que 30 minutos en llegar al centroide del poligono del Barrio 07.

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()

Por otra parte, en este gráfico podemos observar la isolinea que delimita el área en la que podemos tardar como máximo 30 minutos hasta llegar a alguno de los puntos elegidos al azar dentro del polígono del barrio.

isocronaPuntos <- st_union(isocronaPuntos)

13- A continuación, realizaremos un gráfico que muestre la totalidad de la ciudad de Barcelona, con todos sus barrios y la ubicación de los puntos de alojamientos turísticos con las 2 areas de influencia delimitadas en los gráficos anteriores, respecto del barrio con mayor concentración de actividades turísticas.

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

Ahora, calcularemos las distancias del centroide del barrio más alejado que contiene algún tipo de alojamiento turístico, respecto del centroide del Barrio 07 que tomamos como referencia. Luego calcularemos cuanto tardaríamos caminando de un punto a otro. A continuación, graficaremos la isolinea de esa distancia caminando, para verificar si efectivamente es el más 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)
## Observations: 1
## Variables: 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...

Se puede observar, que el tiempo estimado para recorrer los 9.238 metros que separan el centroide del Barrio 22 del Barrio 07 es de 2:35:44 (156 minutos aproximadamente).

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 ningún alojamiento que se encuentre a mas de 2 horas 35 minutos del centroide del Barrio 07.

14- Estudiaremos la relación que existe entre la localización de las actividades económicas y los alojamientos turísticos en la ciudad de Barcelona. Analizaremos esta relación a partir de una Regresión Lineal, planteareamos como variable dependiente las alojamientos turísitcos e independientes las actividades económicas.

Para ello, primero debemos crear el dataset con la información necesaria unificando: Total_Actividades_Económicas_Por_Polígono_y_Barrio con Total_Alojamientos_Turísitcos_Por_Polígonos_y_Barrios.

Antes debemos agrupar por Código de Barrio para no perder nignún dato.

Actividades Económicas:

Total_Actividades_Económicas_Por_Polígono_y_Barrio_para_RL <- Barcelona_Comercios_Turisticos_PB %>%
  group_by(Codi_Barri, Nom_Barri) %>% 
  summarise(total=n())

head(Total_Actividades_Económicas_Por_Polígono_y_Barrio_para_RL)
## Simple feature collection with 6 features and 3 fields
## geometry type:  MULTIPOINT
## dimension:      XY
## bbox:           xmin: 2.163464 ymin: 41.37092 xmax: 2.19637 ymax: 41.41152
## CRS:            EPSG:4326
## # A tibble: 6 x 4
## # Groups:   Codi_Barri [6]
##   Codi_Barri Nom_Barri          total                                   geometry
##        <int> <fct>              <int>                           <MULTIPOINT [°]>
## 1          1 el Raval           15210 ((2.163464 41.38005), (2.163475 41.38012)…
## 2          2 el Barri Gòtic      6552 ((2.170712 41.385), (2.171266 41.38471), …
## 3          3 la Barceloneta       962 ((2.185805 41.3808), (2.186975 41.38219),…
## 4          4 Sant Pere, Santa …  5304 ((2.173603 41.38884), (2.173865 41.38848)…
## 5          5 el Fort Pienc       3976 ((2.174559 41.39967), (2.175874 41.39961)…
## 6          6 la Sagrada Família  9570 ((2.169478 41.4074), (2.170667 41.40214),…
Total_Actividades_Económicas_Por_Poligono_y_Barrio_Sin_Geometria_para_RL <- Total_Actividades_Económicas_Por_Polígono_y_Barrio_para_RL %>%
  st_set_geometry(NULL)

head(Total_Actividades_Económicas_Por_Poligono_y_Barrio_Sin_Geometria_para_RL)
## # A tibble: 6 x 3
## # Groups:   Codi_Barri [6]
##   Codi_Barri Nom_Barri                             total
##        <int> <fct>                                 <int>
## 1          1 el Raval                              15210
## 2          2 el Barri Gòtic                         6552
## 3          3 la Barceloneta                          962
## 4          4 Sant Pere, Santa Caterina i la Ribera  5304
## 5          5 el Fort Pienc                          3976
## 6          6 la Sagrada Família                     9570
colnames(Total_Actividades_Económicas_Por_Poligono_y_Barrio_Sin_Geometria_para_RL)[colnames(Total_Actividades_Económicas_Por_Poligono_y_Barrio_Sin_Geometria_para_RL) %in% c('total')] <- paste0(c('Total_Actividades_Económicas'))
colnames(Total_Actividades_Económicas_Por_Poligono_y_Barrio_Sin_Geometria_para_RL)[colnames(Total_Actividades_Económicas_Por_Poligono_y_Barrio_Sin_Geometria_para_RL) %in% c('Codi_Barri')] <- paste0(c('CODI_BARRI'))

head(Total_Actividades_Económicas_Por_Poligono_y_Barrio_Sin_Geometria_para_RL)
## # A tibble: 6 x 3
##   CODI_BARRI Nom_Barri                             Total_Actividades_Económicas
##        <int> <fct>                                                        <int>
## 1          1 el Raval                                                     15210
## 2          2 el Barri Gòtic                                                6552
## 3          3 la Barceloneta                                                 962
## 4          4 Sant Pere, Santa Caterina i la Ribera                         5304
## 5          5 el Fort Pienc                                                 3976
## 6          6 la Sagrada Família                                            9570

Alojamientos Turísticos:

Total_Alojamientos_Turisticos_Por_Polígono_y_Barrio_para_RL <- Barcelona_Alojamientos_Turisticos %>%
  group_by(CODI_BARRI) %>%
  summarise(total=n())

head(Total_Alojamientos_Turisticos_Por_Polígono_y_Barrio_para_RL)
## Simple feature collection with 6 features and 2 fields
## geometry type:  GEOMETRY
## dimension:      XY
## bbox:           xmin: 2.170728 ymin: 41.37589 xmax: 2.191125 ymax: 41.40614
## CRS:            EPSG:4326
## # A tibble: 6 x 3
##   CODI_BARRI total                                                      geometry
##        <int> <int>                                                <GEOMETRY [°]>
## 1          1  3276 MULTIPOINT ((2.170728 41.38052), (2.171018 41.37589), (2.173…
## 2          2  3192 MULTIPOINT ((2.174942 41.38101), (2.175294 41.37973), (2.175…
## 3          3   777         MULTIPOINT ((2.189692 41.38031), (2.191125 41.38255))
## 4          4   816                                     POINT (2.179723 41.38417)
## 5          5  1491 MULTIPOINT ((2.177451 41.396), (2.177717 41.39363), (2.17959…
## 6          6  2640 MULTIPOINT ((2.174628 41.40089), (2.178373 41.40306), (2.180…
colnames(Total_Alojamientos_Turisticos_Por_Polígono_y_Barrio_para_RL)[colnames(Total_Alojamientos_Turisticos_Por_Polígono_y_Barrio_para_RL) %in% c('total')] <- paste0(c('Total_Alojamientos_Turisticos'))
Total_Alojamientos_Turisticos_Por_Polígono_y_Barrio_para_RL_Sin_Geometria_Para_RL <- Total_Alojamientos_Turisticos_Por_Polígono_y_Barrio_para_RL %>%
  st_set_geometry(NULL)

names(Total_Alojamientos_Turisticos_Por_Polígono_y_Barrio_para_RL_Sin_Geometria_Para_RL)
## [1] "CODI_BARRI"                    "Total_Alojamientos_Turisticos"
Info_para_Regresión_Lineal_Compacta <- full_join (Total_Actividades_Económicas_Por_Poligono_y_Barrio_Sin_Geometria_para_RL, Total_Alojamientos_Turisticos_Por_Polígono_y_Barrio_para_RL_Sin_Geometria_Para_RL, by="CODI_BARRI")

head(Info_para_Regresión_Lineal_Compacta)
## # A tibble: 6 x 4
## # Groups:   Total_Alojamientos_Turisticos [6]
##   CODI_BARRI Nom_Barri              Total_Actividades_Eco… Total_Alojamientos_T…
##        <int> <fct>                                   <int>                 <int>
## 1          1 el Raval                                15210                  3276
## 2          2 el Barri Gòtic                           6552                  3192
## 3          3 la Barceloneta                            962                   777
## 4          4 Sant Pere, Santa Cate…                   5304                   816
## 5          5 el Fort Pienc                            3976                  1491
## 6          6 la Sagrada Família                       9570                  2640

Observamos la regresión lineal que planteamos:

ggplot(Info_para_Regresión_Lineal_Compacta) +
  geom_point(aes(x=Total_Actividades_Económicas, y=Total_Alojamientos_Turisticos)) +
  labs(x='Actividades Económicas por Barrio', y = 'Alojamientos Turísticos por Barrio') +
  theme(axis.title = element_text(size=10)) +
  labs(title = "Relación Cantidad de Alojamientos Turísticos y Actividades Económicas por Barrio",
         subtitle = "Barcelona",
         caption= "Fuente:https://opendata-ajuntament.barcelona.cat/es/")
## Warning: Removed 36 rows containing missing values (geom_point).

Observamos claramente una correlación directa, a mayor cantidad de actividades económicas vinculadas al turismo, mayor cantidad de alojamientos turísticos. Se observa un punto extremo, que podemos identificar como outlier.

Verificaremos cual es esa correlación estadística, utilizando la función que permite estimar regresiones lineales:

Regresión_Lineal <- lm(data = Info_para_Regresión_Lineal_Compacta, formula = Total_Alojamientos_Turisticos ~  Total_Actividades_Económicas)

Regresión_Lineal
## 
## Call:
## lm(formula = Total_Alojamientos_Turisticos ~ Total_Actividades_Económicas, 
##     data = Info_para_Regresión_Lineal_Compacta)
## 
## Coefficients:
##                  (Intercept)  Total_Actividades_Económicas  
##                   -1959.7506                        0.9984
summary(Regresión_Lineal)
## 
## Call:
## lm(formula = Total_Alojamientos_Turisticos ~ Total_Actividades_Económicas, 
##     data = Info_para_Regresión_Lineal_Compacta)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -9949.4 -1891.2   753.6  1708.2 20526.9 
## 
## Coefficients:
##                                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  -1959.7506  1096.6987  -1.787   0.0829 .  
## Total_Actividades_Económicas     0.9984     0.1347   7.412 1.35e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4898 on 34 degrees of freedom
##   (36 observations deleted due to missingness)
## Multiple R-squared:  0.6177, Adjusted R-squared:  0.6065 
## F-statistic: 54.94 on 1 and 34 DF,  p-value: 1.353e-08
ggplot(Info_para_Regresión_Lineal_Compacta) +
  geom_abline(aes(slope = coef(Regresión_Lineal)[2] ,intercept = coef(Regresión_Lineal)[1]), color="red") +
  geom_point(aes(x=Total_Actividades_Económicas, y=Total_Alojamientos_Turisticos), color="black") +
  labs(x='Actividades Económicas por Barrio', y = 'Alojamientos Turísticos por Barrio') +
  labs(title = "Relación Cantidad Alojamientos Turísticos y Actividades Económicas por Barrio",
         subtitle = "Barcelona",
         caption= "Fuente:https://opendata-ajuntament.barcelona.cat/es/")
## Warning: Removed 36 rows containing missing values (geom_point).

De este modo obtenemos la recta que mejor se ajusta a nuestras observaciones. Podremos estimar cual sera el cambio esperado de los alojamientos turisticos ante el aumento o disminución de una actividad económica. Es por ello que se observa la tendencia que donde hay mayor cantidad de actividades económicas vinculadas al tursimo, existen mayor cantidad de alojamientos turísticos. La existencia de un valor atípico provoca que nuestro modelo sufra una desviación.

Si observamos la tabla, tenemos un p-valor muy bajo que rechazaría la “hipotesis nula”. Lo que nos indica el p-valor bajo (1.35e-08 *) es que hay un efecto significativo del predictor o variable independiente (la existencia de actvidades económicas relacionadas al turismo) sobre la dependiente (en este caso, la ubicacion de alojamientos turisticos). Que el p-valor sea menos a 0,05 (5%) indica que la capacidad de predicción de la variable asociada es significativa. Por otro lado tenemos un r2 alto, de 0,62. Esto significa que el modelo logra captar un 60 % de la variabilidad de mi variable dependiente. Quiere decir que el modelo ajusta bien a los datos que tengo.Nos dice que proporción de la variación al cuadrado de las observaciones de alojamientos son explicadas por la variación de nuestra variable explicativa. Este modelo puede “explicar” o “predecir” el 62% de la localizacion de los alojamientos turisticos. Por ultimo, tenemos un valor T de 7,41. Muy por arriba d ela zona de corte de 1,96 (zona de corte o de rechazo de la hipotesis nula con un intervalo de confianza de 95% y con una distribucion normal).

15- Ahora sabiendo que existe cierta incertidumbre muestral, hacemos una prediccion de un valor utilizando nuestro modelo y agregando el “error” ya que el valor de este no tiene porque ser 0.

prediccion <- coef(Regresión_Lineal)[1] + coef(Regresión_Lineal)[2]*2000
prediccion
## (Intercept) 
##    36.97949

Esto indicaría que sumaramos aproximadamente 37 alojamientos cada 2000 actividades económicas.

En los proximos comandos vamos a: - Estimar el intervalo de confianza del 95% del promedio de alojamientos cuando tenemos 2000 actividades económicas (nuestra predicccion). - Calcular el intervalo de confianza para la cantidad puntual de alojamientos, con un intervalo del 95%, es decir de una muestra de 100 barrios con 37 alojamientos, 95 caerían en el intervalo resultante.

predict(Regresión_Lineal,newdata = data.frame(Total_Actividades_Económicas=2000), interval ='confidence')
##        fit      lwr      upr
## 1 36.97949 -1870.28 1944.239
predict(Regresión_Lineal,newdata = data.frame(Total_Actividades_Económicas=2000), interval ='prediction')
##        fit       lwr      upr
## 1 36.97949 -10098.96 10172.92

16- Calculamos los residuos para ver cuanto se alejan los valores del “0”:

plot(residuals(Regresión_Lineal))

Promedio:

mean(residuals(Regresión_Lineal))
## [1] 7.891527e-14

El promedio de la distancia de los risiduos al “0” es casi cero (“0”).

Desvío Standard:

sd(residuals(Regresión_Lineal))
## [1] 4827.98

Intentamos reducir el desvío standard de nuestros residuos eliminando los valores donde nuestra recta pasa más lejos

Regresión_Lineal_2 <- lm(data = Info_para_Regresión_Lineal_Compacta[abs(residuals(Regresión_Lineal))<sd(residuals(Regresión_Lineal)),], formula = Total_Alojamientos_Turisticos ~ Total_Actividades_Económicas)
## Warning: Length of logical index must be 1 or 72, not 36
summary(Regresión_Lineal_2)
## 
## Call:
## lm(formula = Total_Alojamientos_Turisticos ~ Total_Actividades_Económicas, 
##     data = Info_para_Regresión_Lineal_Compacta[abs(residuals(Regresión_Lineal)) < 
##         sd(residuals(Regresión_Lineal)), ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2477.9  -785.0   -55.6   337.2  4439.6 
## 
## Coefficients:
##                               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  -23.45056  433.57308  -0.054    0.957    
## Total_Actividades_Económicas   0.55458    0.07263   7.636 3.26e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1723 on 27 degrees of freedom
##   (31 observations deleted due to missingness)
## Multiple R-squared:  0.6835, Adjusted R-squared:  0.6718 
## F-statistic:  58.3 on 1 and 27 DF,  p-value: 3.264e-08
predict(Regresión_Lineal_2,newdata = data.frame(Total_Actividades_Económicas=2000), interval ='prediction')
##        fit       lwr      upr
## 1 1085.712 -2523.428 4694.851

Verificamos que con la caída del desvío standard de los errores, también se achicaron los intervalos de confianza de las predicciones.

17- Calculamos de nuevo el modelo agregando una nueva variable, “Bibliotecas y Museos”, creando un Modelo de Regresión Lineal Múltiple, estudiaremos si esta incorporación influye en la localización de los alojamientos turísticos, analizando si existe una correlación estadísticamente significativa.

Bibliotecas_y_Museos <- read.csv("06_Bibliotecas_y_Museos.csv")

head(Bibliotecas_y_Museos)
##   CODI_EQUIPAMENT                    EQUIPAMENT     SECCIO TIPUS_VIA NOM_CARRER
## 1        62172134 Museu d'Història de Catalunya Biblioteca        Pl   Pau Vila
## 2        62172134 Museu d'Història de Catalunya Biblioteca        Pl   Pau Vila
## 3        62172134 Museu d'Història de Catalunya Biblioteca        Pl   Pau Vila
## 4        62172134 Museu d'Història de Catalunya Biblioteca        Pl   Pau Vila
## 5        62172134 Museu d'Història de Catalunya Biblioteca        Pl   Pau Vila
## 6        62172134 Museu d'Història de Catalunya Biblioteca        Pl   Pau Vila
##   NUM_CARRER_1 NUM_CARRER_2 CODI_BARRI      NUM_BARRI CODI_DISTRICTE
## 1            3            3          3 la Barceloneta              1
## 2            3            3          3 la Barceloneta              1
## 3            3            3          3 la Barceloneta              1
## 4            3            3          3 la Barceloneta              1
## 5            3            3          3 la Barceloneta              1
## 6            3            3          3 la Barceloneta              1
##   NOM_DISTRICTE CODI_POSTAL CODI_POBLACIO  POBLACIO LATITUD LONGITUD X_ETRS89
## 1  Ciutat Vella        8039            19 BARCELONA 41.3807 2.185529 431897.1
## 2  Ciutat Vella        8039            19 BARCELONA 41.3807 2.185529 431897.1
## 3  Ciutat Vella        8039            19 BARCELONA 41.3807 2.185529 431897.1
## 4  Ciutat Vella        8039            19 BARCELONA 41.3807 2.185529 431897.1
## 5  Ciutat Vella        8039            19 BARCELONA 41.3807 2.185529 431897.1
## 6  Ciutat Vella        8039            19 BARCELONA 41.3807 2.185529 431897.1
##   Y_ETRS89 X_ED50  Y_ED50 TELEFON_NUM TELEFON_TIPUS TELEFON_INFO_COM
## 1  4581340 431989 4581541   932254758           Fax                 
## 2  4581340 431989 4581541   932254758           Fax                 
## 3  4581340 431989 4581541   932254700          Tel.                 
## 4  4581340 431989 4581541   932254700          Tel.                 
## 5  4581340 431989 4581541   932254700          Tel.                 
## 6  4581340 431989 4581541   932254700          Tel.                 
##   HORARI_PERIODE_INICI HORARI_PERIODE_FI HORARI_DIES HORARI_HORES_INICI
## 1                01/01             31/12     1000111           16:00:00
## 2                01/01             31/12     1000111           10:00:00
## 3                01/01             31/12     1000111           16:00:00
## 4                01/01             31/12     1000111           10:00:00
## 5                01/01             31/12     1000111           16:00:00
## 6                01/01             31/12     1000111           10:00:00
##   HORARI_HORES_FI HORARI_OBSERVACIONS          X3ER_NIVELL
## 1        18:00:00                  NA         Biblioteques
## 2        15:00:00                  NA         Biblioteques
## 3        18:00:00                  NA         Biblioteques
## 4        15:00:00                  NA         Biblioteques
## 5        18:00:00                  NA Humanitats i lletres
## 6        15:00:00                  NA Humanitats i lletres
##              X2N_NIVELL      X1ER_NIVELL  X
## 1 Biblioteques i museus Cultura i lleure NA
## 2 Biblioteques i museus Cultura i lleure NA
## 3 Biblioteques i museus Cultura i lleure NA
## 4 Biblioteques i museus Cultura i lleure NA
## 5          Biblioteques Cultura i lleure NA
## 6          Biblioteques Cultura i lleure NA
Total_Bibliotecas_y_Museos <- Bibliotecas_y_Museos %>%
  group_by(CODI_BARRI) %>%
  summarise(total=n())

head(Total_Bibliotecas_y_Museos)
## # A tibble: 6 x 2
##   CODI_BARRI total
##        <int> <int>
## 1          1   548
## 2          2   413
## 3          3   320
## 4          4   230
## 5          5   342
## 6          6    76
colnames(Total_Bibliotecas_y_Museos)[colnames(Total_Bibliotecas_y_Museos) %in% c('total')] <- paste0(c('Total_Bibliotecas_y_Museos'))
Info_para_Regresión_Lineal_Múltiple <- full_join (Info_para_Regresión_Lineal_Compacta, Total_Bibliotecas_y_Museos, by="CODI_BARRI")

head(Info_para_Regresión_Lineal_Múltiple)
## # A tibble: 6 x 5
## # Groups:   Total_Alojamientos_Turisticos [6]
##   CODI_BARRI Nom_Barri     Total_Actividade… Total_Alojamient… Total_Biblioteca…
##        <int> <fct>                     <int>             <int>             <int>
## 1          1 el Raval                  15210              3276               548
## 2          2 el Barri Gòt…              6552              3192               413
## 3          3 la Barcelone…               962               777               320
## 4          4 Sant Pere, S…              5304               816               230
## 5          5 el Fort Pienc              3976              1491               342
## 6          6 la Sagrada F…              9570              2640                76
Modelo_Regresión_Lineal_Múltiple <- lm(Total_Alojamientos_Turisticos ~ Total_Actividades_Económicas + Total_Bibliotecas_y_Museos, data = Info_para_Regresión_Lineal_Múltiple)

Modelo_Regresión_Lineal_Múltiple
## 
## Call:
## lm(formula = Total_Alojamientos_Turisticos ~ Total_Actividades_Económicas + 
##     Total_Bibliotecas_y_Museos, data = Info_para_Regresión_Lineal_Múltiple)
## 
## Coefficients:
##                  (Intercept)  Total_Actividades_Económicas  
##                   -2722.6074                        0.9745  
##   Total_Bibliotecas_y_Museos  
##                       4.4965
summary(Modelo_Regresión_Lineal_Múltiple)
## 
## Call:
## lm(formula = Total_Alojamientos_Turisticos ~ Total_Actividades_Económicas + 
##     Total_Bibliotecas_y_Museos, data = Info_para_Regresión_Lineal_Múltiple)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -11287.9  -2404.8    437.4   2036.7  19713.1 
## 
## Coefficients:
##                                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  -2722.6074  1400.9964  -1.943   0.0617 .  
## Total_Actividades_Económicas     0.9745     0.1608   6.059 1.35e-06 ***
## Total_Bibliotecas_y_Museos       4.4965     5.8094   0.774   0.4452    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5210 on 29 degrees of freedom
##   (41 observations deleted due to missingness)
## Multiple R-squared:  0.6241, Adjusted R-squared:  0.5982 
## F-statistic: 24.08 on 2 and 29 DF,  p-value: 6.89e-07

Observando la nueva tabla, vemos que los coeficientes de la variable independiente original practicamente no se modificaron. Y para la nueva variable incorporada tenemos un p-valor alto. Lo que nos indica que esta nueva variable no tiene un efecto significativo sobre la que queremos explicar.Es decir que la existencia de museos y bibliotecas en una zona no modifica o no influye en la localizacion de mayor cantidad de alojamientos turisticos, cuando existen localizadas una determinada cantidad de actividades económicas vinculadas al turismo. La capacidad de prediccion de la nueva variable asociada no es significativa. El valor T de 0,774 no entra en la zona de corte de 1,96 , lo que es lógico ya que el p-valor es alto, y la hipotesis nula no seria rechazada. De esta tabla podemos concluir que la existencia de actividades económicas en PB es una variable estadísticamente significativa para la localización de alojamientos turísticos, pero no existe correlación entre esto y la existencia o cercanía de bibliotecas y museos. El r2 practicamente no se modifico, indicando que la nueva variable agregada no explica nada más, o no aporta información extra a la ubicación de los alojamientos.

18- Verificamos los Intervalo de Confianza para cada una de las variables de nuestro modelo.

confint(Modelo_Regresión_Lineal_Múltiple)
##                                      2.5 %    97.5 %
## (Intercept)                  -5587.9666899 142.75184
## Total_Actividades_Económicas     0.6455902   1.30344
## Total_Bibliotecas_y_Museos      -7.3851109  16.37813

19- Corregimos nuestro modelo, reduciendo el desvío standard de nuestros residuos eliminando los valores donde nuestra recta pasa mas lejos. De este modo se podrán achicar los intervalos de confianza.

Modelo_Regresión_Lineal_Múltiple_2 <- lm(data = Info_para_Regresión_Lineal_Múltiple[abs(residuals(Modelo_Regresión_Lineal_Múltiple))<sd(residuals(Modelo_Regresión_Lineal_Múltiple)),], formula = Total_Alojamientos_Turisticos ~ Total_Actividades_Económicas + 
    Total_Bibliotecas_y_Museos)
## Warning: Length of logical index must be 1 or 73, not 32
summary(Modelo_Regresión_Lineal_Múltiple_2)
## 
## Call:
## lm(formula = Total_Alojamientos_Turisticos ~ Total_Actividades_Económicas + 
##     Total_Bibliotecas_y_Museos, data = Info_para_Regresión_Lineal_Múltiple[abs(residuals(Modelo_Regresión_Lineal_Múltiple)) < 
##     sd(residuals(Modelo_Regresión_Lineal_Múltiple)), ])
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2262.5 -1308.3  -141.7   542.8  4775.3 
## 
## Coefficients:
##                                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  -412.90365  737.64290  -0.560    0.582    
## Total_Actividades_Económicas    0.53745    0.09095   5.909 8.85e-06 ***
## Total_Bibliotecas_y_Museos      2.26325    2.69281   0.840    0.411    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2029 on 20 degrees of freedom
##   (37 observations deleted due to missingness)
## Multiple R-squared:  0.6423, Adjusted R-squared:  0.6065 
## F-statistic: 17.95 on 2 and 20 DF,  p-value: 3.433e-05

En esta tabla podemos observar que los valores de los coeficientes en general disminuyen bastante, salvo los del p-valor que no descienden tanto. Sigue siendo significativo únicamente el p-valor de la varianble de actividades economicas. El r2 aumento un poquito, no demasiado pero indica un modelo más ajustado a los datos.

CONCLUSIÓN: A lo largo de todo el trabajo se pudo observar que la localización de los alojamientos turísitcos esta fuertemente relacionado a la ubicación de las actividades económicas vinculadas al turismo. Por otra parte, no se pudo verificar que las Bibliotecas y Museos incidan en la localización de los alojamientos, pero podemos estimar que dichas actividades tendrían una correlación con los mismos. Se podría realizar una regresión lineal contemplando como variable predictora Bibliotecas y Museos y observar dichos resultados. Si bien la localización de los alojamientos turísticos se encuentra vinculado a las actividades como las recreativas, el ocio y la cultura, es dable mencionar que esta es solo una variable que incide en dicha localización. Pero, a su vez, existen muchas otras variables que quizás refuercen o debiliten la localización, como ser conectividad, transporte público, espacios verdes, actividades gastronómicas, entre otras. Aunque, si se realizara un estudio más profundo podría estimarse que todas las actividades vinculadas al turismo probablemnete se localicen en áreas cercanas y es por esa razón que los alojamientos turísticos tienden a ubicarse allí.