Profile picture
cinyc @cinyc9
, 176 tweets, 50 min read Read on Twitter
Tutorial on how to make a map using QGIS. I'll turn @SenhorRaposa's 2000 Vermont town data into a map showing by how much Gore outran Senator Jeffords (or vice versa) in every town.
Step 1: Download QGIS for your computer, which is available here:…
You'll also need some of Census' Tiger/Line County and County Sub shapefiles. The main download page for those is here:…

A direct link to the 2017 VT county sub shapefile is here:
I can't find a 2017 County file by state, so we'll use the 2009 verison here:
(We could always edit the 17 national county file in QGIS & create a 2017 VT-only county shapefile, but let's keep it simple.)
Finally, we need the data - Here's a link to @SenhorRaposa's raw 2000 results data:…

It's in good shape, but might need a little work before mapping it.
I downloaded @SenhorRaposa's data as an Excel file (File-->Download As-->Microsoft Excel). The relevant sheets are VT_Elections_Database__2000_U_S and VT_Elections_Database__2000_Pre. I'm going to do a simple comparison of Gore and Jeffords' percentages in a new worksheet.
If you're following along, I did that by hitting the plus button on the bottom of Excel, named the sheet 2000 Comparison. I then copied Column A (City/Town) from the 2000_Pre worksheet. I entered the following formula in Cell B3: =VT_Elections_Database__2000_Pre!R3
I then copied it and pasted it down that column to cell B249. Name the column "Gore PCT" in Cell B1.

I'm pretty sure the town names are in the same order in the VT_Elections_Database__2000_U_S sheet. But since I'm not, 100% sure, I'll use a =vlookup or =sumif formula:

I can explain these formulas in more detail upon request.
Copy and paste your chosen formula down to Cell C249. Name the column "Jeffords PCT" in Cell C1.

Finally, name Column D "Gore-Jeffords" in D1. Type =B3-C3 in Cell D3 and copy and paste down to cell D249.
Like I said in an earlier tweet, reconciling VT data without FIPS or GeoID codes is a bit more difficult because some cities and towns have the same names. Without FIPS Codes, name mismatches are possible. We could import the data into QGIS right now, but there would be errors.
So, next, I'll show you how to use Excel to reconcile town names and add FIPS codes.
If you've unzipped the VT County Sub shapefile, you'll notice that there's no Excel file associated with it. Data associated with shapefiles is saved in a .dbf file. Excel can open, but not save these. So use Excel to open tl_2017_50_cosub.dbf. It should look something like this
We really only need two columns to do a proper data merge in QGIS: the GEOID and Name columns should suffice, since the GEOID is unique for each county sub. So:
1) Create a new spreadsheet in the Vermont.xlsx and call it "2000 Import Data"
2) Copy and paste columns E&F from tl_2017_50_cosub.dbf to Columns A&B of Vermont.xlsx "2000 Import Data"
3) Since we're only interested in making a map of the Gore-Jeffords PCT, Label Column C in 2000 Import Data "Gore-Jeffords PCT".
4) Type the following VLOOKUP formula into Cell C2:
=VLOOKUP(B2,'2000 Comparison'!A:D,4,0)
5) Copy and paste the formula in C2 through Cell C256.
Note: This is how I'd do it, which may or may not be the best way to do it. If anyone else has simpler ideas, let us know.
Unfortunately, you'll notice that #N/A appears in some of the Column C cells. Filtering Column C to only show rows with N/A reveals 27 mismatches. (To filter, click on 1) Data, 2) Filter, 3) the Arrow in Cell C1, and select #N/A from the drop-down menu.) It should look like this
Unfortunately, only now I noticed that we'll need the Name LSAD column G from the tl_2017_50_cousub.dbf to differentiate between, say, Rutland City and Town.

So copy and paste that column, either by inserting it into Column C or after the data in column D of the data sheet.
The only way I know how to compare names is by manually comparing the N/A names in 2000 Import Data to the town names on the 2000 Comparison sheet. There are a few shortcuts:
We know that Drew used E. for East, S. for South, etc. So in the 2000 Import Data sheet, replace West Haven with W. Haven, North Hero with N. Hero, etc. You should see data pop up in the Gore-Jeffords PCT column if you've made a match.
We also know @SenhorRaposa labeled the towns and cities with their full LSAD names. So, any time you see a duplicate name, add City or Town after the city name. For example, Rutland in Cell B23 should become Rutland Town.

