QGIS lesson 27 – Creating a choropleth / heat map

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
either welcome back in this this I'm going to show you how to create a choropleth map or heat map of some data for US counties so first things first this get hold of the shape files in the data so if you click on the two links below the video one will take you to the poverty data for u.s. counties and the file you want is this one here the est 10 or XLS file so download there and the shapefile you're going to want is the 500k CB 2013 I'll use the Census Bureau shake files instead of the tiger che files because the Census Bureau ones have the county's clipped to the coastline whereas the tiger ones extend out into the sea and I think the sensible ones are better so that they because they basically look more like the coastline even expect so download those two files and then let's go to QGIS and load them in so first things first is good at show you file load in the shapefile there's that County shapefile and the next thing you want to do is open up the XLS file in Excel so let's open now ok that's quite a large file but the only columns that were interested in are the the first four which gives the state 50 code and the county FIPS code the postal letter code and the name of the county and the other column we're going to be interested in is the percentage of poverty for all ages now when you're doing a heat map or choropleth is better to use percentages than absolute figures because obviously County has more population in it and the figures are going to be higher so if you use the percentages than that evens out for everything so I'm just going to remove the columns I don't need so just going to select the columns and then delete so all I'm going to be left with five columns I need to select one of those just control click and then delete so now we've got out of five columns what we need to do is find a way of joining this table this excel file with our attribute table so let's go back and have a quick look at the attribute table so as you can see it's got the same state and county number but we can't join on the County numbers because they all begin with the same number the first 50 counties they all begin with 0 0 1 and so on the way the you identify the counties is using the Geo ID which is a combination of the state number and the county number which then creates a unique number here so we're going to try and create this geo ID column from our excel file so let's go back to our excel file and what we need to do is basically join these two cells together and because they're numbers we need to treat them as text because if you just do 0 0 & 0 0 0 it's just going to give you 0 so what you need to do just keep that name column a name is in your formula function here my equals text open brackets then click on cell a4 comma open quote 0 0 it's basically signifying that you want to keep both figures and then an ampersand and then text again open click on cell b4 comma open quote and then three zeros this time because there's three numbers there close quote close parenthesis and hit enter and there you'll see you'll have five zeros so in order to fill this entire column just click on the first Dale and then scroll down till you get to the bottom of your table almost there okay hold down the shift key click on the last cell then go to home and you see this fill click on that and click on the down one and that basically fill in the entire table with all of the cells so what we need to do now is just select the first row and we just want to delete that so our column headings are at the top so just delete that and now we just want to save this as a CSV so choose your format CSV save that now when you've saved your CSV file you need to go ahead and create a nother file it's just a simple text file because when you join a CSV file to a shape file inside huges you just needs to know what type of data is in each column so if you just bring in a CSV straight into cutis it just treats all of the columns of strings so your poverty column here will be treated as a string and it won't be able to calculate how to do the corp left coloring so you just need to go to any text file text editor I'm just going to open up the CSV so you can see what I'm talking about so basically you've got your column headings state FIPS county foods postal name poverty and geo ID if you just drag the straight in it's going to treat all of these are strings so what you need to do is create a separate text file first of all I just want to go to that top line there so we've got the column headers right at the top just say in fact so you just basically need to create a new text file and start off by putting string and just copy that and paste it in six times because we've got six columns one two three four five six so put string in six times there's the comma from the end and you just need to put in the word integer for the column that we need to treat as a number which in this case is the poverty one so in here and just type in the word integer and you need to save this as the same name as your CSV we just put a T on the end so it's a csv text file so save that and now drag your csv into qgs that it appears is a little table file here so now we're going to do the join of the table to the shapefile so double click on the layer go to joins click the green plus sign the join name is the es10 all and the column we're going to join on is geo ID and the target field is also geo ID so that's okay that and okay there and you'll now see when we look at the attribute table that all of the data from spreadsheet has now been correctly pulled in to our file so now what we need to do is color it up so double click on your layer go to style and there's a couple of choices you can either have categorized or the other one is graduated so graduated the select the poverty column and you've got a choice of how many classes you want basically means how many categories let's just click the classify button here so now you've chosen your column for the poverty click on classify and it creates these color bounds so the data is looking at is between 0 and 15 and is created five pounds if you increase the classes get as many colors as you want you can also obviously change the colors choices look up to you completely up to you how you classify and what colors you choose and how many intervals i always suggest using the natural breaks the Jenks method of distributing the data it just distributes them to comers in the best way normally trusting an equal more equal number of data into each category so you can see that the categories aren't evenly spread out it's not 0 to 10 10 to 20 30 to 40 and so on so if you go ahead and apply that you will see now you have a beautiful claw of left for the data that we are poured in on from the CSV so the other thing we want to do now is just change the projection so come on shift P to bring up your project and choose the US a contiguous albers equal-area conic projection this is a nice one for the US and it gives that nice curve on the Canadian border so but as you can see Alaska and Hawaii are obviously big and quite a long way away from our main map now what I'm going to do is show you how to create a nice view in the print composer consisting of the main mainland of the US with Alaska and Hawaii just down here in the bottom left corner so let's first of all zoom in on the US bring up a print composer a4 is fine and just add a new map so the usual way click on the curly piece of paper add in our new map now just go back to your main window and now what we're going to do is choose a different projection so we're going to choose the Alaska albers equal-area so choose that and then just zoom in on Alaska so and then go back to your print composer and then just add another map in so there's our Alaska the bottom left corner and again similar leaders before go back to your map zoom out zoom in on Hawaii and then go back to your project properties and change the projection to Hawaii albers equal-area conic and just zoom in and then again back to your print composer add another map and there so now when you save this you now have your mainland your Alaska and your Hawaii all on the equal area projections and all in one nice shape with Alaska and away nicely tucked in the corner now you can obviously add a legend here at this point or you can then export this map and take it into illustrator week scape so I'm going to quickly show you how to add a legend so it's just click on this button here add new legend and then just click and drag the window and then just resize your map just reposition it so you've got space for your legend so there you go that's map without legend in obviously like Sao prefer up fur to actually create this legend inside a vector editing program just so you've got more control over but if you need to do a quick map and you're happy with the legend provided by QGIS then by all means use it you
Info
Channel: Steven Bernard
Views: 36,213
Rating: undefined out of 5
Keywords: QGIS (Software), Heat map, choropleth, map, maps, mapping, tutorial, lesson, QGIS Uncovered, excel, formula, join, joining, data join, csv, graduated, Jenks, print composer, CRS, Choropleth Map
Id: rG6UphZGmg4
Channel Id: undefined
Length: 12min 43sec (763 seconds)
Published: Wed Mar 11 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.