Natural Earth Data in QGIS 3: Part 2

Natural Earth ocean and shaded relief
Click to enlarge
Prepared from Natural Earth data

Last time, I described how I used free Natural Earth data and the software package QGIS to produce a basic map of Alaska and its surroundings, shown above.

This time, I’m going to lay some more vector datasets on top of this map to make it a little more useful. First, I want to add political boundaries, using some vector data I downloaded previously: Admin 0 – Countries, Admin 0 – Boundary Lines, and Admin 1 – States, Provinces from Natural Earth’s Cultural Vectors page. In my last post, I described how I’d unzipped all these files into the same folder on my hard-drive, and then batch-processed them to clip away all the data I didn’t need.

First of all, I go through Layer>Add Layer…>Add Vector Layer… in the top menu, and navigate to the directory containing my clipped files, to which I added the prefix alaska_ during processing, last time. The original Natural Earth shape file was ne_10m_admin_0_countries.shp, so I’m opening alaska_ne_10m_admin_0_countries.shp. This dumps a set of opaque polygons of uniform colour on top of my nice shaded-relief map.

Natural Earth country polygons
Click to enlarge
Prepared from Natural Earth data

We can see the international boundary between Alaska and Canada, and also an ugly seam running along the 180° meridian across the Russian Chukchi peninsula and Wrangel Island. To get rid of this artefact, I can adopt the same strategy I used when I encounter the 180° seam in the ocean—set the polygon colours and borders to the same shade. But first I need to find a way to colour the USA, Canada and Russia in different shades.

I do this by double-clicking on the countries layer in the “Layers” window, to the left of the map window, to bring up the Layer Properties dialogue, and then selecting Symbology from the options at the left of that box. From the drop-down box at the head of the dialogue window, I select “Rule-based”. This brings up a default, blank rule for shading the country polygons, marked “no filter”.

Blank rule-based symbology in QGIS

By double-clicking on that “empty” rule, I bring up the Edit Rule dialogue, which is where most of the action is going to be happening as I add further layers. I’m going to call my rule “Russia”. I change the colour for this country to a pale pink, and set its transparency to 50%, so that my shaded relief will show through.

Edit Rule for country polygons in QGIS
Click to enlarge

To make sure the border is the same colour as the rest of the country, I click on Simple Fill to bring up some more polygon properties, which lets me change “Stroke Color” to match “Fill Color”.

But I still need to define the rule by which QGIS can identify which polygon is Russia, and shade it accordingly. So I click on the button marked with a little curly epsilon (ε) character, next to the “Filter” text box.

Another dialogue opens up, the Expression String Builder. Here, I can access the various data fields attached to each Natural Earth polygon. In the centre panel I click on “Fields and Values” to drop down a list of all the data fields that are associated with the Natural Earth country polygons. “SOVEREIGNT” looks promising, and I confirm this by clicking on the All Unique button, which shows me that my clipped country file contains polygons linked to Russia, USA, Canada, and Denmark (I included a corner of Greenland when I trimmed the file).

Expression String Builder in QGIS
Click to enlarge

Now to create my filter rule, I can double-click on “SOVEREIGNT”, type an equals sign, and then double-click on “Russia”. This creates an expression in the left panel that looks like this:

“SOVEREIGNT” = ‘Russia’

It’s easy enough to type this sort of stuff in yourself, but notice that the field name needs to be enclosed in double quotes, while the field value is in single quotes.

Clicking on OK a couple of times gets me back to the Layer Properties dialogue, with my new rule in place. I can now repeat this process to create additional rules, assigning colours to the USA and Canada—clicking on the little green cross at bottom left brings up a new Edit Rule dialogue. Here’s the final set of rules:

Rule-based symbology for selected countries in QGIS
Click to enlarge

And the effect on my map:

Natural Earth topography and country shades in QGIS
Click to enlarge
Prepared from Natural Earth data

I’d like to emphasize the country borders and the coastline a little more, as well as showing provincial borders in Canada, so I add three more layers, using files I downloaded and clipped last time: alaska_ne_10m_coastline.shp, alaska_ne_10m_admin_0_countries.shp, and alaska_ne_10m_admin_1_states_provinces_lines.shp. By opening the Layer Properties dialogue and editing Symbology, I can assign suitable colours and widths to each of these. I also want to see only Canadian internal boundaries, so I can set up a rule-based symbology for that file like this:

“ADM0_NAME” = ‘Canada’

Natural Earth Alaska with borders in QGIS
Click to enlarge
Prepared from Natural Earth data

Now I’d like to add some more detail. So I download “rivers and lake centerlines” and “lakes & reservoirs” from Natural Earth’s physical vectors page, unzip, them into my master directory, and clip them down to my area of interest using the process I described in Part 1. Once the *.shp files are added as new layers, and their symbology edited for colour, my map looks like this:

Natural Earth Alaska in QGIS with borders and watercourses
Click to enlarge
Prepared from Natural Earth data

(The lakes layer needs to go on top of the rivers layer.) I’m not entirely happy with the depiction of the Mackenzie River delta, which is notoriously complicated, and a bit under-represented in Natural Earth’s basic dataset. So I download the “North America supplement” for rivers, clip it, and add it as another layer. This turns out to add far too much detail for this scale of map, and I’m really only interested in enhancing the appearance of the Mackenzie Delta, so (after poking around to discover the correct field names) I set up a rule-based symbology:

“name” = ‘Mackenzie

This excludes all the other rivers and draws only those that have been labelled as belonging to the Mackenzie. Here’s a before-and-after to show the effect of the extra data:

Natural Earth Mackenzie Delta in QGIS, with and without North America supplement
Click to enlarge
Prepared from Natural Earth data

It would be nice to add names to the rivers, and these can be turned on by going through the Layer Properties dialogue and selecting Labels from the choices at left. First, I use the “Value” drop-down box at the top of the dialogue to look at a list of all the data fields Natural Earth has associated with the rivers, and select the option “name”. (In the hurry to configure all the other options available, I often forget to choose the “Value” entry, and end up with no labels at all.) Then, under “Text”, I can select a nice text colour, and, under “Placement”, choose how the labels align with the river courses—I chose “Parallel”. But there’s a problem when I apply these edits—some of the river names appear twice, with one of the names superimposed on a lake. This is because (as the name implies) the “rivers and lake centerlines” dataset also includes segments that mark the centre-lines of lakes—so there’s a river labelled “Mackenzie”, but a lake centre-line with the same label, and that label turns up annoyingly superimposed on Great Slave Lake.

Time for some rule-based labelling. The data field “featurcla” tells us whether a given feature is a river or a lake centre-line, so I can set my labels to appear only when

“featurecla” = ‘River’

Setting up Natural Earth river labels in QGIS
Click to enlarge

Finally, I’d like to label some of the larger lakes, without cluttering the map with names on every lake. The Natural Earth dataset helpfully includes a field called “scalerank”, which classifies features by their approximate size, and a bit of experimentation reveals that I can get the effect I want using rule-based labels with

“scalerank” BETWEEN 0 and 2

Which demonstrates that we can do all sorts of logical tests on fields to get the desired result. More on that next time, when I’ll add some artificial features like roads and settlements.

Natural Earth Alaska with rivers and lakes in QGIS
Click to enlarge
Prepared from Natural Earth data

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.