QGIS Tutorial
QGIS is a relatively easy to learn software for election mapping. This page will teach you how to make election maps that look good, and if I can figure it out, it'll link files related to mapmaking. I'm going to walk you through how to make this map of Transylvania County NC from the 2020 Presidential race on the left
First we need to get our shapefiles. The Census Bureau is probably the best place to do this. Here's the link to that https://www2.census.gov/geo/tiger/TIGER2020PL/STATE/
Bear in mind, once you click on the state you want, the counties are sorted by FP code. Just cross reference the "List of Counties in X State" pages on Wikipedia to figure that out
Transylvania County is 37175, so we'll click on that, and select the VTD20 file at the bottom, which will download the associated files with voting districts
Once you get that downloaded and extracted, open the folder and you'll get these files. The spreadsheet (DBF) and the one with the QGIS (SHP) icon here are important. We're going to start by clicking on the spreadsheet
That'll pull up something like this. There's a lot here, but you just need the GEOID20 column (essentially a precinct identifier) and the NAME20 column (which has the precinct name). You're going to want to copy those two columns, and stick them in a spreadsheet of your own
Once you do that, it should look like this. Now comes the data. It can come from a variety of sources. We're going to use the NC Secretary of State (SoS) site to get ours. Here's that link
https://er.ncsbe.gov/?election_dt=11/08/2022&county_id=50&office=ALL&contest=0
It'll look like this when you get there. This doesn't always have all the precinct data, but for Transylvania in 2020 it does (there's a complicated way to get the rest that you don't need to know right now). So navigate to the county, office, and race that you want to map (President 2020, Federal, Transylvania County)
This should come up if you did it right. With NC's site, you can also be less specific and get multiple races to come up if you want, say if you want to browse
Now, click on "View Contest Details"
NC's site is handy in that it gives you an actual map that you can interact with. I reference it to make sure I didn't mess up a precinct
To get to the actual data, click on "Results by Precinct"
That should give you this lovely chart. You're going to copy and paste this whole thing in the excel sheet with the two columns
Once you do that, it should look like this. I keep a space in between the data and the shapefile info until I'm ready to map. There's also a problem with it right now: the data is ordered incorrectly. TC1 and TC7 should be above WC. So cut WC and insert it above those two
Here I've done that, eliminated the non-major party candidates (just because here they aren't swinging the results a ton), and scooted it over a bit
Now I cleared out the extra precinct column, and set it up for our *fun* math portion. I calculate the total votes, Republican percentage, Democratic percentage, and R-D PCT (margin)
If you formatted your table like above and are using a color scheme of mine (which will be linked below), here are the formulas:
Total: c2+d2 R PCT: c2/e2 D PCT: f2-1 R-D PCT: f2+g2
If you end up with a positive number, it means Republicans won the precinct. If negative, Democrats won it. If its a 0, its a tie. If its N/A, error, etc., then that either means you screwed up, or there's missing data. If there's no data for a precinct, type 10 there
If you did that, you should get these numbers. Select all the numbers you generated in a box, and drag it down to the last precinct. This will apply the formulas to each row
Once you do that, it should look like this, and we're ready to map
Now open QGIS by selecting the QGIS icon in the folder you downloaded
Doing that will produce this boy, which is the basic precincts of Transylvania County. We need to modify things a bit before adding in the data
First, this map has no projection (which is a translation of spherical turf to a plane), so it looks a bit long. Click the globe looking thing by EPSG at the bottom right
That'll bring up this handy window. In the filter box at the top, type North Carolina, and pick a projection. I typically pick one with a newer date, so I'm choosing the 2007 one
If you did that right, it should look a little taller
I also add backgrounds to my maps. To do that with yours, click the dropdown by XYZ Tiles on the left of the screen, and select OpenStreetMap (OSM)
Another issue: our precinct map of Transylvania County gets hidden by the background map we just selected. To fix that, right click on the shapefile name (the tl xxxx thing), and select "Properties"
If this didn't happen for you because the shapefile is above OSM in the bottom right, drag the OSM above the shapefile, and then do what I said
You'll get the "Layer Properties" window to pop up, and the tab its on might vary. Go to "Transparency", and set it to 90%. Don't close out of the window though.
Next, go to "Symbology"
Once you're there, click the "Blending mode" dropdown and select multiply. You don't necessarily have to do this, but I think it makes the map look cooler. You can also set the transparency to whatever you please, I just do 90%
Once you do that, click "OK"
If you do that, you should get something like this. You can still see the background map (with cities and such included), and also the precincts. Now the fun begins
Right click the tlwhatever line at the bottom left (which you can also rename like I did), and go to "Properties" again, and then "Joins"
That should make this appear, without the "Add Vector Join". Click the green + at the bottom to get that to appear. You'll want the "Join layer" to be the name of the page of your data in the spreadsheet, and join and target fields to be the GEOID20. Then hit ok
If you did that right, then this will appear. From there, go to "Symbology"
This didn't look like the symbology of the background map because its a different layer, so don't freak. On this page you'll do a lot, but first you'll want to load your style (which are qml files). I'll have mine linked below. Use "New Partisan Rev"
https://drive.google.com/drive/folders/1oKTAZ8Gpky20w2ez9O-bKbK6XDVjLXFO?usp=share_link
This pop-up will appear, and you'l click the "..." button on the "File" line to select a style/color scheme. You'll have to navigate to the folder you put them in once, then it'll start opening said place automatically
Once that's open, pick your color scheme (New Partisan Rev). Most of mine are courtesy of @cinyc9
That should make the scheme come up, but your work isn't done yet. You should select the "Value" dropdown, and select your spreadsheet name with the R-D PCT label by it. Then click "OK"
TA DA YOU'VE GOT A MAP!!!
Now we make it look pretty with labels, a legend, and such, and make it into an exportable or screenshot-able format
At the top left, click on "New Print Layout" (the icon with the paper and ruler thing)
That'll take you to the layout window with a blank page. I usually click one of the zoom icons to make it bigger/easier on the eyes while I work
Then it should look like this. If it doesn't, just mess around with the zoom until it looks the way you want
Now we're going to throw our map up. Click the blank page-looking "Add Map" icon on the left. Once you have that selected, you click on a corner of the blank canvas and drag to cover the whole thing
That should give you this. At any time, you can export this as an image by clicking the photo on the blank page-looking icon at the top, but we're going to keep going
We're going to add a legend next. There's the icon with the three dots on the right that lets you do that. Its click and drag just like the map
Your map will probably look like this when you do that, with the item properties window to the right. We're going to do some stuff in that
Within that window, I'd turn off Auto update and Resize to fit contents for now. Not turning off auto updates will mess up the main map, and resizing will make you legend look weird. I forgot to do this for this map, but you can also click "Only show items inside linked map" and it'll only show the shades in the legend that you use
From there, select OSM and your spreadsheet in the Legend Items, and hit the red -. This will eliminate them from the legend (at least do this for your spreadsheet name). Double clicking will also rename things, which I'll do for my precinct map later
Now your map should look like this in your layout (not sure why my image here got cropped. We can make it look a bit better though
We're going to go to "Add Label" to make our city names and our results summary. This is also a click and drag feature
Here's how it looks with just the results label there. Relatively easy math to calculate the %s and such
Transylvania County only has 2 incorporated areas (Brevard and Rosman), so I'm going to create smaller labels for those
Here's the final product that you can export or screenshot. I'd advise finding your own fonts and eventually making your own color schemes. For now though, I wish you luck on starting to map. Maybe in the future I'll make an addition to this with mapping Canadian/multiparty races