[Tutorial] QGIS for Fictional Cartography

  • Thread starter Deleted member 101966
  • Start date

Deleted member 101966

QGIS for Fictional Cartography
The last map tutorial anybody will ever need

Have you ever spent more than 5 minutes tracing borders off an image of a map by hand?

Did it make you wonder what the "professionals" do?

BGD315.png


AH.com user hard at work, c. 1985


If you've hung around here long enough, you probably already know computers are involved: you need GIS, the clunky acronym (geographic information system) describing software that handles spatial data. Why care?

- Since most of the world's topography was long ago committed to digital format, GIS makes tracing rivers and land features off other maps completely unnecessary.

- The U.S. government makes all of its satellite elevation data free to download. With these files, contours and shaded relief become effortless.

- Objects with thousands of nodes bring artistic vector graphic programs like Inkscape grinding to a halt. GIS is designed for computation and loads complex data hundreds of times faster.

- Setting your work to a different map projection takes one click.

This is the most recent ahistorical map I've created with GIS. Working at a pretty relaxed pace, it took less than a week to go from concept to completion:



Fictional dirt roads, fictional potato farms, and fictional unincorporated communities. It's never been so easy to distract yourself from working out the actually consequential details of a timeline!


For a long time, none of this mattered very much to non-professionals, because the ESRI corporation used its complete lockdown on the GIS industry to charge thousands of dollars for its ArcGIS software. ArcGIS still dominates the corporate and government sectors, but a community effort created a free open-source alternative called QGIS. Another significant 2010s trend is that more and more governments have started to make their geo-data available for free download. GIS is more accessible than it ever has been, so what's your excuse?

Oh, right - nobody's ever written a tutorial about how to use the program to draw excellent alternate history maps! The currently existing documentation spread around the Internet is OK but dense as hell, especially since the idea of using GIS to create fiction is unknown to most technical writers. So, after spending years grumbling about how many people are wearing out their wrists for no good reason through excessive tracing, I've set out to gradually explain QGIS from start to finish.

I'll try to keep the updates coming at a reasonable pace, but until then, here's how to prepare yourself for them...

- Download and install QGIS, natch.

- Get Inkscape too. QGIS does most of the work, but Inkscape is necessary for three final touches: creating curved labels, adding last-pass design elements to a map, and drawing custom vector assets.

- QGIS is a data handling program, so your results will only be as good as the data you have on hand. Start by downloading all of Natural Earth, the 1:10M set of vector data used by most Wikipedia maps.

- Register a free account with the U.S. government at EarthExplorer to download everything that NASA gets when it points its cameras down instead of up. This is an ideal source of global elevation data, among many other things.

- Start poking around on Statistics Canada's 2016 census boundary files page, because I'm probably going to flex my hometown bias by incorporating these downloads into future tutorials.

- QGIS is pretty complicated and some questions won't be easily answered by forum posts. To help solve this problem, join Next-Year Country, the Discord server I made to accompany this thread! Ping @ksituan and I'll get back to you, as long as you don't mind sharing space with the furry bible study group I intend to run in the same place simultaneously.
 
Last edited by a moderator:
Importing Google Web Layers

Deleted member 101966

Importing Google Web Layers

Have you ever wished you could just take Google's satellite imagery and draw on top of it? What about setting it to an arbitrary projection? QGIS does both. (This is also good practice for importing layers, because the subject matter should already be familiar.)

unknown.png


The program is pretty dauntingly complicated, and my UI is a bit souped-up from regular use. For now, we're just concerned with right-clicking the XYZ Tiles item in the Browser menu...

upload_2019-1-2_11-9-36.png


Bashing "New Connection" gets you the following window. Here are the necessary URLs:

Google Maps - https://mt1.google.com/vt/lyrs=r&x={x}&y={y}&z={z}
Google Satellite - http://www.google.cn/maps/vt?lyrs=s@189&gl=cn&x={x}&y={y}&z={z}
Google Satellite Hybrid - https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}
Google Terrain - https://mt1.google.com/vt/lyrs=t&x={x}&y={y}&z={z}
Google Roads - https://mt1.google.com/vt/lyrs=h&x={x}&y={y}&z={z}

upload_2019-1-2_11-12-36.png


Once you've added all the Google layers of your dreams, just double-click the one you want, and...

unknown.png


Click the "EPSG: 3857" tab in the lower-right corner. This is where you manage your CRSes (co-ordinate reference systems, synonymous with "projections"). When importing them into a new project, QGIS will automatically detect that Google Maps tiles use a Mercator variation as their native CRS, hence the "3857" number (every CRS has a unique code). Luckily, this is eminently customizable.

upload_2019-1-2_11-17-9.png


This is the menu where you can pick whatever CRS you'd like. For demonstration purposes, we'll go with World Robinson, and...

unknown.png


upload_2019-1-2_11-24-11.png


Assert your dominance by microwaving New Zealand.

[Source]
 
Last edited by a moderator:
Thanks a lot, Qgis is a very powerful tool and it's hard for me to go back to tracing with inkscape after using QGis, there is a lack of good tutorials for it and this thread is worthy of a sticky IMO. A lot of people would gain from knowing how to use this software.

You make some really awesome maps, it would be great if you could share the databases you use for them (and the other you know), i've found that natural earths quickly becomes insufficient when making more detailled maps.

Could you also explain a bit how one can edit the database, like editing coastlines or adding cities, that would be great for all the sci-fi/fantasy and alternate earth mapmakers!

Also not sure how relevant it is , but the Stackexchange subforum for general GIS is helpful IMO

This is a well written tutorial so far, i can't wait for the next parts!
 
Last edited:

ST15RM

Banned
Our lord and savior has cometh with the sacred Tutorials. Praise him.

But in all seriousness, this is really cool. I found QGIS difficult to work with and confusing, especially to make maps like this. To quote Borat:
tenor.gif
 
Importing Vector Data

Deleted member 101966

Importing Vector Data

1. Rasters + Vectors

Inkscape users will already be familiar with the difference between rasters and vectors. For everyone else, here's a shoddily edited Wikipedia graphic:

upload_2019-1-2_17-26-32.png


All the memes and QBAMs saved on your phone are raster images, because they're made out of gridded pixels. In contrast, vector images are made out of mathematically defined points, curves, and lines. Rasters have specific resolutions and extents, while vectors exist independent of zoom level and can be resized infinitely. This matters because QGIS handles both types of data. Vectors are used for most political map features, but anything that's imaged instead of surveyed (satellite photographs, elevation data, land cover data...) is best distributed in raster form. Inside a single QGIS project, both kinds of data will usually be working together, but we'll cover vector data to start because it's more commonly encountered.

2. Vector File Formats

In the heady days of the 1990s, some bright bulb at ESRI invented the shapefile - the most commonly encountered file format for vector geographic data. It's a good term to punch into Google ("connecticut township shapefile") but from a usability point of view it's an awful file format (see here for an example of how passionate people get about listing all the reasons). Here's the most obvious foible:

upload_2019-1-2_17-40-44.png


It comes in five parts!! If even one of these goes missing, the entire file stops working. As you might be able to guess, the .shp component is the one that contains all the actual geometry, but the .dbf is important too because it contains a spreadsheet which pairs every geometric feature with a bunch of data. At its most minimal, this attribute table only needs to contain a unique number ID for every shape (so the computer can tell them apart), but it has many more uses. For instance, in a national census every relevant feature (a province, a municipality, a single city block) within a shapefile would be paired with a population count.

ESRI tried to make up for its past mistakes by introducing the geodatabase, a type of weird file folder which can contain both vector and raster data at once. Unfortunately, this format is proprietary and QGIS is only capable of decoding the vector features inside one of these - full functionality is impossible without a paid copy of ArcGIS. If you ever come across a folder with a name like "counties.gdb" that contains hundreds of files all named "a00000023.gdtablx", it's a geodatabase.

