qgis basics for journalists
Frequently, you will want to find out how two sets of data relate to each other. There are several plugins that will help you do just that.
Points in Polygon
The Points in polygon tool will compare a point layer and a boundary layer. It counts the number of points for each boundary and creates a new shape file that contains a column with the resulting data.
Create a new project with an Alameda tracts layer and a toxic releases point layer.
Go to the Vector menu -> Analysis Tools -> Points in Polygon. This opens a window and your polygon layer and your points layer should be selected.
Change the Output count field name to TOX_REL_CT for toxic release count.
Click Browse to save to a new file and folder. Click OK. QGIS will save the file and ask if you want to load it into the project. Click Yes.
Right-click on the new layer and open the Attributes table. Scroll all the way to the right and you will see the new column. If you wanted, you could color code the new layer based on the count data.
The Buffer tool allows you to create a new boundary a specific distance around shapes. For example, rivers often have development buffer zones to protect them from development. By creating a buffer along a river (a line), you can see if development has encroached and threatens the river. Or you may want to see how how many toxic release sites (points) are within 1000 feet of a school (points). Let's look at this last example.
Before we start, we have to change the projection on our shape files and re-save them in order for the Buffer operation to work. QGIS's 'on the fly' projection feature will not work.
Right-click on the alameda tracts layer and select Save as... Make sure the format is set to ESRI Shapefile. Then name it alameda-tracts-utm and save it in a new folder. UTM stands for Universal Transverse Mercator and is the projection we will use.
Look for the CRS field. It should say Original CRS. Click the Browse button next to it. Type 26910 in the search field. Make sure you're searching by ID then click the Find button. The NAD83 / UTM zone 10N projection will be highlighted. Click OK.
Now lets do the same thing with the toxic releases layer. Right-click and select Save as... Make sure the format is set to ESRI Shapefile. Then name it toxic-releases-utm and save it in a new folder.
Click the CRS Browse button. This time NAD83 / UTM zone 10N projection will be in the Recent CRS area. Select it and click OK.
Create a new project, load the alameda-tracts-utm file and then the toxic-releases-utm file.
Go to the Vector menu -> Geoprocessing Tools -> Buffer(s). This opens a window and your toxic-releases-utm layer should be selected.
Setting the Buffer distance can be a bit tricky. The UTM projection only uses meters. Let's set up a 1,000 meter buffer by entering it in the Buffer distance box. If you want to create a buffer in feet you have to convert. For example, a 1,000 foot buffer is 304.8 meters.
Save the output shapefile as toxic-buffer-utm in a new folder and click OK. Add the layer to the project when prompted and close the buffer window. We'll add some schools in the next section.
The MMQGIS plugin offers a lot of tools and one of the most useful is the Geocode from Google. It's simple to use but the process may take a while so if you get the spinning beach ball of death, wait it out. Also, Google limits the number of addresses you can geocode, which can cause large datasets to fail.
Go to the Plugins menu -> mmqgis -> Geocode with Google. This opens a new window. Click browse and navigate to the alameda-schools.csv file in the data folder.
The plugin auto-detects the street, city and state fields. Hit OK and wait for this to process. Don't be surprised if it takes 10 minutes or longer based on the number of addresses.
When it's finished, a layer will appear. The final thing we need to do is change it's projection. Go to the File menu ->Project properties. Check Enable 'on the fly' CRS transformation. Select the NAD83 / UTM zone 10N projection Recent CRS area and click Apply.
Now you can zoom in and see where schools overlap the buffer areas. You could also use the Points in polygons tools to get an accurate count.
NOTE: We'll continue updating this section as time permits