INTRODUCCIÓN

En el presente trabajo de investigación analizaremos los proyectos residenciales con viviendas asequibles para la ciudad de San Francisco, California.

La zonificación inclusiva en la ciudades promueve la integración de la sociedad en áreas de altas oportunidades. Esta politica urbana es aplicada en San Francisco desde el año 1992. Al día de la fecha existen aproximadamente 4000 unidades tanto en propiedad como en alquiler. En el año 2016 el % de asequibilidad en relación a las unidades total del inmueble se ajusto entre 20% y 33%, dependiendo si las unidades se localizan dentro o fuera del sito donde se construye el inmueble y la totalidad de unidades.

Para el análisis se utilizarán los siguientes dataset obtenidos del portal de datos abiertos de la ciudad, San Francisco Open Data (https://datasf.org/opendata/).

El estudio tiene por objeto dar respuesta a una serie de preguntas asociadas a la temática propuesta:

Cargamos las librerías de R a ser utilizadas durante el desarrollo de la investigación.

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.2     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.2     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.1     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(sf)
## Linking to GEOS 3.9.3, GDAL 3.5.2, PROJ 8.2.1; sf_use_s2() is TRUE
library(ggmap)
## ℹ Google's Terms of Service: <https://mapsplatform.google.com>
## ℹ Please cite ggmap if you use it! Use `citation("ggmap")` for details.
library(lubridate)
library(osmdata)
## Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright
library(leaflet)
library(tidygeocoder)
## 
## Attaching package: 'tidygeocoder'
## 
## The following object is masked from 'package:ggmap':
## 
##     geocode
library(osrm)
## Data: (c) OpenStreetMap contributors, ODbL 1.0 - http://www.openstreetmap.org/copyright
## Routing: OSRM - http://project-osrm.org/
library(gganimate)
library(gifski)

IMPORTACIÓN, LIMPIEZA, TRATAMIENTO, TRANSFORMACIÓN Y VISUALIZACIÓN DE DATOS

Importamos los datasets con los cuales voy a trabajar durante el presente trabajo.

Importamos un dataset geográfico con los barrios de SF.

barrios_SF <- st_read("../entradas/barrios_SF/geo_export_7f3417ec-d5ef-427f-a9a5-93b8490b9eb6.shp",
                         stringsAsFactors = TRUE,
                         options = "ENCODING=UTF-8")
## options:        ENCODING=UTF-8 
## Reading layer `geo_export_7f3417ec-d5ef-427f-a9a5-93b8490b9eb6' from data source `F:\BDeIT (Flacso)\(X) Módulos Curso\M3 - Ciencia de Datos Geográfica\TP Final\FLACSO_CDDII\entradas\barrios_SF\geo_export_7f3417ec-d5ef-427f-a9a5-93b8490b9eb6.shp' 
##   using driver `ESRI Shapefile'
## Simple feature collection with 41 features and 1 field
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -122.5149 ymin: 37.70813 xmax: -122.357 ymax: 37.8333
## Geodetic CRS:  WGS84(DD)

Analizamos el dataset importado.

class(barrios_SF)
## [1] "sf"         "data.frame"
dim(barrios_SF)
## [1] 41  2

El dataset posee 41 filas con 2 variables.

summary(barrios_SF)
##                             nhood             geometry 
##  Bayview Hunters Point         : 1   MULTIPOLYGON :41  
##  Bernal Heights                : 1   epsg:NA      : 0  
##  Castro/Upper Market           : 1   +proj=long...: 0  
##  Chinatown                     : 1                     
##  Excelsior                     : 1                     
##  Financial District/South Beach: 1                     
##  (Other)                       :35

Consultamos los nombres de todos los barrios de SF.

unique(barrios_SF$nhood)
##  [1] Western Addition               West of Twin Peaks            
##  [3] Visitacion Valley              Twin Peaks                    
##  [5] South of Market                Treasure Island               
##  [7] Presidio Heights               Presidio                      
##  [9] Potrero Hill                   Portola                       
## [11] Pacific Heights                Outer Richmond                
## [13] Outer Mission                  Sunset/Parkside               
## [15] Oceanview/Merced/Ingleside     North Beach                   
## [17] Noe Valley                     Lone Mountain/USF             
## [19] Lincoln Park                   Seacliff                      
## [21] Nob Hill                       Mission Bay                   
## [23] Mission                        Russian Hill                  
## [25] Marina                         Lakeshore                     
## [27] Tenderloin                     McLaren Park                  
## [29] Japantown                      Inner Sunset                  
## [31] Hayes Valley                   Haight Ashbury                
## [33] Golden Gate Park               Inner Richmond                
## [35] Glen Park                      Financial District/South Beach
## [37] Excelsior                      Chinatown                     
## [39] Castro/Upper Market            Bernal Heights                
## [41] Bayview Hunters Point         
## 41 Levels: Bayview Hunters Point Bernal Heights ... Western Addition

Generamos un mapa para ver el dataset geográfico en detalle.

ggplot()+
  geom_sf(data=barrios_SF , aes(fill=nhood)) +
  labs(title="Barrios",
       subtitle= "San Fransico, California",
       fill="Referencias", 
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  theme_light() +
    scale_fill_viridis_d() +
    theme(legend.key.size = unit(0.3, "cm"), 
        legend.key.width = unit(0.4,"cm"), 
        legend.position="bottom") 

Importamos un mapa base de SF. Obtenenmos las coordenadas geograficas.

bbox_SF <- st_bbox(barrios_SF)
bbox_SF
##       xmin       ymin       xmax       ymax 
## -122.51495   37.70813 -122.35697   37.83330

Agregamos un margen al mapa antes de ser descargado.

xmin <- as.numeric(bbox_SF$xmin - 0.05)

xmax <- as.numeric(bbox_SF$xmax + 0.05)

ymin <- as.numeric(bbox_SF$ymin - 0.05)

ymax <- as.numeric(bbox_SF$ymax + 0.05)
bbox_SF <- st_bbox(c(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax))

Coordenadas geográficas con el margen incluido.

bbox_SF
##       xmin       ymin       xmax       ymax 
## -122.56495   37.65813 -122.30697   37.88330

Descargamos el mapa de la ciudad de SF.

mapa_base_SF <- get_stamenmap (bbox = as.numeric(bbox_SF), maptype="toner-lite", zoom=13)
## ℹ Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.
## ℹ 49 tiles needed, this may take a while (try a smaller zoom?)

Ploteamos el mapa para ver lo descargado.

ggmap(mapa_base_SF) +
  labs(title="San Francisco, California",
       fill="Referencias", 
       x= "Longitud",
       y= "Latitud",
       caption = "Fuente: Stamen Maps (maps.stamen.com)")

Solapamos el mapa de base descargado y el dataframe de barrios.

ggmap(mapa_base_SF)+
  geom_sf(data=barrios_SF , fill=NA, color="tomato4", lwd=0.75, inherit.aes = FALSE) +
  labs(title="Barrios",
       subtitle="San Francisco, California",
       x= "Longitud",
       y= "Latitud",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/) // Stamen Maps (maps.stamen.com)")
## Coordinate system already present. Adding new coordinate system, which will
## replace the existing one.

Importamos el dataset correspondiente a los proyectos residenciales con requerimientos inclusivos.

projects_IR <- read.csv("../entradas/residential_projects_IZ/Residential_Projects_With_Inclusionary_Requirements.csv",
                         stringsAsFactors = TRUE)

Analizamos el dataset importado.

summary(projects_IR)
##     Project.ID                                 Project.Status
##  1989-001:  1   (3) Design with Entitlements Approved : 79   
##  1990-019:  1   (4) Site Work Permit Issued           : 44   
##  1991-001:  1   (5) First Construction Document Issued: 55   
##  1991-002:  1   (6) Complete                          :343   
##  1991-003:  1   (8) Cancelled                         :  1   
##  1992-001:  1   (e) Cancelled                         : 16   
##  (Other) :535   (f) Planning Approval Expired         :  3   
##              Project.Name Street.Number   Street.Name   Street.Type 
##  345 6th           :  2   1      :  8   Market  : 33   St     :441  
##  793 South Van Ness:  2   300    :  5   Mission : 28   Ave    : 65  
##  Mosso             :  2   600    :  5   Van Ness: 21   Blvd   : 16  
##  0 Guttenberg      :  1   101    :  4   Folsom  : 20   0      :  7  
##  1 Franklin        :  1   201    :  4   3rd     : 15   Way    :  4  
##  1 Hawthorne       :  1   333    :  4   Harrison: 15   Dr     :  2  
##  (Other)           :532   (Other):511   (Other) :409   (Other):  6  
##     Zip.Code               Housing.Tenure
##  Min.   :94012   Ownership        :241   
##  1st Qu.:94103   Ownership, Rental:  2   
##  Median :94107   Rental           :191   
##  Mean   :94110   Unknown          :107   
##  3rd Qu.:94112                           
##  Max.   :94410                           
##                                          
##                      Section.415.Declaration Entitlement.Approval.Date
##  On-site BMR Project             :353        05/12/2016:  6           
##  Fee Payment                     :125        09/02/2014:  6           
##  On-site BMR Project, Fee Payment: 18        01/01/2002:  4           
##  Off-site BMR Project            : 10        02/10/2011:  4           
##  Undeclared                      :  9        06/16/2005:  4           
##  Units for Off-site Project      :  7        08/03/2006:  4           
##  (Other)                         : 19        (Other)   :513           
##  Actual.Estimated.Completion.Date     Planning.Case.Number
##  06/29/2019: 42                   2002.1179     :  4      
##  05/23/2023: 10                   2008.0021     :  4      
##  11/22/2021: 10                   Not applicable:  3      
##  07/29/2021:  4                   2002.1303     :  2      
##  02/27/2015:  3                   2003.0029     :  2      
##  09/13/2025:  3                   2003.1113     :  2      
##  (Other)   :469                   (Other)       :524      
##                                      Property.Information.Map.Link
##  http://propertymap.sfplanning.org/?search=2002.1179:  4          
##  http://propertymap.sfplanning.org/?search=2008.0021:  4          
##                                                     :  3          
##  http://propertymap.sfplanning.org/?search=2002.1303:  2          
##  http://propertymap.sfplanning.org/?search=2003.0029:  2          
##  http://propertymap.sfplanning.org/?search=2003.1113:  2          
##  (Other)                                            :524          
##  Project.Units  Affordable.Units  Units.Subject.to.Section.415
##  Min.   :   0   Min.   :  0.000   Min.   :   0.0              
##  1st Qu.:  21   1st Qu.:  0.000   1st Qu.:  20.0              
##  Median :  43   Median :  2.000   Median :  42.0              
##  Mean   : 108   Mean   :  8.956   Mean   : 106.6              
##  3rd Qu.: 118   3rd Qu.:  9.000   3rd Qu.: 116.0              
##  Max.   :3522   Max.   :176.000   Max.   :3522.0              
##                                                               
##  On.Site.Affordable.Units Off.Site.Affordable.Units
##  Min.   :  0.000          Min.   :  0.000          
##  1st Qu.:  0.000          1st Qu.:  0.000          
##  Median :  3.000          Median :  0.000          
##  Mean   :  9.449          Mean   :  1.031          
##  3rd Qu.: 10.000          3rd Qu.:  0.000          
##  Max.   :176.000          Max.   :164.000          
##                                                    
##  Off.Site.Affordable.Units.at.This.Site   SRO.Units        Studio.Units   
##  Min.   :  0.000                        Min.   : 0.0000   Min.   : 0.000  
##  1st Qu.:  0.000                        1st Qu.: 0.0000   1st Qu.: 0.000  
##  Median :  0.000                        Median : 0.0000   Median : 0.000  
##  Mean   :  1.009                        Mean   : 0.1017   Mean   : 1.453  
##  3rd Qu.:  0.000                        3rd Qu.: 0.0000   3rd Qu.: 1.000  
##  Max.   :164.000                        Max.   :17.0000   Max.   :56.000  
##                                                                           
##    X1bd.Units      X2bd.Units       X3bd.Units       X4bd.Units      
##  Min.   : 0.00   Min.   : 0.000   Min.   : 0.000   Min.   : 0.00000  
##  1st Qu.: 0.00   1st Qu.: 0.000   1st Qu.: 0.000   1st Qu.: 0.00000  
##  Median : 0.00   Median : 0.000   Median : 0.000   Median : 0.00000  
##  Mean   : 3.17   Mean   : 3.135   Mean   : 0.647   Mean   : 0.05915  
##  3rd Qu.: 3.00   3rd Qu.: 3.000   3rd Qu.: 0.000   3rd Qu.: 0.00000  
##  Max.   :66.00   Max.   :94.000   Max.   :25.000   Max.   :19.00000  
##                                                                      
##     X30..AMI          X50..AMI           X55..AMI         X60..AMI      
##  Min.   : 0.0000   Min.   :  0.0000   Min.   : 0.000   Min.   : 0.0000  
##  1st Qu.: 0.0000   1st Qu.:  0.0000   1st Qu.: 0.000   1st Qu.: 0.0000  
##  Median : 0.0000   Median :  0.0000   Median : 0.000   Median : 0.0000  
##  Mean   : 0.1774   Mean   :  0.7819   Mean   : 3.843   Mean   : 0.5471  
##  3rd Qu.: 0.0000   3rd Qu.:  0.0000   3rd Qu.: 0.000   3rd Qu.: 0.0000  
##  Max.   :50.0000   Max.   :110.0000   Max.   :91.000   Max.   :81.0000  
##                                                                         
##     X80..AMI          X90..AMI        X100..AMI         X120..AMI      
##  Min.   : 0.0000   Min.   : 0.000   Min.   :  0.000   Min.   : 0.0000  
##  1st Qu.: 0.0000   1st Qu.: 0.000   1st Qu.:  0.000   1st Qu.: 0.0000  
##  Median : 0.0000   Median : 0.000   Median :  0.000   Median : 0.0000  
##  Mean   : 0.4344   Mean   : 1.046   Mean   :  1.911   Mean   : 0.2865  
##  3rd Qu.: 0.0000   3rd Qu.: 0.000   3rd Qu.:  0.000   3rd Qu.: 0.0000  
##  Max.   :33.0000   Max.   :72.000   Max.   :170.000   Max.   :56.0000  
##                                                                        
##    X150..AMI        Supervisor.District                         Neighborhood
##  Min.   : 0.00000   Min.   : 1.000      South of Market               : 98  
##  1st Qu.: 0.00000   1st Qu.: 5.000      Mission                       : 75  
##  Median : 0.00000   Median : 6.000      Financial District/South Beach: 57  
##  Mean   : 0.08133   Mean   : 6.479      Potrero Hill                  : 41  
##  3rd Qu.: 0.00000   3rd Qu.: 9.000      Tenderloin                    : 40  
##  Max.   :28.00000   Max.   :11.000      Hayes Valley                  : 35  
##                                         (Other)                       :195  
##                               Plan.Area      Off.Site.Principal.Project.ID
##                                    :136   0                 :396          
##  Mission (EN)                      : 53                     :135          
##  Market and Octavia                : 48   2003-019          :  2          
##  Downtown                          : 33   2005-010          :  2          
##  Showplace Square/Potrero Hill (EN): 29   2003-003, 2005-028:  1          
##  Van Ness Corridor                 : 29   2003-015          :  1          
##  (Other)                           :213   (Other)           :  4          
##                  Off.Site.Principal.Project Off.Site.Project.ID
##  0                            :530          0       :531       
##  Summit 800                   :  2          2005-002:  2       
##  The Infinity                 :  2                  :  1       
##                               :  1          2003-007:  1       
##  1635 California, 680 Illinois:  1          2004-003:  1       
##  Linea                        :  1          2005-004:  1       
##  (Other)                      :  4          (Other) :  4       
##      Off.Site.Project    Latitude       Longitude     
##  0           :531     Min.   :37.71   Min.   :-122.5  
##  Bayshore    :  2     1st Qu.:37.76   1st Qu.:-122.4  
##              :  1     Median :37.78   Median :-122.4  
##  125 Mason   :  1     Mean   :37.77   Mean   :-122.4  
##  1400 Mission:  1     3rd Qu.:37.78   3rd Qu.:-122.4  
##  1600 Market :  1     Max.   :37.81   Max.   :-122.4  
##  (Other)     :  4                                     
##                               Location  
##  (37.717010014, -122.478923092999):  4  
##  (37.778456858, -122.413427037999):  4  
##  (37.712880416, -122.393115878999):  2  
##  (37.754173424, -122.390345622999):  2  
##  (37.76067284, -122.416701194999) :  2  
##  (37.764362355, -122.401028829999):  2  
##  (Other)                          :525

Datos relevantes que contiene el dataset:

  • Cada linea representa un proyecto con requerimientos inclusivos.
  • Estado del proyecto.
  • Tipo de tenencia.
  • Section 415 (ubicación de las unidades asequibles).
  • Fecha de aprobación del proyecto.
  • Fecha estimada de finalización del proyecto.
  • Unidades funcionales que posee el proyecto.
  • Unidades asequibles que posee el proyecto.
  • Barrio donde se localiza el proyecto.
  • Coordenadas geográficas de cada proyecto.
class(projects_IR)
## [1] "data.frame"
dim(projects_IR)
## [1] 541  44

El dataset posee 541 filas con 44 variables.

names(projects_IR)
##  [1] "Project.ID"                            
##  [2] "Project.Status"                        
##  [3] "Project.Name"                          
##  [4] "Street.Number"                         
##  [5] "Street.Name"                           
##  [6] "Street.Type"                           
##  [7] "Zip.Code"                              
##  [8] "Housing.Tenure"                        
##  [9] "Section.415.Declaration"               
## [10] "Entitlement.Approval.Date"             
## [11] "Actual.Estimated.Completion.Date"      
## [12] "Planning.Case.Number"                  
## [13] "Property.Information.Map.Link"         
## [14] "Project.Units"                         
## [15] "Affordable.Units"                      
## [16] "Units.Subject.to.Section.415"          
## [17] "On.Site.Affordable.Units"              
## [18] "Off.Site.Affordable.Units"             
## [19] "Off.Site.Affordable.Units.at.This.Site"
## [20] "SRO.Units"                             
## [21] "Studio.Units"                          
## [22] "X1bd.Units"                            
## [23] "X2bd.Units"                            
## [24] "X3bd.Units"                            
## [25] "X4bd.Units"                            
## [26] "X30..AMI"                              
## [27] "X50..AMI"                              
## [28] "X55..AMI"                              
## [29] "X60..AMI"                              
## [30] "X80..AMI"                              
## [31] "X90..AMI"                              
## [32] "X100..AMI"                             
## [33] "X120..AMI"                             
## [34] "X150..AMI"                             
## [35] "Supervisor.District"                   
## [36] "Neighborhood"                          
## [37] "Plan.Area"                             
## [38] "Off.Site.Principal.Project.ID"         
## [39] "Off.Site.Principal.Project"            
## [40] "Off.Site.Project.ID"                   
## [41] "Off.Site.Project"                      
## [42] "Latitude"                              
## [43] "Longitude"                             
## [44] "Location"

Analizamos que tipo de campos son las columnas que poseen fechas (aprobación y fnalización de proyecto)

str(projects_IR$Entitlement.Approval.Date)
##  Factor w/ 435 levels "01/01/1992","01/01/2000",..: 17 410 56 318 365 187 424 252 384 299 ...
str(projects_IR$Actual.Estimated.Completion.Date)
##  Factor w/ 448 levels "01/04/2018","01/05/2007",..: 78 37 250 317 448 341 145 167 11 3 ...

Ambos campos son de tipo factor.

Ejecutamos algunas moficaciones al dataset original para luego poder trabajar con el mismo.

  • Filtramos todos los proyectos que tienen al menos 1 unidad de vivienda asequible.
  • Creamos una nueva columna con tasa de incidencia de unidades asequibles sobre total de unidades.
  • Transformamos los campos de fechas en tipo date y creamos nuevas columnas con campos de años de aprobación y de finalización del proyecto.
  • Filtramos todos los proyectos que fueron aprobados a partir de 1990.
  • Creamos una nueva columna con la diferencia de años entre la aprobación y la finalización del proyecto.
  • Creamos una columna con categorización de incidencias de unidades asequibles.
projects_IR <- projects_IR %>%
               filter(Affordable.Units > 0) %>%
               mutate(incidencia = round(Affordable.Units/Project.Units*100)) %>%
               mutate(Entitlement.Approval.Date=mdy(Entitlement.Approval.Date))  %>%
               mutate(Actual.Estimated.Completion.Date=mdy(Actual.Estimated.Completion.Date)) %>%
               mutate(anio_aprobacion=year(Entitlement.Approval.Date),
               anio_finalizacion=year(Actual.Estimated.Completion.Date)) %>%
               filter(anio_aprobacion > 1990) %>%
               mutate(diferencia_anios = (anio_finalizacion - anio_aprobacion)) %>%
               mutate(categoria_incidencia = case_when(incidencia %in% c(1:10) ~ "Incidencia Baja (1% a 10%)",                               
                                                      incidencia %in% c(11:20) ~ "Incidencia Media (11% a 20%)",                              
                                                      incidencia %in% c(21:33) ~ "Incidencia Normativa (21% a 33%)", 
                                                      incidencia > 33 ~ "Incidencia Alta (> 33%)")) %>%
              arrange(desc(incidencia))

Validamos si los campos que tenía fechas quedaron el formato “Date”.

str(projects_IR$Entitlement.Approval.Date)
##  Date[1:337], format: "1997-09-18" "2005-01-01" "1997-08-04" "2007-01-01" "2005-02-17" ...
str(projects_IR$Actual.Estimated.Completion.Date)
##  Date[1:337], format: "2003-06-25" "2013-03-14" "2003-12-04" "2008-05-15" "2004-08-27" ...
class(projects_IR$diferencia_anios)
## [1] "numeric"

Graficamos los proyectos aprobados por tipo de tenencia. Se observa un pico de aprobación de proyectos para los años 2003 y 2016. A partir del año 2010 las unidades en alquiler asequible superar a las unidades para adquisición.

ggplot(projects_IR) + 
  geom_bar(aes(x = anio_aprobacion, fill=Housing.Tenure)) +
   labs(title="Proyectos aprobados con unidades asequibles por tipo de tenencia",
        subtitle= "San Francisco, California", 
       fill="Referencias", 
       x = "año de aprobación",
       y = "Cantidad de proyectos",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  theme_light() +
  scale_fill_viridis_d() 

Graficamos los proyectos por tipo de estado al momento de actualización del dataset. Se observan pocos proyectos cancelados y con permiso vencido.

ggplot(projects_IR) + 
    geom_bar(aes(x = anio_aprobacion), fill = "tomato4") +
   labs(title="Proyectos aprobados con unidades asequibles por tipo de estado de proyecto",
        subtitle= "San Francisco, California", 
       fill="Referencias", 
       x = "año de aprobación",
       y = "Cantidad de proyectos",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  facet_wrap(~Project.Status) 

Graficamos los proyectos finalizados por tipo de tenencia. Se observa un pico de finalización de proyectos para los años 2019 y 2021.

ggplot(projects_IR) + 
    geom_bar(aes(x = anio_finalizacion , fill=Housing.Tenure)) +
   labs(title="Proyectos finalizados con unidades asequibles",
        subtitle= "San Francisco, California", 
       fill="Referencias", 
       x = "año de finalización",
       y = "Cantidad de proyectos",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  theme_light() +
  scale_fill_viridis_d() 

Agrupamos la base para tener la cantidad de proyectos por años.

projects_IR_4 <- projects_IR %>% 
                  group_by(anio_aprobacion) %>%
                  summarise(cantidad = n())
projects_IR_5 <- projects_IR %>% 
                  group_by(anio_finalizacion) %>%
  summarise(cantidad = n())

Ejecutamos un grafico solapado con años de aprobación y años de finalización de los proyectos.

ggplot() + 
  geom_line(data=projects_IR_4, (aes(x = anio_aprobacion, y= cantidad, color = "Año Aprobación")), color = "tomato4", size =1) +
  geom_line(data=projects_IR_5, (aes(x = anio_finalizacion, y= cantidad, color = "Año Finalización" )), color = "blue4", size =1) + 
  labs(title="Proyectos con unidades asequibles - aprobación/finalización",
        subtitle= "San Francisco, California", 
       fill="Referencias", 
       x = "años",
       y = "Cantidad de proyectos",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  theme_light() +
  scale_fill_viridis_d() 
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

En base a la categorización realizada según la incidencia de unidades asequible grafico la cantidad de proyectos. Existen muy pocos proyectos bajo la nueva normativa, gran cantidad de proyectos entre el 11% y el 20% de incidencia.

ggplot(projects_IR) + 
  geom_bar(aes(x = categoria_incidencia), fill = "tomato4") +
   labs(title="Proyectos segun incidencia de unidades asequibles",
        subtitle= "San Francisco, California", 
       fill="Referencias", 
       x = "Categoría",
       y = "Cantidad de proyectos",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  theme_light() +
  scale_fill_viridis_d() +
  coord_flip()

Calculamos la media de la incidencia.

mean(projects_IR$incidencia)
## [1] 14.79525

Generamos un histograma con los porcentajes de incidencia. Destacamos en el gráfico la media obtenida anteriormente.

ggplot(projects_IR) + 
    geom_histogram(aes(x = incidencia), alpha=0.5 , fill = "tomato4") +
   labs(title="Histograma incidencia unidades asequibles",
        subtitle= "San Francisco, California", 
       fill="Referencias", 
       x = "% de unidades asequibles sobre unidades totales",
       y = "Cantidad de proyectos",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  theme_light() +
      geom_vline(xintercept = c(mean(projects_IR$incidencia)),
                 linetype = 2, color = "darkgreen", size=1)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Analizamos la cantidad de tiempo transcurrido entre la aprobación del proyecto y la finalización del mismo. La mayoría de los proyectos rondan los 4 años entre cada hito.

ggplot(projects_IR %>% filter(diferencia_anios > 0)) + 
    geom_histogram(aes(x = diferencia_anios), fill = "tomato4") +
   labs(title="Histograma diferencia años aprobación y finalización",
        subtitle= "San Francisco, California", 
       fill="Referencias", 
       x = "años",
       y = "Cantidad de proyectos",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  theme_light()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

Calculamos la media de la diferencia en años.

mean(projects_IR$diferencia_anios)
## [1] 4.302671

Agrupamos la base para poder realizar otros tipos de análisis.

  • Cantidad de emprendimientos por barrio
projects_IR_1 <- projects_IR %>% 
                  group_by(Neighborhood) %>%
                  summarise(cantidad = n()) %>%
                  rename(nhood = Neighborhood)

Los barrios que mayor proyectos con requerimientos inclusivos poseen son:

  • South of Market
  • Mission
  • Tenderloin
  • Potrero Hill

Los barrios que menor proyectos con requerimientos inclusivos poseen son:

  • Visitacion Valey
  • Presidio Heights
  • Glen Park
ggplot(data = projects_IR_1, aes(x = nhood, y = cantidad)) +
  geom_col(fill = "tomato4",  alpha = 0.8) +
  coord_flip() + 
  labs(title="Proyectos inmobiliarios IZ por barrio",
        subtitle= "San Francisco, California", 
       fill="Cantidad de proyectos",
       x = "Barrio",
       y= "Cantidad",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  geom_text(aes(label = cantidad), color="white", hjust=1.5, size=4)+ 
  theme_minimal()

  • Cantidad de emprendimientos por estado del proyecto
projects_IR_2 <- projects_IR %>% 
                  group_by(Project.Status) %>%
                  summarise(cantidad = n())

La mayoría de los proyectos al momento de la actualización del dataset se encuentran en estado finalizado.

ggplot(data = projects_IR_2, aes(x = Project.Status, y = cantidad)) +
  geom_col(fill = "tomato4",  alpha = 0.8) +
  coord_flip() + 
  labs(title="Proyectos inmobiliarios IZ por estado",
        subtitle= "San Francisco, California", 
       fill="Cantidad de proyectos",
       x = "Estado",
       y= "Cantidad",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  geom_text(aes(label = cantidad), hjust=1.5, size=4, color="white")+ 
  theme_minimal()

  • Cantidad de emprendimientos segun la localización de las unidades asequibles
projects_IR_3 <- projects_IR %>% 
                  group_by(Section.415.Declaration) %>%
                  summarise(cantidad = n())

La normativa vigente permite localizar las unidades asequibles en el mismo lote de la propiedad, fuera del sitio o pagar una tasa municipal para no construir con zonificación inclusiva. En el siguiente grafico se puede observar que la mayoría de los proyecto decide construir las unidades asequibles dentro del inmueble principal. Muy pocos deciden pagar la tasa municipal y muy pocos destinar las unidades asequibles fuera del sitio original.

ggplot(data = projects_IR_3, aes(x = Section.415.Declaration, y = cantidad)) +
  geom_col(fill = "tomato4",  alpha = 0.8) +
  coord_flip() + 
  labs(title="Proyectos inmobiliarios IZ por localización",
        subtitle= "San Francisco, California", 
       fill="Cantidad de proyectos",
       x = "Localización",
       y= "Cantidad",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  geom_text(aes(label = cantidad), hjust=1.5, size=4)+ 
  theme_minimal()

Obtenemos la cantidad total de unidades de todos los proyectos.

sum(projects_IR$Project.Units)
## [1] 36944

Obtenemos la cantidad total de unidades asequibles.

sum(projects_IR$Affordable.Units)
## [1] 4833

Obtenemos la relación entre la cantidad de unidades totales y la cantidad de unidades asequibles.

sum(projects_IR$Affordable.Units) / sum(projects_IR$Project.Units) * 100
## [1] 13.08196
  • Cantidad de unidades asequibles según el tipo de tenencia.
projects_IR_6 <- projects_IR %>%
                 group_by(Housing.Tenure) %>%
                 summarise(cantidad = sum(Affordable.Units))
ggplot(data = projects_IR_6, aes(x = Housing.Tenure, y = cantidad)) +
  geom_col(fill = "tomato4",  alpha = 0.8) +
  coord_flip() + 
  labs(title="Unidades asequibles segun tipo de tenencia",
        subtitle= "San Francisco, California", 
       fill="Cantidad de proyectos",
       x = "Tipo de tenencia",
       y= "Cantidad de unidades",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  geom_text(aes(label = cantidad), hjust=1.5, size=4) + 
  theme_minimal() 

Vinculamos el mapa de SF con los proyectos con requerimientos asequibles por barrios.

barrios_SF_projects_IR <- left_join(barrios_SF, projects_IR_1,"nhood")

Graficamos un mapa coropletico de todos los barrios de SF según la cantidad de proyectos existentes en cada uno.

ggplot()+
  geom_sf(data=barrios_SF_projects_IR, aes(fill=cantidad), color= "grey")+
  geom_point(data=projects_IR, aes(x=Longitude, y=Latitude, size=Affordable.Units), color="blue" , alpha=0.3) +
  geom_sf_text(data=barrios_SF_projects_IR, aes(label = nhood), size=3, color = "black") +
   labs(title="Proyectos inmobiliarios con unidades asequibles",
        subtitle= "San Francisco, California", 
       fill="Cantidad de proyectos",
       x = "Longitud",
       y= "Latitud",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  scale_fill_distiller(palette = "YlOrRd", direction = 1) +
  theme_light()
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

Generamos un mapa de calor de los proyectos con unidades asequibles según el tipo de tenencia.

ggmap(mapa_base_SF) +
    geom_bin2d(data = projects_IR, 
               aes(x = Longitude, y = Latitude), bins=50)+
  scale_fill_viridis_c(direction=-1) +
   labs(title="Proyectos inmobiliarios con unidades asequibles - Mapa de Calor por tipo de tenencia",
        subtitle= "San Francisco, California", 
       fill="Cantidad de proyectos",
       x = "Longitud",
       y= "Latitud",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  facet_wrap(~Housing.Tenure, ncol=2)

Generamos un mapa de calor de los proyectos con unidades asequibles según el estado de los proyectos a la fecha de actualización del dataset.

ggmap(mapa_base_SF) +
    geom_bin2d(data = projects_IR, 
               aes(x = Longitude, y = Latitude), bins=50)+
 scale_fill_distiller(palette = "Spectral")  +
   labs(title="Proyectos inmobiliarios con unidades asequibles - Mapa de Calor por estado de proyecto",
        subtitle= "San Francisco, California", 
       fill="Cantidad de proyectos",
       x = "Longitud",
       y= "Latitud",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  facet_wrap(~Project.Status, ncol=3)

Generamos un mapeo de los proyectos con unidades asequibles categorizados por la incidencia de las mismas en relación a las unidades totales.

ggplot()+
  geom_sf(data=barrios_SF , fill=NA, color="grey", lwd=0.75, inherit.aes = FALSE) +
  geom_point(data=projects_IR, aes(x=Longitude, y=Latitude, color = categoria_incidencia),  size=5 , alpha=0.6) +
  geom_sf_text(data=barrios_SF_projects_IR, aes(label = nhood), size=3, color = "black") +
   labs(title="Proyectos inmobiliarios con unidades asequibles por incidencia en la totalidad de las unidades",
        subtitle= "San Francisco, California", 
       fill="Cantidad de proyectos",
       x = "Longitud",
       y= "Latitud",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  theme_light()
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data

Generamos un mapa animado para ver la localización de los inmuebles en el tiempo en base a la finalización de los mismos.

ggmap(mapa_base_SF) +
  geom_point(data = projects_IR, aes(x = Longitude, y = Latitude) , size = 6, colour = "tomato4", alpha = 0.8) +
  labs(title="Proyectos inmobiliarios con IZ según fecha de finalización",
        subtitle= "Date: {frame_time}",
       x = "Longitud",
       y= "Latitud",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/)") +
  ease_aes("linear") +
  transition_time(anio_finalizacion) 

Generamos un mapa interactivo para ver todos los proyectos en detalle.

leaflet(projects_IR) %>%
  addProviderTiles(providers$CartoDB.Positron) %>% 
  addTiles() %>%
  addCircleMarkers(popup = paste("Nombre del Proyecto:", projects_IR$Project.Name, "<br>", "Incidencia IZ (%):", projects_IR$incidencia ))
## Assuming "Longitude" and "Latitude" are longitude and latitude, respectively

Filtramos el dataset por los proyectos ubicados en uno de los barrios mas esclusivos de SF, Presidio Heights. El objeto será analizar el entorno y los servicios educativos próximos en la zona.

barrios_SF_projects_IR_filtrado <- barrios_SF_projects_IR %>%
                                   filter(nhood == "Presidio Heights")

Obtenemos un bbox con las coordenadas del barrio.

bbox_PH <- st_bbox(barrios_SF_projects_IR_filtrado)
bbox_PH
##       xmin       ymin       xmax       ymax 
## -122.45948   37.78126 -122.44279   37.79188

Traemos un mapa base del barrio.

mapa_base_PH <- get_stamenmap (bbox = as.numeric(bbox_PH), maptype="toner-lite", zoom=16)
## ℹ Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.

Ploteamos el mapa base del barrio.

ggmap(mapa_base_PH)+
  geom_sf(data=barrios_SF_projects_IR_filtrado, fill= "tomato4", color="tomato4", alpha=0.4, lwd=2, inherit.aes = FALSE) +
  labs(title="Barrio Presidio Heights",
       subtitle="San Francisco, California",
       x= "Longitud",
       y= "Latitud",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/) // Stamen Maps (maps.stamen.com)")
## Coordinate system already present. Adding new coordinate system, which will
## replace the existing one.

Buscamos la única propiedad con unidades asequibles que posee el barrio y obtenemos la dirección.

projects_IR %>% filter(Neighborhood == "Presidio Heights")
##   Project.ID                        Project.Status Project.Name Street.Number
## 1   2017-030 (3) Design with Entitlements Approved   2670 Geary          2670
##   Street.Name Street.Type Zip.Code Housing.Tenure Section.415.Declaration
## 1       Geary        Blvd    94118         Rental     On-site BMR Project
##   Entitlement.Approval.Date Actual.Estimated.Completion.Date
## 1                2017-11-30                       2022-01-22
##   Planning.Case.Number                            Property.Information.Map.Link
## 1       2014-002181PRJ http://propertymap.sfplanning.org/?search=2014-002181PRJ
##   Project.Units Affordable.Units Units.Subject.to.Section.415
## 1            75                8                           75
##   On.Site.Affordable.Units Off.Site.Affordable.Units
## 1                        8                         0
##   Off.Site.Affordable.Units.at.This.Site SRO.Units Studio.Units X1bd.Units
## 1                                      0         0            2          4
##   X2bd.Units X3bd.Units X4bd.Units X30..AMI X50..AMI X55..AMI X60..AMI X80..AMI
## 1          2          0          0        0        7        1        0        0
##   X90..AMI X100..AMI X120..AMI X150..AMI Supervisor.District     Neighborhood
## 1        0         0         0         0                   2 Presidio Heights
##   Plan.Area Off.Site.Principal.Project.ID Off.Site.Principal.Project
## 1                                                                  0
##   Off.Site.Project.ID Off.Site.Project Latitude Longitude
## 1                   0                0  37.7773 -122.4091
##                            Location incidencia anio_aprobacion
## 1 (37.777295299, -122.409123492999)         11            2017
##   anio_finalizacion diferencia_anios         categoria_incidencia
## 1              2022                5 Incidencia Media (11% a 20%)
  • 2670 Geary Blvd, San Francisco, CA 94118, USA

Geocodificamos la propiedad.

Geary <- geo(address = "2670 Geary Blvd, San Francisco, CA 94118, USA",
                  method = "osm")
## Passing 1 address to the Nominatim single address geocoder
## Query completed in: 1.3 seconds
Geary
## # A tibble: 1 × 3
##   address                                         lat  long
##   <chr>                                         <dbl> <dbl>
## 1 2670 Geary Blvd, San Francisco, CA 94118, USA  37.8 -122.

Geolocalizamos propiedad en mapa interactivo.

leaflet(Geary) %>%
  addProviderTiles(providers$CartoDB.Positron) %>% 
  addMarkers(~long, ~lat,
             popup = "Proyecto IZ - Geary")

Obtenenmos desde OSM los establecimientos educativos existentes para el barrio en estudio.

educacion_SF <- opq(bbox_PH)
educacion_SF <- add_osm_feature(educacion_SF, key = "amenity", value = c("school", "college", "kindergarten", "university"))
educacion_SF <- osmdata_sf(educacion_SF) 
educacion_SF
## Object of class 'osmdata' with:
##                  $bbox : 37.7812570002723,-122.459475999986,37.7918789997658,-122.442793000466
##         $overpass_call : The call submitted to the overpass API
##                  $meta : metadata including timestamp and version numbers
##            $osm_points : 'sf' Simple Features Collection with 55 points
##             $osm_lines : NULL
##          $osm_polygons : 'sf' Simple Features Collection with 5 polygons
##        $osm_multilines : NULL
##     $osm_multipolygons : NULL

Filtramos los 55 puntos obtenidos desde OSM.

educacion_SF <- educacion_SF$osm_points
dim(educacion_SF)
## [1] 55  2

Mapeamos el proyecto con la unidad asequible y las instituciones educativas en la zona.

ggmap(mapa_base_PH) +
  geom_point(data = Geary, aes(x= long, y=lat), inherit.aes = FALSE, color= "yellow", size=6) +
  geom_sf(data = educacion_SF, size=4, color = "blue", alpha = 0.5, inherit.aes = FALSE) +
  geom_sf(data=barrios_SF_projects_IR_filtrado, fill= "tomato4", color="tomato4", alpha=0.1, lwd=0.75, inherit.aes = FALSE)+
  labs(title="Establecimientos Educativos - Barrio Presidio Heights",
       subtitle="San Francisco, California",
       x= "Longitud",
       y= "Latitud",
       caption = "Fuente: San Francisco Open Data (https://datasf.org/opendata/) // Stamen Maps (maps.stamen.com)")+
  theme_void()+
  theme(title=element_text(size=10, face = "bold"), #tamaño de titulo del mapa
        plot.caption=element_text(face = "italic", colour = "gray35",size=7)) #tamaño de nota al pie
## Coordinate system already present. Adding new coordinate system, which will
## replace the existing one.

Ejecutamos un mapa de isocronas para evaluar distancias desde el proyecto a los diferentes establecimientos educativos. Tomamos una distancia máxima de 15 minutos a pie.

isocrona <- osrmIsochrone(loc = c(Geary$long, Geary$lat),
                     breaks = seq(from=0,to=15,by=5),
                     res = 35,
                     osrm.profile = "foot")
isocrona
## Simple feature collection with 3 features and 3 fields
## Geometry type: MULTIPOLYGON
## Dimension:     XY
## Bounding box:  xmin: -122.4594 ymin: 37.7731 xmax: -122.4363 ymax: 37.79244
## Geodetic CRS:  WGS 84
##   id isomin isomax                       geometry
## 1  1      0      5 MULTIPOLYGON (((-122.4475 3...
## 2  2      5     10 MULTIPOLYGON (((-122.4462 3...
## 3  3     10     15 MULTIPOLYGON (((-122.4475 3...

Generamos el mapa interactivo con las isocronas y el proyecto Geary.

leaflet(isocrona) %>%
  addProviderTiles(providers$CartoDB.Positron) %>% 
  addPolygons(fillColor = ~colorBin("YlOrRd", domain = isocrona$isomax)(isomax),
  color = NA,
  fillOpacity = 0.5) %>%
  addMarkers(data=Geary)
## Assuming "long" and "lat" are longitude and latitude, respectively

Ejecutamos una serie de comandos para obtener los establecimientos educativos dentro de las isocronas.

st_crs(isocrona)
## Coordinate Reference System:
##   User input: EPSG:4326 
##   wkt:
## GEOGCRS["WGS 84",
##     DATUM["World Geodetic System 1984",
##         ELLIPSOID["WGS 84",6378137,298.257223563,
##             LENGTHUNIT["metre",1]]],
##     PRIMEM["Greenwich",0,
##         ANGLEUNIT["degree",0.0174532925199433]],
##     CS[ellipsoidal,2],
##         AXIS["geodetic latitude (Lat)",north,
##             ORDER[1],
##             ANGLEUNIT["degree",0.0174532925199433]],
##         AXIS["geodetic longitude (Lon)",east,
##             ORDER[2],
##             ANGLEUNIT["degree",0.0174532925199433]],
##     USAGE[
##         SCOPE["Horizontal component of 3D system."],
##         AREA["World."],
##         BBOX[-90,-180,90,180]],
##     ID["EPSG",4326]]
educacion_SF_geo <- educacion_SF %>%
  st_as_sf(coords=c("long", "lat"), crs=4326)
sf_use_s2(FALSE)
## Spherical geometry (s2) switched off
educacion_SF_geo <- st_intersection(educacion_SF_geo, isocrona)
## although coordinates are longitude/latitude, st_intersection assumes that they
## are planar
## Warning: attribute variables are assumed to be spatially constant throughout
## all geometries
educacion_SF_geo
## Simple feature collection with 35 features and 4 fields
## Geometry type: POINT
## Dimension:     XY
## Bounding box:  xmin: -122.4588 ymin: 37.78171 xmax: -122.4452 ymax: 37.79097
## Geodetic CRS:  WGS 84
## First 10 features:
##                osm_id id isomin isomax                   geometry
## 4969831941 4969831941  1      0      5 POINT (-122.4481 37.78511)
## 4969831942 4969831942  1      0      5  POINT (-122.448 37.78514)
## 2783570633 2783570633  2      5     10 POINT (-122.4539 37.78278)
## 2783570667 2783570667  2      5     10 POINT (-122.4539 37.78292)
## 4969831926 4969831926  2      5     10 POINT (-122.4469 37.78667)
## 4969831931 4969831931  2      5     10  POINT (-122.4499 37.7864)
## 4969831932 4969831932  2      5     10 POINT (-122.4499 37.78633)
## 4969831933 4969831933  2      5     10 POINT (-122.4499 37.78627)
## 4969831934 4969831934  2      5     10 POINT (-122.4498 37.78624)
## 4969831935 4969831935  2      5     10 POINT (-122.4496 37.78619)
summarise(educacion_SF_geo, establecimientos=sum(n()))
## although coordinates are longitude/latitude, st_union assumes that they are
## planar
## Simple feature collection with 1 feature and 1 field
## Geometry type: MULTIPOINT
## Dimension:     XY
## Bounding box:  xmin: -122.4588 ymin: 37.78171 xmax: -122.4452 ymax: 37.79097
## Geodetic CRS:  WGS 84
##   establecimientos                       geometry
## 1               35 MULTIPOINT ((-122.4588 37.7...

Generamos un gráfico de barras que nos muestra la cantidad de establecimientos educativos desde el proyecto Geary categorizado por distancia en minutos.

ggplot()+
  geom_bar(data=educacion_SF_geo, aes(x=as.factor(isomax)), fill="tomato4")+
  labs(title="Establecimientos Educativos - Barrio Presidio Heights",
       subtitle="San Francisco, California",
       x= "Distancia Maxima (minutos)",
       y= "Cantidad de establecimientos educativos",
       caption = "Fuente: OSM")+
  theme_minimal()

Sumamos al mapa de isocronas los establecimientos educativos.

leaflet(isocrona) %>%
  addProviderTiles(providers$CartoDB.Positron) %>% 
  addPolygons(fillColor = ~colorBin("YlOrRd", domain = isocrona$isomax)(isomax),
  color = NA,
  fillOpacity = 0.5) %>%
  addMarkers(data=Geary,
             popup = "Proyecto IZ") %>%
  addCircles(data=educacion_SF,
             popup = ~osm_id,
             color = "black")
## Assuming "long" and "lat" are longitude and latitude, respectively

A continuación ejecutaremos un ruteo desde al proyecto Geary hacia las 5 universidades mas prestigiosas de San Francisco con el objeto de poder obtener distancias y tiempos de viaje.

Obtenemos las direcciones de las 5 universidades.

Stanford <- geo(address = "Universidad Stanford, 408, Panama Mall, Stanford, Santa Clara County, California, 94305, Estados Unidos de América",
             method = "osm") %>% 
            mutate( nombre = "Stanford")
## Passing 1 address to the Nominatim single address geocoder
## Query completed in: 1 seconds
Stanford <- Stanford %>%
  st_as_sf(coords=c("long", "lat"), crs=4326)
Berkeley <- geo(address = "University of California, Berkeley, Derby Street, Elmwood, Berkeley, Condado de Alameda, CAL Fire Northern Region, California, 94720, Estados Unidos de América",
             method = "osm") %>% 
            mutate( nombre = "Berkeley ")
## Passing 1 address to the Nominatim single address geocoder
## Query completed in: 1 seconds
Berkeley <- Berkeley %>%
  st_as_sf(coords=c("long", "lat"), crs=4326)
USF <- geo(address = "University of San Francisco, 2130, Fulton Street, North of Panhandle, San Francisco, CAL Fire Northern Region, California, 94117, Estados Unidos de América",
             method = "osm") %>% 
            mutate( nombre = "University of San Francisco")
## Passing 1 address to the Nominatim single address geocoder
## Query completed in: 1 seconds
USF <- USF %>%
  st_as_sf(coords=c("long", "lat"), crs=4326)
UESF <- geo(address = "Universidad Estatal de San Francisco, 1600, Holloway Avenue, Parkmerced, San Francisco, CAL Fire Northern Region, California, 94132, Estados Unidos de América",
             method = "osm") %>% 
            mutate( nombre = "Universidad Estatal de San Francisco")
## Passing 1 address to the Nominatim single address geocoder
## Query completed in: 1 seconds
UESF <- UESF %>%
  st_as_sf(coords=c("long", "lat"), crs=4326)
AOAU <- geo(address = "Academy of Art University, 79, New Montgomery Street, Transbay, San Francisco, CAL Fire Northern Region, California, 94105, Estados Unidos de América",
             method = "osm") %>% 
            mutate( nombre = "Academy of Art University")
## Passing 1 address to the Nominatim single address geocoder
## Query completed in: 1 seconds
AOAU <- AOAU %>%
  st_as_sf(coords=c("long", "lat"), crs=4326)

Unificamos todas las direcciones en un dataset.

base_universidades <- rbind(Stanford, Berkeley, USF, UESF, AOAU)

Ejecutamos una serie de comandos para luego generar el mapa interactivo.

ruteo_funcion <- function(nombre_origen, lon_origen, lat_origen,
                          nombre_destino, lon_destino, lat_destino)
  {
  ruta <- osrmRoute(src = c(lon_origen, lat_origen),
                    dst = c(lon_destino, lat_destino),
                    overview = "full",
                    osrm.profile = "car")
  
  ruta %>%
  mutate(src=nombre_origen,
         dst=nombre_destino)
}
base_universidades <- base_universidades %>%
  st_set_geometry(NULL) %>%
  mutate(long = unlist(map(base_universidades$geometry,1)),
         lat = unlist(map(base_universidades$geometry,2)))
ruteo2 <- list("Geary", Geary$long, Geary$lat,
               base_universidades$nombre, base_universidades$long, base_universidades$lat)
ruteo2 <- pmap(ruteo2, ruteo_funcion)
summary(ruteo2)
##      Length Class Mode
## [1,] 5      sf    list
## [2,] 5      sf    list
## [3,] 5      sf    list
## [4,] 5      sf    list
## [5,] 5      sf    list
ruteo2 <- ruteo2 %>% 
  reduce(rbind)
summary(ruteo2)
##      src                dst               duration         distance     
##  Length:5           Length:5           Min.   : 2.855   Min.   : 1.256  
##  Class :character   Class :character   1st Qu.:10.443   1st Qu.: 6.958  
##  Mode  :character   Mode  :character   Median :16.815   Median :10.644  
##                                        Mean   :23.036   Mean   :20.416  
##                                        3rd Qu.:32.190   3rd Qu.:26.526  
##                                        Max.   :52.875   Max.   :56.697  
##           geometry
##  LINESTRING   :5  
##  epsg:4326    :0  
##  +proj=long...:0  
##                   
##                   
## 

¿Cual es la universidad que mas cerca esta del proyecto Geary?

  • University of San Francisco (3´ de viaje en auto)
ruteo2 %>%
  filter(distance==min(distance))
## Simple feature collection with 1 feature and 4 fields
## Geometry type: LINESTRING
## Dimension:     XY
## Bounding box:  xmin: -122.453 ymin: 37.77797 xmax: -122.4471 ymax: 37.783
## Geodetic CRS:  WGS 84
##            src                         dst duration distance
## src_dst2 Geary University of San Francisco    2.855   1.2557
##                                geometry
## src_dst2 LINESTRING (-122.4474 37.78...

¿Cual es la universidad que mas lejos esta del proyecto Geary?

  • Stanford (53´ de viaje en auto)
ruteo2 %>%
  filter(distance==max(distance))
## Simple feature collection with 1 feature and 4 fields
## Geometry type: LINESTRING
## Dimension:     XY
## Bounding box:  xmin: -122.4501 ymin: 37.43115 xmax: -122.1555 ymax: 37.78442
## Geodetic CRS:  WGS 84
##           src      dst duration distance                       geometry
## src_dst Geary Stanford   52.875  56.6973 LINESTRING (-122.4474 37.78...
paleta <- c(low="gold", high= "deeppink4")
leaflet(ruteo2) %>% 
    addProviderTiles(providers$CartoDB.Positron) %>% 
    addPolylines(color = ~colorNumeric(paleta, ruteo2$distance)(distance),
                 label = paste("Desde", ruteo2$src, "hasta", ruteo2$dst, "|", "Distancia:", round(ruteo2$distance, 2), "km", "|", "Duración:", round(ruteo2$duration, 2), "min")) %>%
  addLegend("bottomright", pal = colorNumeric(paleta, ruteo2$distance), values = ~distance,
            title = "Distancia",
            labFormat = labelFormat(suffix = "km")) %>%
  addCircleMarkers(data=Geary, ~long, ~lat, 
                   popup = paste("ORIGEN:GEARY"),
                   color="white",
                   fillOpacity = 1,
                   radius=8) %>%
  addCircleMarkers(data=base_universidades, ~long, ~lat,
                   popup = paste("DESTINO:", base_universidades$address),
                   color="gray",
                   fillOpacity = 1,
                   radius=6)

COMENTARIOS FINALES

Luego del análisis del dataset hemos podido dar respuesta a la serie de interrogantes planteados en en la introducción del presente trabajo.

Hemos podido evidenciar la experiencia que posee la Ciudad de San Francisco respecto a la normativa de zonificación inclusiva y a la construcción de viviendas asequibles.

Se ha evidenciado que la integración de unidades asequibles en áreas claves de la ciudad ofrece mejores oportunidades (en el caso del presente estudio, educativas) especialmente para los deciles mas bajos de la sociedad.

Final del TP.-