This workshop covers the basics of desktop GIS for new users using the open source QGIS app. No previous GIS experience is required. If you are taking this workshop in person, you will need to bring a fully charged laptop.
Please visit the QGIS website to download the desktop app. We recommend you install the Long Term Version for your OS.
We will be using the following data in this workshop:
City boundaries for San Francisco
Seismic Hazard zones
Streets
SF Police and Fire departments
Digital Elevation Model of San Francisco
You can download the data packet here. Please copy and unzip the downloaded folder to your Desktop.
Open QGIS. If you have used QGIS before you may see thumbnails for Recent Projects in the main window. We want to start a new project so you can ignore these and go to the Project menu in the upper left of the window and select New. Or double click the New Empty Project page under the Project Templates in the lower right hand corner.
The center window is the Data Frame where our map will draw. The Layers panel is where we organize the various data layers added to our map. At the top of the window are various Toolbars for interacting with QGIS.
The Browser Panel on the left lets you navigate around your computers hard drive to open projects, import new data, copy/delete/move data around.
Go to the Project > Save menu in the upper left and browse your way to the QGIS_quick_start folder you downloaded earlier. Save your new project as SF_Map.
Note that a new Project Home connection is added to the Browser panel once you save the project.
GIS apps create connections to data on your HD versus saving data directly in the project and the Browser panel makes managing your data connections easier than using the Finder or File Explorer windows on your computer. Best practice for new GIS projects is to collect all of the data for the project together into a new folder then save your QGIS Map Project into that folder. If you ever need to move the project around, always zip up and move the entire project folder, data and QGIS map project, together. Otherwise you risk separating the data from the project.
You can add data to your project from the Layer > Add Layer menu, from the Data Source Manager tool, or by dragging the layer in from the Browse Panel.
Vector data are identified with a point, line, and poygon icon in the Browser window.
Go to the Browser Panel > Project Home > SF Data folder. Click and drag the SF_shoreline.shp file into the data frame. Now do the same for seismic_hazard_zones.shp and SF_streets.geojson.
Note that the first data layer imported to any GIS project will set some of the map parameters, in particular the current view extent and the project coordinate system. Our map project has been set to EPSG: 4326 as the coordinate system and the map view extends out to the Farallon islands to the West of San Francisco. Right click on the SF_Streets layer and select Zoom to Layer to change our map extent.
You can preserve this view with a spatial bookmark. Go to the View menu and select New Spatial Bookmark... Give the bookmark a name, like SF, and click Save. To return to an existing bookmark use the Bookmark Manager panel, or find the bookmark in the Spatial Bookmarks folder in the Browser panel.
Raster data are identified with a grid icon in the Browser window.
Go to the Browser Panel > Project Home > SF Data folder. Click and drag the DEM_SF_UTM10N.tif file into the data frame.
If the new raster layer draws in above the other map layers you just need to change the drawing order in the Layers panel. Click on the DEM layer and drag it to the bottom of the layer list. The other layers should be visible again. To hide the layer in the map view uncheck the box next to the layer name.
CSV data are identified with a table icon in the Browser window.
Dragging a table directly into a GIS project won't add the data to your map. Instead we need to plot table data based on coordinate attributes. If you right click on the SF_fire_and_police.csv to open the file externally you'll see that it includes fields for longitude and latitude. We'll use these to plot the data as points in the map.
Click the Data Source Manager button from the toolbar.
Select Delimited Text from the left side of the window.
In the File name bar, browse to the SF_data folder on your desktop and select the SF_Fire_and_Police.csv.
In the Geometry Definition options, check that the X field is set to longitude and the Y field is set to latitude.
Click the Geometry CRS drop down and set it to EPSG:4326 - WGS 84.
Leave all other fields set to their defaults and click Add then Close at the bottom right.
While the new point layer in your map looks just like a regular data layer in QGIS it is important to understand that you did not actually create a new map dataset. This map layer is being dynamically drawn for you by QGIS as it read the original CSV. If you move or rename the CSV file these points will disappear. You can save any dynamic or temporary layers in QGIS by right clicking on them and choosing Export > Save Features As...
To view the coordinate system of a map layer, open the layers Properties and go to the Source tab.
Double click and open the Properties > Source menu for the Seismic Hazard Zones layer. Note the assigned CRS.
Double click and open the Properties > Source menu for the SF_streets layer. Note the assigned CRS.
Each map layer has its own CRS as defined by the data file itself. Map layers with different coordinate systems can be added to the same project but the map view window can only display one CRS at a time. QGIS is able to display map layers with different coordinate systems in the same view by applying an "on-the-fly" projection.
The Project Coordinate System is set in the Project Properties and defines which CRS the map view window will display. You can see the current map project CRS as an EPSG code in the lower right hand corner of the map window. EPSG codes are the unique numeric identifier for each CRS. Clicking on the EPSG code text will open the Project Coordinate System menu. From here you can see the full name and description of the CRS. The preview map shows a red box that indicates the current CRS bounding envelope.
Click on the ESPG text in the lower right corner of the map window to open the Project Coordinate System menu.
In the Filter bar enter the EPSG code from the SF_streets layer: 32610
Click to select the WGS 84 / UTM zone 10N CRS from the filtered list in the bottom window.
Click OK to close the Project Coordinate System menu.
If you paid attention to the map in the background when changing from EPSG 4326 to EPSG 32610 you might notice that the map shape changed a little. All of the map layers are now being displayed in the new on the fly CRS.
You can add a vierety of different custom tools and functions to QGIS through the community created plugins menu. We'll add one now that lets us load different dynamic basemaps to the back ground of our project.
Open the Plugins menu and go to Manage and Install Plugins...
In the Search bar type QuickMapServices.
Click Install Plugin to load the plugin then close the plugins menu.
Different plugins will show up in different location in the QGIS interface. This plugin can be found under the Web menu, but it still requires one more step to make it fully functional.
Open the Web menu and go to QuickMapServices > Settings.
Go to the More services tab and click Get contributed pack.
Click Save to close the Settings menu.
Now re-open Web > QuickMapServices and select the OSM Standard basemap.
Basemaps are great for ensuring locational accuracy of imported data sets, or creating quick map exports without having to spend a lot of time building a custom background maps.
The Layer Styling Panel will help with symbolizing both Raster and Vector layers in our map. You can do all of the same styling operations from the Symbology menu of each layers Properties, but the Layer Styling Panel makes it much quicker and easier to iterate through different symbols choices as you play around with styling.
From the View menu go to Panels and select Layer Styling Panel to add it to the side of your map window.
Turn off all map layers except the DEM_SF raster layer. The default symbology for an elevation raster is a black to white color ramp that resembles an x-ray image of the terrain around San Francisco.
Click to select the DEM layer in the Layers panel.
In the Layer Styling panel use the drop down to change the Color ramp from Singleband grey to Singleband pseudocolor.
Toggle open the Min/Max Value Settings options.
Change the Statistics extent to Whole raster and the Accuracy to Actual.
Set Interpolation to Discrete.
Open the Color ramp drop down go to All color ramps and select the BrBG ramp.
Change the Mode to Equal interval and the Classes to 10.
Double click to enter new breaks in the Value list: 0, 50, 75, 125, 175, 225, 275, 325, 350, and inf.
Turn back on layer visibility for SF_shoreline, seismic_hazard_zones, and SF_streets (click the checkbox next each layer in the Layers panel).
The default styling for any layer will always be Single Symbol which shows all features with the same symbology. But we can use characteristics of the data itself to set layer symbology. In this case we are going to use the classcode attribute to set the line thickness for all of the streets in San Francisco.
Value Legend Line Weight
0 Private Streets 0.5
1 Freeways 3.0
2 Highways 2.0
3 Major Streets 1.0
4 Secondary Streets 0.5
5 Local Streets 0.5
6 Freeway Ramps 0.5
If you haven't already, add the Layer Styling panel (View > Panels > Layer Styling).
Change the Single Symbol drop down to Categorized.
Set the Value field to classcode.
Click Classify to add all the values to the legend builder window.
Uncheck all other values.
Under Legend double click and update each value to match the table above (e.g. change 0 to "Private Streets", change 1 to "Freeways"...).
Next double click the sample line symbol for Private Street (classcode 0) to open the symbol properties.
Change the line color to black and set the Width to 0.5 Points.
Click the Go Back arrow to return to the legend view.
Use the table above to set each of the remaining streets to their new symbology.
Click on the Select Features icon in the menu bar (white arrow over small yellow square).
Click on the SF_streets layer in the Layers panel to make it the active layer (blue highlight bar with show over layer name).
Zoom into the map and click to select a road segment (or click and drag if direct selection is not working).
Right click on the SF_streets layers and select Open Attribute Table (notice the heading which should indicate how many feature are selected).
Click the dropdown in the lower left corner of the table to change the view from Show All Features to Show Selected Features.
Reset the view back to Show All Features.
From the table icon menu click on the Deselect All Features icon.
From the left side of the attribute table, click on one the numbered buttons to select that row in the table.
From the table icon menu click on the Zoom map to selected rows icon.
Deselect all features again and close the attribute table.
Features will turn yellow to indicate they have been actively selected. If using the direct click to select method is difficult you can click and drag a small box over the features you want to select as well, or click and drag to select many features at once.
Notice that you can direct select by features by clicking on them in the map or by selecting rows in the attribute table.
Direct selection has it's uses but more often we need to make a selection based on some characteristic of the data. We can use expressions to make selections based on information in the layers attribute table. For instance, let's say we wanted to select all of the Major Streets in San Francisco, we can make an expression that finds all of the street segments with a Major Street attribute value (3) in the classcode attribute.
Click on the Select Features Using an Expression icon.
Toggle open the Fields and Values list in the center panel.
Double click classcode to add it to the expression window on the left.
Single click the = symbol below the expression window.
Click the All Unique button in the values window in the lower right corner then double click the value 1 to add it to the expression.
The finished expression should look like this: "classcode" = '1' .
Click Select Features then Close to close the expression builder window.
All of the road segments with a classcode 1 for Freeways will now be selected in the map. You can play around with different classcode values to see how they selection chnages. When you are done, use the Deselect Features button to clear the selection.
Go to the Processing menu and click Toolbox to open the Processing Toolbox.
In the search bar enter Statistics by categories.
Set the Input vector layer to SF_Fire_and_Police.
Set Field with categories to Jurisdiction.
Leave all other parameters set to their defaults and click Run.
Right click and choose Open Attribute Table for the resulting Statistics by category output layer.
The result is a count of how many features in the map are Fire vs Police departments.
Go to Vector > Data Management Tools> Join Attributes by Location.
Set Join to features in to SF_fire_and_police.
Set By comparing to to seismic_hazard_zones.
Click the button for Fields to add, select Hazard then click OK.
Leave all other fields set to their default and click Run.
Open the new layer's attribute table and inspect the Hazard column on the far right.
The resulting output layer is a duplicate of the original SF_fire_and_police layer but it now has an additional Hazard column. Any fire/police points that overlapped the seismic hazard zone will have a "Seismic Hazard" value in the new field. Any points that were not inside the seismic hazard zone will have a NULL value. You can use this new attribute to create new filters, selections, or feature symbols.
A definition query is similar to an attribute query but instead of selecting features based on an expression we'll create a filter so only features that match the expression are shown in the layer. Definition queries act like we've deleted those features from the layer, but removing the query will bring the features back.
Double click on the SF_Fire_and_Police layer to open its Properties.
Go to the Source tab and at the bottom of the window, select Query Builder.
From the Fields list on the left double click jurisdiction to add it to the expression builder window.
Click the = sign to add it to the expression.
Click All under the Values window and double click to Fire Department to add it to the expression.
The final expression should be "jurisdiction" = 'Fire Department'.
Click OK on the expression builder the OK on the Properties window.
Map layers in the Layers Panel are individual instances
A full tutorial on building a sound cartographic style and working with the QGIS Print Composer tool can be found here. Below is a quick workflow for creating a map layout. The core feature to understand in the Print Composer is that whatever map element is currently active in the layout will be the configurable in the Item Properties tab to the right of the print layout window. Just experiment with the different tools and properties to see how they all work.
From the toolbar click on the New Print Layout icon (or go to Project > New Print Layout...).
Give your new layout a name and click Ok.
In the new layout that opens, click on the white art board and go to the Item Properties tab on the right.
Set the Size to Custom and the units to Inches and enter 10" for Width and Height.
From the toolbar on the left select the Add Map icon then click on the art board to open the New Item Properties menu.
Change the units to inches and set the Width and Height to 10".
Enter 0 for the X and Y origin point then click Ok to place the map.
Adjust the scale and position of the map content from the Item Properties and using the Move item content tool.
Use the Add Label tool to add a map title and Add Legend tool to add a legend.
Fine tune as needed then export the map layout from the Export as image icon in the top menu bar.
Give your map a name, set the export resolution to 150 dpi or higher and click Save.