In one of my many 'playing around with map stuff and then posting it on twitter' adventures, I recently posted a kind of comet map - see below. This started off as something completely different but once I had the basic idea I then wondered what kind of data I could apply it to, and that's why I did it to the UK political map of 2019. Read on below for how I did it, as well as how you can replicate it pretty easily in QGIS. Scroll straight to the bottom if you're just looking for the 'how-to', as well as a bit more on how this kind of thing might work on a US county-level election map.
First of all, this was done in QGIS. I'm sure it could be done lots of ways, but I did it in QGIS using something called 'geometry generator', which is basically just a little bit of code that can be used to style things more fancily than just clicking a button and selecting a colour and shape.
Map of the day is a very comet-style UK general election 2019 map experiment, where— Alasdair Rae (@undertheraedar) October 7, 2022
- colour of dot = winning party
- comet trail colour = second place
- comet train length = how far behind second place was
(dot is just a coloured centroid, see Alt text for QGIS geom gen code) pic.twitter.com/tx04FYxkIX
|A basic line, within each area's bounding box|
|Big pile of red sticks drifting into space|
|A cometmap emerges from the darkness|
- Use a circle in the centroid of each constituency, using party colour to indicate who won that seat.
- Use a tapered buffer behind each coloured circle, with the colour of the party who came second.
- The length of the comet trail is dictated by the winning margin - so if a party is WAAAAAY behind the winner then it gets a longer trail. So this map draws attention more (deliberately) to the second placed party. But of course any of this can be edited.
- The size of the circles and buffer is a few thousand metres but of course that can be adjusted too. See the results below.
|Dot with no trail? Means it's very close|
|Loooong blue trails? Conservatives waaaay behind|
|Mostly short trails = mostly quite close results|
|THE LIBERAL DEMOCRATS ARE COMING!!!!|
How to replicate this style in QGIS
- First of all, you'll need to grab the UK General Election 2019 results file from my Automatic Knowledge resources page. Use the GeoPackage because it's easiest.
- Add the file to QGIS.
- Optional step. For exact duplication of my maps, make the QGIS background very dark grey (e.g. #111111) and make duplicate the UK general election layer and make it dark grey, both fill and stroke colour (e.g. #333333) so that when you make the comets they look brighter and have a dark backdrop and you can also get your bearings from the plain dark backdrop.
- Download the cometmap layer style file to your computer. This is just a standard QML file and you'll apply it in the next step.
- Go the Layer Properties for the layer you want to apply the cometmap style to and then via the Style button at the bottom of the Layer Properties window, and then it's Load Style... browse to the cometmap-ukge-2019-example.qml file on your computer, then it's Open, Load Style and OK - and that should be it!
- Once you've done this you can inspect the properties of the style yourself and edit them if you want to - see screenshot below.
|How the trail is generated - rotation set to zero right now|
|The '97' in the html colour values sets the opacity|
|Done very quickly, just to test the method|
|You can see where this needs work - but it could work|
|Just a few tweaks needed here!|
|That'll do it for now|
Needlemaps - the next frontier
|Lots of ways this could be edited/improved|
|Yeah, not surprising|
|Big 'lean left' energy going on here|
|Actually quite interesting here I think|
|Lots of interesting stuff here, for sure|