2014 saw the development of the geopackage, a non-proprietary format that actually manages to keep all your data inside a single file. Three years later, the QGIS 3.0 update added this .gpkg functionality to the program. Now that this new file type is well-supported, it'll probably have a long and productive life ahead of it, so I recommend saving everything you ever generate or edit in this format.

3. Opening Vector Files

Just check under Layer > Add Layer > Add Vector Layer. Since this is one of the things you'll do most often, Ctrl+Shift+V is worth committing to memory.

upload_2019-1-2_18-28-28.png


For shapefiles and geopackages, this is it: just locate the file and you're done. For a shapefile, you want to be clicking on the .shp component. (Another common mistake: if you downloaded your shapefiles inside a compressed file format like .zip or .rar, remember to unzip them first!)

upload_2019-1-2_18-32-14.png


Geodatabases take three extra clicks: you have to change the source type to "Directory".

upload_2019-1-2_18-33-34.png


Conclusion

By now, you should be able to get your screen to look like this.

unknown.png
 
Last edited by a moderator:

Deleted member 101966

You make some really awesome maps, it would be great if you could share the databases you use for them (and the other you know), i've found that natural earths quickly becomes insufficient when making more detailled maps.

Could you also explain a bit how one can edit the database, like editing coastlines or adding cities, that would be great for all the sci-fi/fantasy and alternate earth mapmakers!

NaturalEarth is easy to recommend because it's truly global. The next level is OpenStreetMap, where it becomes hard to track down single definitive sources for everything (although the entire OSM world is always only a single 900GB download away). Try this site for global applications. For smaller maps, the best data sources are frequently maintained by individual regional governments so the best I can usually do is drop a giant list.

Actually doing feature edits should come in two or three posts.
 
Styling Vector Data

Deleted member 101966

Styling Vector Data

So you can load shapes into QGIS. Here's how to get past the randomly chosen default colours and make them look the way you want:

1. The Symbology Menu

Luckily, every kind of layer is styled in the same place. Double-click on a layer in the Layers pane to open up its Properties, then pick Symbology:

upload_2019-1-5_10-9-57.png


QGIS has a lot of easy symbology features, allowing you to set custom colour ramps and colour schemes based on feature attributes. By default, a polygon feature is always set to a randomly chosen fill colour with 0.26mm black lines. Change that by clicking "Simple fill"...

upload_2019-1-5_10-15-39.png


upload_2019-1-5_10-16-13.png


All of these options can be changed at your pleasure. For now, let's set the fill style to "No brush" and the line thickness to 0.1mm.

unknown.png


Just by varying line thickness between different layers, our raw geographic data is already looking a lot better. Sometimes it helps to keep two duplicate instances of the same shapefile kicking around, one for outlines and one for colour fills - that way, other features can be easily sandwiched in between them.

2. Other Symbology Types

On that note, here's how to set arbitrary colour fills, AH.com style:

upload_2019-1-5_10-26-39.png


Picking Categorized symbology lets you set different rules for shapes that have different attributes. Training it on an attribute that's unique to individual features (like "Name") results in a giant list of shapes. Set to a non-unique attribute, it could be used to implement a four-colour scheme (by creating an attribute called something like "Fill Colour" and populating it with carefully chosen numbers from 1 to 4).

upload_2019-1-5_10-32-47.png


Individual colours can be edited just by double-clicking them. To change the line thickness of every state at once, you'd want to click "Symbol" at the top.

Graduated symbology is best used for numerical data. Let's whip out an American county shapefile which happens to contain the length of every county name as an attribute:

upload_2019-1-5_10-43-18.png


Nothing will appear on the screen until you mash "Classify" to sort your numerical data into categories. Easy, right? Not so fast - every data set has a different distribution, so it's very easy for the default option (Equal Interval) to have a useless final result. Without regurgitating a whole first-year statistics textbook here, I encourage you to experiment with different classification modes to see which one displays what you want most clearly.

