Skip to content

Instantly share code, notes, and snippets.

@bastianolea
Created December 17, 2025 20:00
Show Gist options
  • Select an option

  • Save bastianolea/0fc32985c92ffb569bcf3776f391163b to your computer and use it in GitHub Desktop.

Select an option

Save bastianolea/0fc32985c92ffb569bcf3776f391163b to your computer and use it in GitHub Desktop.
Código para visualizar mapas con los datos del Censo 2024 a nivel de manzana
# código para visualizar mapas con los datos del Censo 2024 a nivel de manzana
library(dplyr)
library(arrow)
library(sf)
library(ggplot2)
# cargar datos
manzanas <- read_parquet("datos/Cartografia_censo2024_Pais/Cartografia_censo2024_Pais_Manzanas.parquet")
manzanas |> names()
manzanas |> glimpse()
# filtrar
manzanas_comuna <- manzanas |>
filter(COMUNA == "LA FLORIDA")
# convertir a sf
manzanas_comuna_sf <- manzanas_comuna |>
st_as_sf(crs = 4326)
# gráfico
manzanas_comuna_sf |>
ggplot() +
aes(fill = n_edad_60_mas) +
geom_sf(color = "white", linewidth = 0.1) +
scale_fill_fermenter(palette = 13) +
theme_minimal(base_size = 10) +
theme(axis.text.x = element_text(angle = 90, vjust = .5)) +
guides(fill = guide_legend(title = "Población 60 años y más",
position = "top")) +
labs(title = "Población de 60 años y más por manzana",
subtitle = "Comuna de La Florida, Censo 2024",
caption = "Fuente: Censo 2024, INE")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment