This article describes how to join country geometry from GISCO with attribute data from EUROSTAT and save it as GeoJSON. This type of GeoJSON is great for creating choropleth maps. We will also cover how to upload GeoJSON to MapTiler Cloud.
If you want to merge our country dataset with your data, read this article. In this tutorial, we cover data preparation for a web choropleth map. If you want to create such a map, we recommend that you read tutorials that show how to add GeoJSON to a map with Maplibre, leaflet, or the OpenLayers library.
Prepare the data
We will work with data from EUROSTAT.
-
Get geometry of European countries. (The geometry layer doesn't have to be in GeoJSON format. The GeoJSON format will be created by export of geometry joined with attribute data).
PRO TIP: The Whole Europe is visible approximately on zoom 3, corresponding to 1:73,957,338.86 map scale in 96 dpi. You can read more about map scales and zoom levels here. The best scale for our choropleth map is 1:1 000 000. Of course, it is possible to change geometry generalization as you go through zoom levels.
-
Get categorical or quantitative data, which will be displayed in the choropleth map.
Remember that you should have relative values, such as population density, for the choropleth map, not the number of people. We will use categorical data of the mean age of women at first marriage in 2019, which can be filtered from the Marriage indicators dataset. (Filters - Time: 2019, Geopolitical entity: countries, Demographic indicator: mean age at first marriage - females)
PRO TIP: In the format tab, select codes instead of labels. These codes are better suited for connection with a geographical representation.
- Remove the spreadsheet's header and footer and rename the headers of each column, ideally to one word without spatial characters. The final document should have just one sheet with two columns named GEO_code and Age.
Join of spatial and attribute data
- Open QGIS.
- Open the edited table with the mean age of women at first marriage as a layer
- Select CNTR_RG_10M_2020_4326.geojson from GeoJSON countries. Right-click on CNTR_RG_10M_2020_4326.geojson layer and select properties → joins → green plus signWell done! You just joined spatial data with attributes. (However, this is just a temporary connection which will become permanent after export. CNTR_RG_10M_2020_4326.geojson layer contents countries of the whole world, but we want to have final GeoJSON only with countries that have values.)
-
Select only countries with value
Right-click on CNTR_RG_10M_2020_4326.geojson → open attribute table → select feature using an expression: "Age" is NOT Null and "Age" is NOT ':' This expression will select just countries with some value.
Now it's good to check if our Age column is a number. If it's a number, the numbers will be alight to the right. If age is not a number, create a new field (decimal number (real) size 3 precision 1) and save values to it with the expression “Age”.
- Export: right-click on CNTR_RG_10M_2020_4326.geojson layer → export → Save Selected Features As and name it. In this phase, it is also possible to remove unnecessary attributes such as FID, CNTR_ID Age, or ISO3_CODE.
Upload GeoJSON to MapTiler Cloud
Go to MapTiler Cloud - maps in the Left Menu, select Data, and then select NEW DATASET.
Useful links
Zoomable choropleth map from GeoJSON with MapLibre
Zoomable choropleth map from GeoJSON in Leaflet
Countries' geometries from EUROSTAT
Marriage indicators dataset
Comments
0 comments
Please sign in to leave a comment.