Skip to content

Instantly share code, notes, and snippets.

@LuisSevillano
Last active October 24, 2016 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LuisSevillano/a5d147cd45c624e8811238f0a5480439 to your computer and use it in GitHub Desktop.
Save LuisSevillano/a5d147cd45c624e8811238f0a5480439 to your computer and use it in GitHub Desktop.
Comunidad Valenciana population(d3v4)
license: gpl-3.0
border: none
height: 1370

Source: 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.

Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment