qgis basics for journalists
Understand, load, export map files
There are several formats that QGIS and other GIS apps will open and export. The most common is the SHP or "shape" format. While other filetypes are important, we will work with SHP files in this tutorial.
How SHP files work
SHP files are made of editable "vectors." All that really means is that it calculates the distance between points on a map and draws lines.
There are three types of SHP files:
Point files include one or more specific locations. This is essentially what you see on a Google map.
Line files connect groups of points. These can be used to draw roads, rivers, etc.
Polygon files connect points into closed shapes. The shapes usually form boundaries such as ZIP Codes or tracts.
And if they all use the same projection, they can be accurately layered together.
And finally, SHP files are really a collection of files:
SHP contains the drawing information.
DBF contains the data about each shape, such as name, address, etc.
SHX is an index file that ties the two together.
PRJ contains the projection information.
Some agencies will also include metadata which describes properties of the files.
Import a shape file
So lets get started. Download the project files and unzip them. We're going to be working with 2010 census tract files of Alameda County, Calif.
Go to the Layer menu and select Add vector layer (Command-shift-V). Navigate to the project files and open SHP files - source folder, then the alameda-2010-tracts folder and then click on the file that ends in .shp and click Open. A map will appear in the layout area and a layer is added to the panel.
Edit the layer properties
Go to the Layer menu and select Properties. A new window will appear. Symbology should be selected by default. Click the Properties button:
In the new window, change the Fill color and the Border color and click OK. This will take you back to the properties window. Click the Apply button on the bottom left corner to see the changes or click OK.
Changes in Version 1.7: There were some substantial changes to Layers properties. The vertical menu is now a set of horizontal tabs. The image below notes the important changes.
Search data to select boundaries
One of the quickest ways to select shapes in a layer is with search. Go to the Layer menu and select Open Attributes Table. This opens the information in the DBF file. The initial columns usually identify each record. In this case, we see six columns of Federal Information Processing Standards (FIPS) IDs.
NOTE: FIPS abbreviates names of places to make files smaller and make it easier to join data with SHP files. In this case, 06 is the state of California, 001 is Alameda County, 437800 is the name of a tract and 06001437800 is the complete Geographic ID.
The row of buttons let you edit the data and the Search field lets you find specific records. QGIS can search inside individual cells and select ranges based on the content of cells.
Scroll the window to the right until you see the column NAMELSAD10. In the search field, type 4378. Then change the pull-down menu to NAMELSAD10. Click Search and the field will highlight and tract 4378 is selected in your map. It's small and you may have to look closely.
Click the Advance Search button. In the Fields area, click on AWATER10. Look in the Values area and click the All button. This gives you all the values in the AWATER10 field — the square meters of surface water in each tract.
The Operators buttons help you build search queries. Once you are comfortable with the syntax, you can type them directly into the text field. If there is anything in the text field now, select and delete it.
Double-click AWATER10 to add it to the text field. Click the Greater Than ( > ) button and then type 1000000. This will search for tracts with more than 1 million square meters of surface water. Click the test button and it tells you how many tracts will be selected. If you get an error, make sure the query matches the image below.
Click OK and return to the Layer Properties window. Click OK again to close it. You should see several tracts selected.
Save selection as a new SHP file
This is a handy tool when you need to extract a few boundaries from a large map file. You can search for and select the boundaries you need, go to the Layer menu and select Save Selections as Vector File.
Create a new folder to keep all the files organized and Voila! — a new shape file.
Save your work.