library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.4 ✔ readr 2.1.5
## ✔ forcats 1.0.0 ✔ stringr 1.5.1
## ✔ ggplot2 3.5.1 ✔ tibble 3.2.1
## ✔ lubridate 1.9.3 ✔ tidyr 1.3.1
## ✔ purrr 1.0.2
## ── 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.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
partidos_amba <- st_read("data/partidos_amba/partidos_amba.shp")
## Reading layer `partidos_amba' from data source
## `/Users/angiescetta/Desktop/FEPP-DATOS-01/data/partidos_amba/partidos_amba.shp'
## using driver `ESRI Shapefile'
## Simple feature collection with 48 features and 3 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: -59.3392 ymin: -35.23893 xmax: -57.70946 ymax: -34.23007
## Geodetic CRS: WGS 84
ggplot()+
geom_sf(data=partidos_amba, aes(fill=area_km2))+
scale_fill_viridis_c(direction=-1)+
labs(title="Partidos del AMBA")
ggplot()+
geom_sf(data=partidos_amba, aes(fill=provincia))
ggplot()+
geom_sf(data=partidos_amba, aes(fill=nombre), show.legend = FALSE)
datos_amba <- read.csv("data/amba_properati2021.csv",
encoding="latin1")
datos_amba_venta <- datos_amba %>%
filter(operation_type=="Venta") %>%
group_by(partido) %>%
summarise(cantidad=n(),
valor_m2=mean(price/surface_covered))
partidos_amba <- left_join(partidos_amba, datos_amba_venta, by=c("nombre"="partido"))
ggplot()+
geom_sf(data=partidos_amba, aes(fill=valor_m2))+
scale_fill_viridis_c(direction=-1)+
labs(title="Partidos del AMBA")
ggplot()+
geom_sf(data=partidos_amba, aes(fill=cantidad))+
scale_fill_distiller(palette = "Spectral")+
labs(title="Partidos del AMBA")
ggplot()+
geom_sf(data=partidos_amba, aes(fill=cantidad/area_km2))+
scale_fill_distiller(palette = "Spectral")+
labs(title="Partidos del AMBA")
ggplot()+
geom_sf(data=partidos_amba)+
geom_sf(data=filter(partidos_amba, cantidad>=300), aes(fill=cantidad/area_km2))+
scale_fill_distiller(palette = "Spectral")+
labs(title="Partidos del AMBA")
A continuación…
ggplot()+
geom_sf(data=filter(partidos_amba, provincia=="CABA"), aes(fill=cantidad/area_km2))+
geom_sf_text(data=filter(partidos_amba, provincia=="CABA"), aes(label=nombre), size=1.5)+
scale_fill_distiller(palette = "Spectral")+
labs(title="Partidos del AMBA")
## Warning in st_point_on_surface.sfc(sf::st_zm(x)): st_point_on_surface may not
## give correct results for longitude/latitude data