Comunidad Valenciana population(d3v4)
A choropleth map of the Comunidad Valenciana depicts population density per census tract, with a legend encoding values from pale yellow to dark red. The visualization uses `d3.geoPath` to render the regions and `d3.scaleThreshold` for the color bins, showing population per square mile. Census tract boundaries are outlined, and municipal borders are drawn via `topojson.mesh`. The data comes from the 2011 Spanish census and municipal shapefiles, processed into a TopoJSON file.
AI-generated descriptionSource: Census data and shapefile Ine, municipios polygons datos.gob.
I used a bash script I to filter from government's files and get the shapefiles I would use:
Isolate Comunidad Valenciana census polygons
ogr2ogr \
-where "CCA = '10'" \
cv/shapes/CV.shp \
cartografia_censo2011_nacional/SECC_CPV_E_20111101_01_R_INE.shp
Shame for municipios
ogr2ogr \
-where "CODNUT2 = 'ES52'" \
cv/shapes/munis.shp \
recintos_municipales_inspire_peninbal_etrs89/recintos_municipales_inspire_peninbal_etrs89.shp
reproject each shapefile and export to GeoJSON
ogr2ogr \
-f "GeoJSON" \
-t_srs "EPSG:32630" \
cv/shapes/census.json \
cv/shapes/CV.shp
ogr2ogr \
-f "GeoJSON" \
-t_srs "EPSG:32630" \
cv/shapes/munis.json \
cv/shapes/munis.shp
Then I use QGIS to create an unique ID from several fields for each polygon to could join with the csv.
Join the data, preserve some properties, simplify, and merge both shapefiles in one json.
"The resulting TopoJSON file has the 2011 estimated population of each census tract as the population property, and the land area in square meters as the area property. We will divide one by the other and converting to square miles".
topojson \
-e data.csv \
--id-property CUSEC,cod \
-p population=+t1_1,area=+Shape_area \
-s 1 \
--width 750 \
--margin 10 \
-o cv.json \
-- cv/shapes/census.json cv/shapes/munis.json
This recipe is in the bash script in this gist repo.
Mostly everything comes from Mike's block.