This should leave 10 towns to manually check.
Unfortunately, I can't reconcile any of those 10 towns. Vermont does have some towns that vote in other towns, so these might be them. Replace #N/A for those cells with 10 - the QGIS code I use for No Data in my Swing Color Scale. Save the Excel file.
Now, we're ready to open QGIS and make a map. Your screen should look something like this - though if you don't have recent projects, that part will be blank.
We'll need to add three layers to this new project. This can be done by hitting the V looking button on the left.
Or, I'm told, by dragging the .shp file to the screen. I use the former method. After hitting the V looking open vector layer button, a dialog will appear. It looks like this. Hitting Browse will allow you to navigate to where you left your unzipped file.
Once you've navigated that folder:
1) Make sure you're able to view all files by selecting that option from the pull-down menu on the bottom right
2) Select tl_2017_50_cosub.shp from the list
3) Hit Open.
Your screen will look something like this:

Notice how Vermont looks too wide. We need to change the projection.
To do that,
1) Click on the globe icon on the bottom right of the screen.
A dialogue will appear.
2) Check the Enable on the Fly box, if it isn't already
3) Type "Vermont" in the Filter
4) Select a Vermont-specific projection below - NAD 83(HARN)/Vermont or whatever
5) Hit OK
Your map should now look like this:
Next, we'll add the data from the Excel file to QGIS. If you don't remember how to do that, you can drag the Vermont.xlsx file to the map or:
1) Hit the V looking icon on the top left to open a vector layer
A dialogue will appear:
2) Make sure show all files is selected in the drop-down menu on the bottom right of the dialogue
3) Navigate to where you saved Vermont.xlsx
4) Click on it
5) Hit Okay
The Dialog will close. Hit Open. A new Dialog will open up, listing all the sheets in Vermont.xlsx. We only need to add one sheet.

1) Scroll down and select "2000 Import Data"
2) Hit Okay
Now, we'll join the data from our spreadsheet to Census' county sub shapefile and (hopefully make a map).

1) RIGHT-CLICK on tl_2017_50_cousub in the Layers Panel
2) Select Properties from the drop-down menu

A new dialog will open up.
At this dialog:

1) Select Joins on the left
2) Hit the + Button on the bottom

Yet another dialog will appear
Note: I'm running into data integrity issues when trying to import the sheet. I'm not sure why. What I did as a workaround was opened Vermont.xlsx, copied the 2000 Import Data, and pasted it to a new sheet in a new workbook AS NUMBERS. If you run into the same issues, try that.
Anyway, after you hit the plus button, the Add Vector Join dialog will appear.
1) Your Excel worksheet will likely be listed as the join layer. If not, select it by name
2) Select GEOID as the Join field
3) Select GEOID as the target field
4) QGIS' default custom prefix is too long. Change it to V_ or something short.
5) Hit OK.
Next, we should verify the join. Close the Properties dialog.
1) Hit the button in the ribbon that looks like the Connecticut Avenue Monopoly card. If you don't know what that is, see 1 below.
2) Scroll to the far right and make sure that the circled joined columns exist & ...
have no numbers greater than 1 or less than -1, except 10. That's where I ran into the data integrity issue when I first ran the join.
Finally, we're ready to make a map. To make it simple, you can download my 5-point swing style file here. It's not my newest color scheme, but will do for now:…
1) Right Click on tl_2017_50_cousub in the Layers Panel and select Properties
2) Select Style on the left top of the Property Dialog
3) Select Style on the bottom left. A menu will appear
4) Select Load Style, and find your style file from where you saved it
The style file should load, but the variable mapped defaults to PWINCODE. We need to change that:

1) Select the arrow next to PWINCODE
2) Select V_Gore-Jeffords PCT from the drop-down menu
3) Hit OK
Congratulations! You have a map of the Gore-Jeffords PCT. Unfortunately, it's in @uselectionatlas colors because I haven't updated my styles - Jeffords outperformed in the blue areas, Gore in the red. The grey areas had no votes - which makes sense up north but perhaps not south.
You finally have your requested map, @SenhorRaposa. It doesn't look as professional as those that I usually do - I didn't add county lines to save time and avoid confusion, and there's no legend. I can explain how to do that how I use QGIS' print composer later, if anyone cares.
Note: If you've followed these instructions, it's probably time to save your project by hitting CTRL-S or the disk icon on the left side of the top ribbon. This saves your progress and allows you to reload the map whenever you want, particularly if QGIS crashes.
Note 2: You can save a simple map as an image by selecting Project-->Save as Image, or hitting the icon you see there, if you have the relevant toolbar on. I don't.
It will look like this. You then can use MS Paint or Snagit or Photoshop or whatever imaging program you have to add a legend and make a more complex map. I prefer to use QGIS' own print composer to do this, but YMMV.
I think Killington is Sherburne in @SenhorRaposa's data. You can change Killington to Sherburne in Cell B94 and copy the =VLOOKUP function from C93 to replace the 10. The other 9 towns/gores appear to have no government or, in some cases, people, so there likely is no data there.
A few other notes:
1) I should have checked the Excel data to ensure we weren't missing a town. I do this by totaling or averaging the data in the source and import spreadsheets. If they're equal (without the 10s), the import data likely isn't missing or doubling anything.
2) If anyone is further interested, jimrtex at @uselectionatlas and I put up a more in depth How-To on That's here:…

I still need to add stuff to it, like how to create a color style, when/if I can find time.
So @SenhorRaposa asked me how to make maps with more than two candidates. Here is what I actually do for all races except when I want to calculate a margin or PVI or something like that.

First. you'll need my 8 color scale style here:…
In order to use this style, you must use Excel or your spreadsheet program to calculate what I call a Wincode. I think @JMilesColeman does the same thing. The 8 color style will output a color in the following ranges: 0-1 Red, 1-2 Green, 2-3 Blue, 3-4 Gold, 4-5 Orange
5-6 Dark Purple, 6-7 Cyan, 7-8 Light Purple, 9 Tie (light grey), 10 No Data (dark grey).
You need to create a new Wincode column on your spreadsheet. In a simple R vs. D race, assuming Rs are in column A and Ds are in column B, the Wincode formula is simple: =if(sum(A2+B2)=0,10,if(A2=B2),09,if(A2>B2),A2,B2+2)))). That will create a dark grey Wincode if no data,
a light grey 9 Wincode if there's a tie, a red shaded 0-1 Wincode if the Republican wins and a blue-shaded 2-3 Wincode if the Democrat wins.
The formula for a three or more candidate race is a bit more complex. Suppose results for Candidates A, B & C are in their respective columns, and you want to color them red, green and blue. You'd calculate that Wincode with an =if function, too. That formula is:

I put the -1 in this example to make the geometry appear white if there's an error, since the 8 Color Scale assigns 0 to red.
You can add a -1 to the simple formula, too, if you wish. Error checking isn't necessarily a bad thing.
09 should be 9 here. Yes, Twitter needs an edit function.
One thing you might have noticed is that so far, we've only been joining data to the shapefile. We haven't been saving the shapefile with the new data. If you think you're going to re-use the data again, saving the shapefile under a new name might make sense.
To permanently join your data to a shapefile, right click on the shapefile name in the layer panel and select Save As. A dialog will pop up.
1) Make sure ESRI Shapelfile is selected in as the format
2) Click Browse, navigate to where you want to save your file & name it
3) (Optional) Deselect the fields you want to save, if you only want to save some fields. Otherwise, ignore.
4a) (Optional) Deselect the Add Saved File to Map box below the field window, if you don't want to add it
4b) Hit OK
Here is a link to a zip of about 25 additonal styles that I use to make my maps:…

Most of the names are self-explanatory.
The misnamed 7ColorScale New 25.qml style is used for multi-candidate maps. (There are actually 8 colors in the scale.) I'll do a tutorial on how to map multi-candidate races next.

The New 25 [color].qml styles are used when you want to map 1 candidate's percentage.
Part 2: How to use the 7ColorScale style to make a map showing results for multiple candidates. You'll need the following for this:

1) @SenhorRaposa's TX 1992 Presidential Results Spreadsheet:…

2) The 7ColorScaleNew 25 qml style file from above.
3) A Texas County shapefile. There are a number of options for this. Unfortunately, the last simplified County shapefile clipped to the coast was made for 2000. That's here:…
Alternatively, you can download the 2016 generalized US County Shapefile and split it into component states. That's here:… Download, and I'll teach you how to split it below.
Finally, you could dowload the non-clipped, large 2010 Tiger/Line Texas shapefile from here:… It won't have coasts, but you can always add a water shapefile on top later. That's the method I usually use.
As an aside, all of Census' shapefiles are available starting from this page:…

The Tiger/Line shapefiles are huge and are not clipped to the coasts. The Cartographic Boundary shapefiles are smaller and generally clipped to the coasts.
Here's how to create 2016 County maps clipped to the coast from the US shapefile. First, load cb_2016_us_county_5m to QGIS either by dragging it to the QGIS' canvas, or 1) clicking on the V-like icon on the left, 2) browsing to where you saved your file, and 3) hitting open.
Next, open up the toolbox by selecting 1) Processing from the top menu and 2) Toolbox from the drop-down menu. A new pane should appear on the left, with various QGIS tools. 3) Type "Split vector layer" in the box, and 4) left click on the Split vector layer tool to open it.
A dialog will appear. 1) From the drop-down menu under Unique ID field, select STATEFP - this is the FIPS Code for each state. 2) Click on the three dots next to Output Directory and select the folder where you want to save the state county files. 3) Hit Run.
QGIS will take a while to split the file. Once it's done, add cb_2016_us_county_5m_STATEFP_48 to the canvas (either by dragging it to the QGIS canvas or navigating to it after hitting the V icon). (The FIPS Code for TX Is 48 - here's a list of the rest:)…
You can zoom to a layer in QGIS by 1) Right clicking on the Layer Name in the Layer Panel and 2) Selecing Zoom to Layer from the pop-up menu. If you do this, your map should now look like this (though the colors are probably different).
Dragging a layer up in the layer panel will make if appear above the lower layers. For example, if you drag cb_us_2016_county above the Texas layer, Texas will seemingly disappear. Don't worry - it's still there.
Clicking on the check box next to the layer name will cause it not to be mapped. Try this by clicking on the box next to cb_us_2016_us_county. If done correctly, your map should now look like this:
Finally before we get to actual mapping tonight, cb_us_2016_us_county is a stupid name. You can change it by 1) RIGHT clicking on the layer name in the layer panel, 2) selecting Rename from the pop-up menu and 3) renaming it.
Let's rename cb_us_2016_us_county US County and cb_2016_us_county_2016_STATEFP_48 Texas County. Note: this only changes the name in QGIS, not the underlying file name.

This would be a good time to save the project by hitting the disk icon on the toolbar or CTRL-S.
With the preliminaries out of the way, we're now almost ready to make a map of the 1992 Texas Presidential results by county. But if you've downloaded the 2000 simplified Texas County shapefile instead of breaking down the 2016 national county file, there's one more step:
Unfortunately, the 2000 shapefile doesn't include a GEOID column, which is needed to do a join. So we'll have QGIS create one by: 1) Clicking on the abacus-looking icon on the toolbar. A dialog appears. 2) Make sure Create a New Field is checked.
3) Name the new Column GEOID in the Output Field Name. 4) Change the Output Field Type to Text. 5) Because the full GEOID is split between STATE and COUNTY fields, type the following expression in the box: concat("STATE","COUNTY"). 6) Hit OK. This will create a new column.
We still need to save the new column to the shapefile. 1) Right click on c048_d00. 2) Select Save Layer Edits from the menu. A dialog will appear asking you if you want to save your changes. Select Save.
Note: This permanently saves a GEOID column to the underlying shapefile, which is useful if you do more mapping. If you don't want to make a permanent change to the shapefile, check the Create vitrual field" box from the menu that pops up after hitting the abacus icon.
Now, we're ready to use @SenhorRaposa's 1992 data to make a map of the winner by county. You'll need Excel or Google sheets to do this. When you open Drew's spreadsheet, it should look like this: @KyleSammin
Drew has already helpfully calculated the D (Clinton), R (George H.W. Bush), L and I (Perot) percentages for us. All we need to do to map it is to calculate what I call a WINCODE. Type WINCODE in cell S1.
The 7 color style will output a color in the following ranges: 0-1 Red, 1-2 Green, 2-3 Blue, 3-4 Gold, 4-5 Orange, 5-6 Dark Purple, 6-7 Cyan, 7-8 Light Purple, 9 Tie (light grey), 10 No Data (dark grey).
So, for example, in order to generate a blue shade, we'd need to add 2 to the Democrat's percentage. The formula I use has a bunch of nested =if functions. Here, since the D PCT is in column O, the R PCT in column P and I PCT is in column R, the formula should be:

=if(sum(O2:R2)=0,10 will make the county dark grey if there are no votes. This is more important for election night mapping that historic mapping..

if(max(O2:R2)=large(O2:R2,2),9 will make the county light grey if there is a tie.
if(P2=max(O2:R2),P2 will create shade of red if the Rep won the county.

if(R2=max(O2:R2),R2+1 will create a shade of green if Perot (I) won the county

if(O2=max(O2:R2),O2+2 will create a shade of blue if the Dem won the
if(Q2=max(O2:R2),Q2+3 will create a shade of yellow if the Libertarian won the county (Spoiler alert: he didn't)

The final -1 will make the county white if there's an error.
Copy and paste the formula down to the bottom of the data.

The next step would be to add a GEOID column to the county names so that we can do a join. This was covered in the first part of this tutorial. Fortunately, Drew has already provided a sheet where he has done this.
So I don't need to recreate the lesson again. Let's move on to the join and coloring.

Load Texas.xlsx into QGIS as a Vector File. Do this by either dragging the sheet's icon to the canvas or selecting the V icon on the left and browsing to find the file.
If you do the latter, make sure that either "All Files" or "MS Office Open XML Spreadsheet" is selected in the drop-down box next to Filename. Either way, a dialog will appear. 1) Click on 1992 to add that sheet, then 2) OK.
Next, we'll join the Texas.xlsx data to the Texas County shapefile: 1) Double Click on your Texas County layer name. A dialog pops up. 2) Click on Join. 3) Click on the + Icon. Another dialog pops up. 4) Select GEOID10 as the Join Field and 5) GEOID as the target field.
6) Make sure Cache join layer in virtual memory is checked. 7) Hit Okay. The data should be joined.
1) Click on Styles from the dialogue.
2) Click on Style at the bottom and
3) Load 7ColorScale New 25.qml from where you saved it.
1) Change the Column to Texas_1992_Wincode
2) Hit OK
Your map should look something like this. You still need to change the projection to something Texas-specific. Do that by 1) clicking on the globe icon on the bottom of the screen.
A dialog pops up. 1) Make sure Enable on the Fly is checked. 2) Type Texas in the filter. 3) Select a Texas-specific CRS. Texas is a large state, so one of the conics might be best.

Later tonight: how to use the print composer to make a map.
Before that: Now that you have my color style files, you can very easily change the variable mapped. Say you want a map of Perot's strength in each county. 1) Double click on the Texas County shp. 2) Select Styles at side. 3) Select style at bottom and 4) load New 25 Green.qml.
1) Select Texas_1992_IND from the column drop-down menu
2) Hit Okay

Voila! The Perot percentage in every county is now mapped!
Part 3: Using the QGIS Print Composer to make a more professional-looking map.

You can very easily print a simple map by selecting Project-->Save as Image from the far left of the top ribbon's drop-down menu. But you can use QGIS' Print Composer to make a more professional map.
To open the print composer, 1) hit the icon that looks like a folded piece of paper with an orange star underneath or CTRL-P or Project-->New Print Composer. 2) Name your print composer in the box, here, Texas. 3) Hit OK.
The Print Composer should open up. It looks like the image below. I'll outline some of the main features before describing how to make a map.

1) Clicking on The rolled-up map looking icon on the left lets you draw a map on the canvas.
2) The mountain icon adds an image.
3) The T in a box adds text.
4) The Three Squares icon adds a legend.
5) The ruler-looking icon allows you to add a scale bar.
6) The disk icon on top saves the project.
7) The mountain image with an out arrow exports your image to file.
8) The icon with shapes adds shapes.
9) The icon that looks like a Connecticut Avenue Monopoly title card adds an attribute table to the map. That's probably more useful when there are fewer geographies than Texas' 250+ counties.
The first thing we should do is draw a map. Click on the map icon. Draw a square on the canvas. It doesn't need to cover the whole canvas. 1) If you've zoomed to the Texas County layer in the main QGIS screen, click on "Set to Map Canvas Extent" in the Item Properties pane.
You can change the scale by inputting a number in 2) the box to the right of Scale. Change the scale to 7000000. Texas will appear bigger.
Playing around with the Extents will allow you to further enlarge the map, or focus on a particular area. The numbers in that box will depend on the projection you use. I'm currently using NAD 83(HARN) / Texas Albers Centric Equal Area.
Increasing the X min will move the left of the map canvas inward. Increasing the X max will move the right of the map canvas outward. Increasing the Y min will move the bottom of the map canvas up. Increasing the Y max will move the top of the map canvas up, etc.
If necessary, change the projection to mine by going to the main QGIS window, clicking on the Globe icon, etc. Then, go back to the print composer & change the coordinates to the following:
X min: 850000
Y min: 6850000
X max: 2200000
Y max: 8100000

The PC should look like this:
Next, we'll adjust the canvas size to fit the larger map and allow us enough room for a legend, scale and text:
1) Click on the Composition tab
2) In the Resize Pane to Content tab, type 75 in the box next to right to allow room for a legend
3) Hit the resize page button.
4) If you're going to put this map on a website that only allows smaller files, change 300dpi to 100dpi under Export Settings.
Next, we'll add a legend to the map.
1) Click on the 3 square legend icon and draw a rectangle on the right side of the page.
2) Select the Item properties tab
3) Click on the funnel icon to include only features on the map
4) Deselect the Auto Update check box
We can easily rename the features on the map to tailor them to this race. 5) Hit the arrow next to Texas County. Double clicking on a name from the drop-down menu will allow you to change the text. Try double clicking on R 30-40% and changing it to Bush 30-40%.
Then, do the same for the rest of the Rs. Change the 2 Is to Perot. Change the blue Ds to Clinton. Your print composer should now look like this:
You can move the legend box wherever you want it on the canvas by dragging it on the canvas. A red guideline should appear when you near the right extent of the map or the bottom of the page. Some notes about the other options for legends on the Item properties pane:
-The Font menu allows you to change the font and size of the legend text
-The columns menu allows you to make your legend span multiple columns. Default is 1 column
-The symbol menu allows you to change the symbol size
-The spacing menu allows you to change the legend spacing
-Position and size allows you to change the size of the legend and what side of the map the legend is tethered to. Default is top left corner. Here, we probably should change it to bottom right corner.
-Background allows you to turn the background on or off and change its color
Next, we'll add a title to the map:
1) Click on the T in a box icon
2) Draw a rectangle on the right side of the canvas that will hold your text.
3) Change the Font as you wish. I use Bold 24 point type.
4) Type the legend you want in the box under Main Properties.
You can always move the text box by clicking on it and moving it. You can increase the size by mousing over to the side of the box and dragging it.
Finally, we'll add a scale bar to the map.
1) Click on the ruler-like icon. Click on where you want to place it on the canvas. A Scale bar should appear.
2) Click the Item properties tab
3) Since this is an American map, change the Scalebar units to feet
You can make the bar smaller by:
4) Changing the segments to Left 0
5) and Right 2
You can make the scale bar narrower by:
6) Changing the height to 1.00 mm

Move the scale bar to the bottom of the canvas next to the map.
If you don't want to add additional layers, this map is done. We're can save it as an image.
1) Click on the composition tab
2) Change all the margins to 0 and hit resize page
3) Hit the mountain with arrow icon on the top of the page. Decide where to save your pic and name it.
A dialog will appear.
1) If you're going to use the pic on a website with size limits, change the Export Resolution to 100dpi. It doesn't matter on Twitter.
2) Click the crop to content box
3) Hit save.

Congratulations! You've made a 1992 TX pres map! It should look like this:
I'll probably be back a bit later or tomorrow to show you how to make a more complex map (adding "water", other states and Mexico) and use the same print composer to keep the map in the same place, which is important when making a map gif.
noticed in error in the El Paso County data. The FIPS code was wrong, which led to it being mapped as a Bush county instead of a Clinton county. @SenhorRaposa will likely fix the error in the underlying file. You can manually change cell F71 to 48139 & F72 to 48141.
The final map should look like this:
Part 3b - Making a more complex QGIS Print composer map

For this exercise, we'll need a Mexico and CONUS shapefiles. The CONUS simplified county shapefile will do. That's available here, if you haven't downloaded it already (5m version):…
I downloaded a Mexican state shapefile by doing an Internet search a few months ago. I forget where I got it, but it's available on my Google Drive here:…
Unzip and add the US and Mexican shapefiles to your QGIS canvas. We actually don't need the county borders, so we'll manually change the style to temporarily "delete" them by doing the following:
1) If you did the shapefile splitting lesson, check the box to turn US County on
2) Double click on US County. A dialog will appear. Select style.
3) Click on Simple Fill
4) Double Click on the color next to Fill. A new dialog will appear.
5) Change the HTML notation to #707070. Hit OK.
6) Double Click on the color next to outline. The same dialog will appear, this time for the outline. Change the HTML notation to the same color, #707070. Hit OK.
7) Changing the outline style isn't necessary, but you can change it to "No Pen" if you wish.
8) Changing the outline width also isn't necessary here, since things are the same color. But you can make it larger or smaller, as desired, all the way down to hairline.
9) Click OK.

Your map should now look like this:
Double click on the Mexican shapefile in the layer pane and follow steps 1-9, this time changing the HTML notation to #f4f4ee. This will color Mexico off-white.

Change the name of the Mexico shapefile to Mexico by 1) Right clicking on the layer name and 2) selecting rename.
Open the existing Print Composer by selecting 1) Properties 2) Print Composer 3) Texas (left click), as seen below.