unknown.png


In this case, I've set the number of classes to 9, because these are integers and the overall range of the data (3 - 21 = 18) is evenly divisible by that number. Vaguely interesting, right? Colour isn't the only thing that can be changed between symbols - adjusting the size/thickness of points/lines is also frequently helpful. (Adjusting the line thickness of polygons, less so, but it's still possible. QGIS lets you do a lot, so I intend to also talk about some basic design rules in order to narrow the field a bit.)
 
Last edited by a moderator:
Editing Vector Data

Deleted member 101966

Okay, so now we know how to load data into QGIS, and we know how to make it look the way we want. Let's officially enter the creative realm by talking about editing shapes.

Editing Vector Data

Vector GIS data combines geometry with attributes. With two separate things to be edited, geometry operations are different from attribute operations (which, being mostly done by spreadsheet, will be decently familiar to any Excel / Google Sheets user). We've mostly been looking at geometry in this thread so far, but you'll notice that attributes have been used to colour Argentina's states and to visualize that county name length statistic. So it might be tempting to ignore all the weird spreadsheet stuff now as you rush to make the visual basemap of your dreams, but fair warning: once you start using QGIS' speedy auto-labeling features, and if you ever choose to make maps that portray more data than simple geometry and topography, attributes will become indispensable.

1. Edit Sessions

Unlike other software that lets you change things as you go, QGIS has a fairly unforgiving edit session mechanic. When a vector file is loaded into the browser, you can change its symbology as much as you like, and you can perform all kinds of weird algorithms on it (because the output of these algorithms is always saved as a copy of the input file, without modifying the original at all). But, without pressing the pencil-shaped Toggle Editing button, you can't do anything to actually modify the layer you're working with.

upload_2019-1-7_10-17-44.png


Fair warning: edit sessions are kind of brutal. If you don't regularly press the Save Layer Edits button (the floppy disk with the little pencil, right next to the big Toggle Editing pencil), then a program crash will wipe out all of the work you've done in that session, no matter how long it took. If you do press the Save Layer Edits button, you can no longer undo anything you did before saving. User-friendly it's not. Because of this, if you're modifying a file you found on the internet, it's usually a good idea to always be working with a copy.

2. Editing Vector Geometry

Once edit mode is enabled, a lot of buttons will suddenly activate in your toolbars. One of the more annoying things about a new install of QGIS is that the shape editing tools are hidden by default - what, am I the only person who routinely needs to add fictional shapes to serious real-life scientific data or something? Right-click on the top of your screen and make sure that "Advanced Digitizing Toolbar" is enabled. If you've done it right, a row of green blob icons should appear. While you're at it, make sure Snapping Toolbar is enabled too.

upload_2019-1-7_10-26-37.png


Just like in Inkscape, these shapes are made out of editable nodes. Unlike in Inkscape, layers containing hundreds of thousands of points won't murder your computer. Of course, this comes at a price: QGIS runs so much faster because it doesn't have Bezier handles and there's no QGIS equivalent to Inkscape's pleasantly curvy pencil tool. Every single line in this program is perfectly straight.

upload_2019-1-7_10-30-34.png


Pick the Vertex (node) Tool and let's explore:

upload_2019-1-7_10-32-1.png


So where are the nodes again?

upload_2019-1-7_10-32-37.png


Aha - most shapefiles just have a really high node density. The node tool will rarely be used for anything useful, but you can see how it works:

upload_2019-1-7_10-34-15.png


Although the node tool is more intuitive now than it once was, it's still a ridiculous proposition to do any serious editing one node at a time, and the possibility of making illegal mistakes (highlighted here in green, which will make it impossible to do anything sophisticated to this geometry later) is too great. Still, it's useful for fighting topological errors, the mathematical crud that accumulates in a shapefile over an edit session (duplicate nodes, tiny "sliver" polygons, holes where there shouldn't be holes, etc.). Let's not save these changes to Cypress County and instead go back to those advanced digitizing tools.

unknown.png


As everybody no doubt already knows, the Municipal District of Fairview is deeply divided by the very scenic, but difficult to traverse Hines Creek valley. Using a semi-transparent Google Maps layer as reference (see, it all fits together!), let's try fixing this problem by turning the relatively inaccessible western portion of the M.D. into a new Municipal District of Highland Park. (Did you notice that I changed the projection between this screenshot and the last one? When doing edits, you are entirely free to change CRSes as it suits you, as long as you don't do it in the middle of an operation.) First, minimize the possibility of ruining a shape which you don't intend to edit by selecting only the M.D. of Fairview using the yellow square icon in the top row. (If you've done it right, it'll become garish yellow.) Then, pick the Split Features tool...

upload_2019-1-7_10-47-15.png


(If you were wanting to start dividing a feature exactly at a certain point, Enable Snapping is what you'd press. Since we're just eyeballing the Hines Creek right now, though, it's not necessary.)

unknown.png


Once your drawn line (difficult to see on an HD monitor) fully crosses the shape, right-click to finish the operation, and...

unknown.png


(Yes, zooming is possible during an edit session, so it would have been possible to do a much better job than this.)

upload_2019-1-7_12-16-17.png


Uh-oh! M.D. of Fairview reeve Peggy Johnson has lodged a formal complaint regarding the loss of tax revenues that would result from Highland Park gaining ownership of the Fairview Ski Hill, on the west side of the Hines Creek valley. Without unanimous approval, there's no way the partition will go ahead. Let's deselect everything and make a border amendment using the Reshape Features tool...

upload_2019-1-7_12-18-15.png


Perfect! It would also have been possible to use a one-two combination of the Split Features and Merge Selected Features tools, but that would have taken more clicks.

3. Editing Feature Attributes

Now that all parties agree on what the new M.D. of Highland Park should look like, we're ready to officially give it a name. Let's click on the shape using the always-useful Identify Features tool...

upload_2019-1-7_12-22-1.png


unknown.png


During an edit session, the Identify tool gets seriously beefed up because now you can arbitrarily edit all of the text fields that come up. As is almost inevitable when editing files acquired from government agencies, there are a lot of weird codes associated with every feature. These are valuable for analysis because they can be distinctively unique even when two features have the same plain-English name. It's a good idea to keep your hands off them unless you know what you're doing because if two polygons have the same numerical ID, the layer won't save properly. (In this case, the relevant field is "RURAL_ID".)

Let's replace "MUNICIPAL DISTRICT OF FAIRVIEW NO. 136" with "MUNICIPAL DISTRICT OF HIGHLAND PARK NO. 137", and open the Attribute Table to see if our changes had any effect...

unknown.png


Perfect! Also notice our first hard evidence that the shape geometry is linked with the attribute table: the same feature is selected on both. Again, it seems kind of marginally interesting now, but once we get into auto-labeling and the Print Composer, properly maintaining feature attributes will save a lot of time. (In this case, we're only about 3 clicks away from labeling every one of these counties with its full text name.)

Just remember to Save Layer Edits!
 
Last edited by a moderator:
Layouts and Composition

Deleted member 101966

Knowing how to make stuff in QGIS is neat, but how exactly are you going to spin it into a final product? The good news is that there is an alternative to manually creating a giant collage of screengrabs!

Layouts and Composition

Yes, there's a native interface... contained within an entirely separate window... which you can open up to export your entire QGIS project into sweet, sweet png format. Layouts have many wonderful features: adding degree grids is easy, adding complex insets is easy, putting different maps in different projections on the same page is easy, and exporting to an arbitrarily high resolution is very easy indeed. Inkscape users be warned: svg export is possible, but loading shapefiles in Inkscape is almost never a good idea re. computer performance. (For adding labels on top of a png export, though, Inkscape is still my preferred tool. For those of you who don't use Inkscape, QGIS has a bit of native support for adding custom text to maps.)

I think I also somehow forgot to mention that QGIS operates with save-able project files, allowing the program to remember which layers you imported and how you styled them. (It's easy to skip over including this in a tutorial because the program does a good job by itself reminding you to use them.) Layouts are also saved in project files, so go nuts making them as complicated as possible.

1. Accessing Layouts

Once your project window looks like something you'll want to export, making a new layout is three clicks and a keysmash away:

upload_2019-1-15_21-7-48.png


upload_2019-1-15_21-9-28.png


upload_2019-1-15_21-11-37.png


Here we are!

2. The Layout Window

upload_2019-1-15_21-11-53.png


Beautiful, a blank 8.5"x11" rectangle. Let's make it not blank:

upload_2019-1-15_21-14-19.png


Click and drag to draw a rectangular map. This map will look a lot like the main project window, but with a few key differences...

- It takes much longer to load.
- It's probably framed badly.
- It has a fixed size and a fixed scale.

upload_2019-1-15_21-16-0.png


Let's start making this look nicer. The Move item content tool on the left will help us shove Alberta front and center, while the Scale and Position and size tools on the right panel (under Item Properties) will help adjust our map frame further. (While we're here, I'll mention that I always set the scale to a nice, round number. This isn't necessary, I just like doing it. Setting width and height to be nice, round numbers might be more important, especially if you intend your maps to ever make it into real-life print.)

upload_2019-1-15_21-19-38.png


Once Alberta perfectly fills a 6"x10" canvas at 1:5,000,000 scale, switch back to the Layout panel and use the Resize layout to content feature.

upload_2019-1-15_21-50-22.png


3. Exporting a Layout

Now that our layout's perfect, we'll export it under Layout > Export as Image.

upload_2019-1-15_21-51-59.png


QGIS tends to round down here, which is stupid, so don't be afraid to unleash your irrational numerological feelings by manually turning 1799px 300dpi into 1800px 300dpi.

upload_2019-1-15_21-53-40.png


Press Save and admire your handiwork!

Yet_another_Alberta_open_data_project.png


There's more to discuss with layouts - the grid feature, the legends, the manual labels, and the transparency options are all worth explaining - but I've already hit the 10-image limit on this post, so we'll take a short break first.
 

VT45

Banned
Can I make a request? I have a csv file with supplementary data for a .shp file, but they're not linked. Is there a way I can link them together in order to create a map based on data in the csv without having to go through and manually colour every polygon in the map?
 

Deleted member 101966

Can I make a request? I have a csv file with supplementary data for a .shp file, but they're not linked. Is there a way I can link them together in order to create a map based on data in the csv without having to go through and manually colour every polygon in the map?
Yes! This is called a "join" and it's totally doable. csv (and tab, and Excel, and basically any other kind of spreadsheet data) files can be imported exactly like any other vector data:

upload_2019-1-16_18-26-15.png


Once your spreadsheet is imported, the rest can all be accessed by double-clicking the shapefile in the Layers panel to open up its layer properties. Choose Joins:

upload_2019-1-16_18-31-58.png


An important note is that joined fields tend to be read as text strings, even if they're numbers. For many purposes, this makes no difference, but it interferes with sorting operations (1000 comes before 2 when the program thinks it should be working in alphabetical order) and sometimes breaks symbology rules. If you notice that your "spreadsheet_population" isn't being read correctly, a quick fix is to use the to_int operator to get to_int("spreadsheet_population").
 
I know this is old, but I was wondering if you could maybe do a small update about stylistic settings for maps (i.e. labels, coloring, background terrain). I'll try to figure it out on my own, but some tips from someone more experienced with QGIS would be helpful.
 
Thanks for the guide. Indeed, spending half an hour tracing a map in inkscape alone does make me question my life choices. This method seems so much better.
 
Top