Create an Animated Choropleth Map

7. Join Temporal Data with Polygons

Our temporal data is now ready, but lacks the geometry. We need to join the attributes to the country boundaries. We can't use the regular join that we've used before, because we have multiple years for each polygon, i.e. there's a one-to-many relation. In the next steps we'll join the data in such way that there's a separate feature for each matching feature.

1. In the Processing Toolbox go to Vector general | Join attributes by field value.


2. In the Join Attributes by Field Value dialog choose country_boundaries as Input layer, ISO3CD as Table field, number-without-improved-water as Input layer 2 and Code as Table field 2. Note that ISO3CD and CODE are the common key for the join, which are the 3 character country codes.

3. Click  under Layer 2 fields to copy and choose the Percentage and Date fields. Click the blue arrow to go back.


4. Under Join type use the dropdown menu to choose Create separate feature for each matching feature (one-to-many).

5. Save the layer in the GeoPackage with the layer name percentage_without_improved_water.


6. Click Run and Close the dialog after processing.

7. Check the attribute table of the percentage_without_improved_water layer which has now been added to the Layers panel.

Now you can see that it has for each country all the years with the percentage of population without access to improved water sources.


8. Save the project before we continue with styling the data.