I've previously posted a couple of QGIS tutorials aimed at historians who don't have a lot of GIS experience, but who still wanted to create professional-looking historical maps. Those tutorials covered importing Natural Earth datasets into QGIS; some basic layout styling; making custom "point" markers for cities or other features you wanted to call attention to; and then setting up a print layout view for PDF-ing. All good stuff!
In this wee blog post I'm going to cover a nice-to-have skill: making some more customisable "regional labels" for your map. In contrast to the "point" labels we made earlier, these aren't meant to signify one particular place, but rather a large decentralised area: an ocean, a forest, a mountain range, maybe even a province or country. We're going to start with the most straightforward way of doing this, and then play around with some slightly-more-advanced QGIS concepts to make them a bit more customisable. That means that I've divided the blog post into three methods; all assume that you're already working on a base-map of some part of the world that you've more-or-less set up as per the previous tutorials (I'm going to use my native Aotearoa). As you'll see, the methods get increasingly fancy-looking, but for some purposes the easiest option (method one) is going to work just fine.
I want to acknowledge right off the bat that I got a lot of inspiration for these methods from Klas Karlssen's incredible YouTube tutorials, particularly his quick tip video on "super nice labels." His labels are, indeed, super nice; but as he recorded that some time ago the QGIS interface now looks and feels a little different, and I also wanted to simplify one or two steps for the sake of accessibility. With that out of the way, let's crack into it!
method one: a hidden point layer
The short version: create a new point layer; make points whereever you want your labels to appear; hide the points.
The longer version: let's start by creating a new point layer! You can do this by opening the "Layer" menu, then "Create Layer." You can either create either a new Shapefile layer, as we did in previous tutorials, or a Geopackage layer; they're pretty much interchangeable for our present purposes. Real GIS people apparently have strong feelings about the superiority of Geopackages - but because I'm not a real GIS person, merely a historian pretending, I shall opt for a Shapefile.
Choose geometry type "point," and create a field of type "text" called something like "label_name". That way you'll know it's where you're going to name your labels. Remember to hit "Add to Fields List" once you've given it a name! Then hit "Ok."
Now just create your labels exactly as you would for cities or other specific features. Go into Edit mode, click "Add Point Features" and start clicking where you'd like labels to appear.
For now you'll just have a bunch of points - that's okay! Click the edit button again to save all your lovely new points.
Now double-click your regional layer in the layer panel to open the layer properties.
Open the "Labels" tab and change the drop-down at the top from "No labels" (which should be the default) to "Single Labels".
(we'll get into Rule-based Labeling one day, promise. It's great).
Okay - format to your heart's content! I recommend making these labels slightly larger, and a bit transparent, to make them seem more "background-y," but based on the fact that I said "background-y" you can make a reasonable judgement about my levels of design sensibility. You are the cartographer, you make your choices!
Once you're happy with the general font etc., head on down to "Placement" (still within the Labels tab).
This is where you decide where your actual labels appear relative to where you actually made the point. If you're not happy with the position they've ended up in on "Cartographic" mode, try "Offset from point." Play around and see what looks nice!
Finally, let's get rid of those pesky point markers. Click over to the Symbology tab and simply do the reverse of what you did for Labels - change it from "Single symbol" to "No symbol."
If you left it on Cartographic label placement, you might find that you need to hop back to that tab and jiggle things around more. But eventually you'll end up with something that looks good enough:
My problem is that the islands themselves are very much on the diagonal, so it's a little jarring to have the labels all sticking out sideways into the Pacific. I could use the Label placement options to rotate them, of course, but then the label for Rakiura (Stewart Island, or as I've chosen to call it "More South Island") might collide unpleasantly with the bottom of Te Wai Pounamu (the South Island). If only I could angle them all individually...
method two: labels on lines
(NB: I'm assuming that you've read all of method one before getting here, so I don't need to be as specific when I say things like "go to Symbology")
This method gives lovely curved, angular lines, which I find are perfect for fitting inside or alongside more stretched-out geographic features like mountain ranges, forests or my own lovely homeland. They also look quite nice for writing out the names of large regions or countries - there's something slightly nostalgic about a curvy label.
For this method, as the name suggests, we're going to create a new layer with a "line" geometry rather than "points." Everything else is exactly the same as above:
This time rather than selecting a single point we'd like our label to eventually appear near to, we're going to draw a line (from left to right) we'd like to write our label on top of. That line can be on any angle, and even curved, which allows us to get pretty creative!
Left click whereever you'd like your first label-underline to start. When you move your cursor away from that point, you should see a red dotted line connecting you to it. Apparently my cursor doesn't show up well in the screenshot.
Left click whereever you'd like the next point in your line to be. If you just want to draw a straight line, then that's just the end of the line. If you want a nice curve, you can keep clicking to add new points:
When you're done drawing your line, right click (or whatever the Mac equivalent is...?) and you should see the same field-entry box as before. Fill it out, then go make the rest of your lines! Here's my three:
Now it's the same drill as above: no symbols, single lines, format as you like, then head down to Placement. This time let's set it to Curved mode.
Hmmm. That doesn't look great to me. The lines for my top islands are a bit wonky, and the line for Rakiura is so short that it can't even fit the label on it.
But that's okay! Let's just edit the lines. Start by clicking the Edit mode button. Then you're going to use the Select Features by Area tool to select one of the offending lines. (note which buttons are selected in my toolbar in the screenshot below).
Now choose the Vertex Tool (right next to Add Line Feature in the Edit toolbar), and simply click the red vertices (points along the line) and select new locations for them until you're happy with how the label looks. Then repeat for your other lines until all the labels look great. You can also do this for points in a point layer, just so you know! Here's my modified line for Te Wai Pounamu:
I find it's so much easier to modify these lines once the labels are already set up. You can just see what you're doing so much more clearly. Don't forget to close edit mode and save once you're done! Here's my final attempt with this method (not great but good enough for a tutorial I meant to only spend fifteen minutes writing up):
I'm still not totally happy with Rakiura ("Nice Island") yet. It just seems disproportionately large, so no matter how much I fernangle the lines it just doesn't look right. If only there were some way I could control all the font sizes individually...
method three: variables are amazing
To get total customisation of each individual layer, we're going to create some new fields (like the "regional_name" field we're using to display our labels) for each feature, and then set those fields to override the default font size if we enter anything into them. It's easier than it sounds - and once you get your head around this, anything is possible in QGIS.
We've previously only been adding fields when we create a new layer. But you can add them to an existing layer too. Right-click our regional_labels layer and open the attribute table.
You'll see a table which, at the moment, only contains one column - the "name" field we made when we created this layer - and a separate row for each individual feature we've created. Mine looks like this.
Up in the top left you'll see what looks a lot like an Edit mode symbol. Hit it! Other buttons should become available. We're looking for the "New Field" button.
Let's create a field called "font size". Make sure it's an Integer type field, with a length of at least two (the default is 10, which is plenty).
A new column should appear in your Attribute Table! For now let's just leave it blank, hit the Edit mode button again to save our changes, and head back over to Layer Properties. Go to the Label tab, then the Text sub-tab. Next to the font Size option, click on the "Data Defined Override" symbol:
Click it, then select "Field type". You should see a list of all the fields in this layer, including your new "font size" field - select that one! The Data Defined Override button will turn an ominous shade of yellow to let you know it's working, though you won't see any changes on your map yet.
Here's how this works. As the name suggests, a Data Defined Override uses any data in the defined field (your new "font size" field) to over-ride the default font size. Since we left those fields blank earlier, there's no data to override with, and all your labels stay at the default. But if you go back into your Attribute Table, toggle Edit mode, and enter a new font size for any one of your features...
Wham! Now you can edit the font sizes of any individual feature, as well as altering the line it sits on as per method two above. But you still have default formatting in place, so you can very quickly add new features en masse and only use the Data Defined Overrides as you need them. Here's my final map, once I'd played with both font size and line for Rakiura.
But here's the really exciting bit: you might have noticed that nearly every formatting option in QGIS, including Symbologies, can have Data Defined Overrides. In the YouTube tutorial I linked at the beginning of this post, Klas Karlsson uses them to control the size, spacing, and even colour of his labels. And there's really no limit - do you know the approximate population of your cities? Why not enter that into a field in your Attributes Table and set that up to control the size of your point marker Symbology? In a future post I'll also try and give a basic introduction into some useful "expressions," which is QGIS's way of transforming that data into yet more creative and interesting ways - so that you could change the colour of a road based on how far from Rome it was, for example? So many possibilities - but for now, happy labelling!
About this blog
I'm mostly using this to archive Twitter threads in a slightly more read-able format. No content final.