Your Texas Print Composer should open up.
The legend might have sort of updated. To actually update it:
1) Click on Legend in the Items pane
2) Click on the Item properties tab below
3) Click Update All
The items will update. Unfortunately, this also changed you Bushes back to R, Perots to I, etc.
4) Move Mexico to the bottom of the list by clicking on it and
5) Hitting the down arrow until it's at the bottom
6) Open up the Texas County names by clicking the down arrow
7) Rename the Rs to Bush, Is to Perot and Ds to Clinton.
Next, we'll update the map and add "water".
1) Click on Map0 in the Item pane
2) Click on Item Properties, then Update Map the US and Mexico should be added to it.
3) Scroll down to Background (off the image). Open up the menu and double click on the color.
Select #a6cee3 as the background color.
Move whatever you need to move around on the map to make it look presentable (click on the item in the item pane first before trying to move it). When you're ready to save it, click the mountain icon. Your final map should look like this:
That's it for tonight. Like I said, I usually don't use Census' generalized shapefiles to make my maps. I use the larger, unclipped Tiger/Line shapefiles and add a water file. I probably can share those, too. If anyone is interested, please reply to this tweet.
Part 4: A quick guide to QGIS navigation and selecting geographies.

Here's a quick guide to what some of the buttons on the QGIS top ribbon allow you to do: @KyleSammin @trumwill
1 and 2 allow you to select geographies. 1) does so by Freehand/Rectangle/Polygon/Radius. Clicking on the down arrow next to the yellow box allows you to change the selection type. Holding Shift while selecting allows you to select multiple geographies without resetting.
2) allows you to select geographies by an expression or value. Select all & invert are also hidden here. 3) Deselects all features.
One simple way to make a new map of new states is to A) select your geographies by whatever method is advantageous, copy them (CTRL-C) or B) Edit-->C) Copy and then Edit-->D) Paste features as a new vector layer if you want it permanent or a Temporary scratch layer if you do not.
The 4) icon with an i in the blue circle with an arrow allows you to click on a geometry on the canvas and get its stats.
The 5) + magnifying glass allows you to draw a rectangle on the canvas to zoom in.
The 6) - magnifying glass allows you zoom out.
The 7) 1:1 magnifying glass zooms to the native resolution.
The 8) magnifying glass with the arrows zooms to the full layer extents of the selected layer.
The 9) yellow box with arrows icon zooms to the selected geographies; and
The 10) hand icon allows you to move around the map
Here's a newer version of the 7ColorScale New 25 color style, this time with no borders. It's probably more necessary for @QGIS 3.0 than 2.18, because the No Pen border style seems to be wider. But it should work with either version of QGIS.…
I'm still experimenting with new QGIS 3.0. It seems to be a lot like 2.18, with a few menu and name changes. I think the tutorial still generally works, with changes. For example, the V+ icon to add a vector layer has been changed to a Layer Symbol+ Icon to add any layer type.
Version of my older Swing Color Scheme (that I think @SenhorRaposa has been using) without borders when using @QGIS 3.0. Technically, there's a hairline border that's the same color as the geography. No Pen/hairline seems to be too wide in 3.0:…
Next, I'll try to explain how I made my Idaho precinct shapefile when a source wasn't publicly available. A lot of this was done by trial and error, and I'm sure others will know a better way.
Publicly available non-shapefile precinct map sources come in a variety of formats. Some are Geospatial PDFs. QGIS can sometimes open these as a vector file - and almost always as a raster file. Others are simple .png or .jpg maps, which can usually be read as rasters.
Source availability varies by state. In Idaho, if maps are available, they are on county websites, usually on the County Clerk's website. Historic maps can sometimes be found by searching for the county clerk's page on
Here's an example of a Geospatial pdf that was done in a way to make making a shapefile out of it easy:

First, download Cassia County's 2016 precinct map from here:…

Save it onto your computer as a pdf file.
Open the pdf in QGIS as a vector file. If you're using QGIS 2, the instructions to do this are above. As I'm now using QGIS 3.02, this will also serve as a lesson in the slightly different way QGIS 3 uses to open files.
In QGIS 3, I think you can still drag your file to the canvas to open. But if you're used to using the V icon to open a vector file like I was, the icon to open ALL files is different. It looks like 3 different colored rectangles. See 1 below.
Next, you have to select your file type from the tabs in the pop-up dialog. For pdfs, try Vector first (at 2) - it may or may not work. Next, hit the dots (next to 3) and navigate to your saved pdf file. QGIS will probably take some time, but another dialog will eventually open..
after you hit add. A new dialog should open up, listing the component shp layers hidden in the pdf file - maybe. Not every pdf is a geo pdf, and not every geo pdf is a vector file. Here, we're lucky - not only is there a precinct layer, but it's a polygon layer. Click on that.
Unfortunately, not every polygon precinct layer will be properly georeferenced so that it ends up in the right place on your map. Again, we're lucky here - Cassia County's 2016 map is properly georeferenced. To test this, check it against census' county or VTD shapefile.
Hitting OK will add the precinct layer to your map.

