In-class Excercises
Part 1: Hexbins
Here we make two choropleths using Points in polygon—one with the PA counties and one using a grid of hexagons.
- Open
Oil_Gas_Well_Historical_Production_Report.csv
from last time's data or download it now. We will call this data the "wells" layer from now on. - Save the wells as a new layer and convert to projection
3650
. Remove the original wells layer. - Open
PaCounty2015_01.shp
, use Save As to save in the projection3650
, and use Points in polygon to count the number of wells in each county. Make a choropleth of the result. - Ensure your project is also in projection
3650
. Check in Project > Project Properties. - Install the MMQGIS QGIS plugin if you have not.
- Create a hexagon layer using MMQGIS, MMQGIS > Create > Create Grid Lines Layer:
- Browse for a location for the new shapefile.
- Change the dropdown at the bottom to Hexagon.
- Adjust the size of the hexagons by changing H Spacing to
52800
.
- Count the wells in the resulting hexagons using Points in polygon.
- Make a choropleth with the resulting layer.
Part 2: Heatmaps
- Install (or enable) the Heatmap QGIS plugin if you have not already done so.
- Open the wells file projected to
3650
from the previous part. - Create a heatmap by going to Raster > Heatmap > Heatmap:
- Select an output raster location.
- Set the Radius field to
10560
.
- Style the output raster. Use Singleband Psuedocolor.
- Make more heatmaps, adjusting:
- the resolution of the raster (rows and columns)
- kernel shape
Part 3: Creating Shapefiles
- Clear all existing layers in QGIS.
- Load a satellite layer and zoom to an area of interest.
- Create a shapefile: Layer > Create Layer > New Shapefile Layer.
- In the New Vector Layer dialog:
- select Point for Type,
- leave File encoding as it is,
- pick a projection, and
- add a few attributes, with a few different Types.
- Turn on Editing Mode for the new layer (Layer > Toggle Editing).
- With the Add Feature tool and the satellite layer as a reference, add a few points and add data to the points when prompted.
- Use the Move Feature tool to move one of your points.
- Create a shapefile of lines. Use the satellite imagery to trace and create some roads and/or waterways. Right-click to finish each line.
- Create a shapefile of polygons. Use the satellite imagery to trace and create features for buildings, areas, and/or larger waterways. Right-click to finish each polygon.
- Experiment with other edit functions available under the Edit menu.
Part 4: Georeferencing
- Go to Urban Reviewer.
- Find an urban renewal plan with a map image on the right when you select it. If you have a hard time finding one with a scanned map, use the Pratt Institute plan.
- Click on the image to make it larger, then right click on it and save as to save it to your computer.
- Open QGIS.
- Add a satellite base layer with labels. I would suggest the Google Hybrid layer.
- Zoom to the general area your image should be in.
- Install or enable Georeferencer GDAL in the plugins area of QGIS.
- Go to Raster > Georeferencer > Georeferencer to open the Georeferencer window.
- Go to File > Open Raster and select the image you downloaded from Urban Reviewer.
- Add 3 or 4 ground control points:
- Switch between the Georeferencer and map windows and find a common point between the two (generally a street corner will be best).
- Click the Add point button in the Georeferencer window.
- Click on the common point in the Georeferencer window.
- When prompted to Enter map coordinates, select the From map canvas button.
- Click on the common point on the map.
- Once you are happy with the ground control points, click the Settings icon in the Georeferencer window.
- Set Transformation type to Thin plate spline.
- Set Target SRS to 3857 (the projection the reference map is in).
- Select a location to save to.
- Check Load in QGIS when done.
- Click Start Georeferencing in the Georeferencer window (looks like a play button).
- The Georeferenced image should show up on your map.
- Find a ground control point that doesn't line up as much as you would like.
- Delete the ground control point in the Georeferencer window.
- Add a replacement ground control point.
- Georeference it again—by default your georeferenced image will be overwritten, so change the destination in the georeferencer settings if you want to make a new file.