block by martgnz 1b7ba8ebd60a1567e855

Choropleth map

Full Screen

A simple choropleth map with the foreign population of El Maresme extracted from IDESCAT. It uses d3-tip for the tooltip.

Generating the GeoJSON

  1. Download the Base Municipal 1:50 000 SHP from the Institut Cartogràfic de Catalunya website. You need to register first.
  2. Extract it and note the bm50mv33sh1fpm1r170.shp shapefile. These are the municipalities that we need.
  3. Open a terminal in the extracted folder and convert the shapefile it to GeoJSON using the following ogr2ogr2 snippet:
ogr2ogr \
  -f GeoJSON \
  -where "NOM_MUNI IN ( 'Alella', 'Arenys de Mar', 'Arenys de Munt', 'Argentona', 'Cabrera de Mar', 'Cabrils', 'Caldes d''Estrac', 'Calella', 'Canet de Mar', 'Dosrius', 'Malgrat de Mar', 'El Masnou', 'Mataró', 'Montgat', 'Palafolls', 'Pineda de Mar', 'Premià de Dalt', 'Premià de Mar', 'Sant Andreu de Llavaneres', 'Sant Cebrià de Vallalta', 'Sant Iscle de Vallalta', 'Sant Pol de Mar', 'Sant Vicenç de Montalt', 'Santa Susanna', 'Teià', 'Tiana', 'Tordera', 'Vilassar de Dalt', 'Vilassar de Mar', 'Òrrius')" \
  -t_srs 'EPSG:4326' \
  maresme.json \
  bm50mv33sh1fpm1r170.shp

Possible improvements: insert the scale of the choropleth buckets like this example and use TopoJSON for a smaller footprint.

index.html

dades.csv