Análisis mediante Python y Geopandas
import os
os.chdir('work directory')
import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
gdf = gpd.read_file('comunas.shp')
gdf
print(f"{type(gdf)}, {gdf.geometry.name}") # Displays the name of the 'geometry' column in the shapefile
print(gdf.head())
print(gdf.geometry.geom_type.value_counts())
df = pd.read_csv('data.csv')
df
full = gdf.merge(df, left_on="CUT", right_on="id_comuna")
colors = 5 # La variable a desplegar (GSE) posee 5 categorías
cmap = 'Blues'
figsize = (16, 10)
title = 'Metropolitan Region of Chile: comunas by Socioeconomic level, 2025'
full.plot(column='GSE', cmap=cmap, figsize=figsize, k=colors, legend=True, aspect=1)
plt.title(title, fontdict={'fontsize': 18}, loc='center')
plt.show()