Next, we need to add Precinct IDs to the various precincts so that we can merge data. I like to add two columns - one with the precinct name, another with what the state's VTD layer would likely use as a GEOID.
GEOIDs usually start with the state code (ID is 16) followed by the county code repeated twice, followed by a three-digit precinct number (with leading 0s if the number is 1 or two digits). Cassia County is 031, so the first precinct in Cassia would be 16031031001, etc.
Next, we'll need to know which of the precincts are which before adding the info to the layer. To do that, we'll need to add a vector layer label or raster map file. I don't see any vector layer label file here, so we'll have to add the map as a raster. To do that...
first, we'll make the Cassia County precinct vector layer transparent. To do that: 1) Double left click on the layer name in the layer panel. A dialog will open up. 2) Select the symbology tab. 3) Make sure All Symbols are shown, and choose Outline Red. Hit OK.
Next, we'll add the Cassia County 2016 pdf as a raster. 1) Hit the three rectangle icon to open up the Data Source Manager. 2) Select the raster tab. 3) Hit the 3 dots and locate your 2016 pdf. Hit add. Eventually, the map will be added to your canvas.
If you don't see the red precinct outlines, you need to drag the precinct polygon layer (symbolized by a red outline in the layer panel) above the raster layer (symbolized by the blue and black checkerboard icon).
Finally, we'll add the precinct names and GEOIDs to the 2016 precinct polygon layer. To do that: 1) Select the 2016 precinct vector layer. 2) Hit the pencil icon to enable editing. 3) Hit the Connecticut Avenue monopoly card looking icon to open up the attribute table...
4) Hit the icon on the attribute table next to the funnel to bring the selected shape(s) to the top of the attribute table. If you're using windows, you can then hit Windows-Right Arrow to put the attribute table on the right of the screen, then open QGIS and hit Win-Left Arrow.
We'll then add Name and GEOID columns. 1) Hit the add field icon. It looks like a graph with an orange bar. A dialog will open up. 2) Name your column (Name). 3) Select Text from the drop-down menu next to Type. 4) Provide a length (30 is usually enough). Hit OK.
Do the same to create a GEOID column.
First, we'll add the actual precinct names.

1) Hit the Select Features Icon on top.
2) Make note of the name of a precinct and click on it.
3) Because the selected features are up top, all you need to do is click on the top entry in the Name Field and add it (here, Parsons).
Repeat steps 1-3 for all of the other precincts. You'll probably need to look at the inset map or key to identify the precincts inside the city of Burley, as some aren't labeled on the countywide map. You can just select a precinct and pan over to the inset map, if necessary.
Once you're done adding precinct names, it's time to create a GEOID. Ideally, the precinct ID part of the GEOID should be in the same order that Idaho SoS used in reporting the 2016 results. Those results are available here:…
In 2016, the Cassia County precincts were reported Burley first and then in alphabetical order. They started at 101 and ended at 124. Using the '16 results as a template, for precinct names add GEOIDs. It should be in the format 160310311XX.
Once you're done, it's probably best to double check your work by selecting the precincts again and checking to make sure they're right. Then, 1) click on the pencil icon and 2) hit Save in the pop-up. Finally, 3) PERMANENTLY save your file by RIGHT clicking on the 2016 layer....
name and selecting "Save As". A dialog will pop up. 1) Make sure you're saving as an ESRI shapefile. 2) If necessary, change the projection to Census' default, 4269 - NAD 83. 3) Click on the 3 dots, navigate to where you want to save your file and name it. 4) Hit OK.
If successful, a new solid layer should pop up covering your map.

Those are the instructions for making a simple shp from a good vector pdf source with a perfectly georeferenced precinct polygon layer. Tomorrow or Wednesday, I'll try to explain what I do when it's not perfect.
Missing some Tweet in this thread?
You can try to force a refresh.

Like this thread? Get email updates or save it to PDF!

Subscribe to cinyc
Profile picture

Get real-time email alerts when new unrolls are available from this author!

This content may be removed anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Did Thread Reader help you today?

Support us! We are indie developers!

This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member and get exclusive features!

Premium member ($3.00/month or $30.00/year)

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!