This in an introductory GIS workshop using QGIS.
QGIS is an open-source desktop mapping and spatial analysis tool for Mac and PC that is free for anyone to install and use.
This workshop is intended for new GIS users or anyone who may need a refresher. We will cover both the basics of the QGIS application as well as general geospatial concepts that apply to other tools and workflows.
Download and install
Setting up your project workspace
Adding geospatial data
Plotting coordinates from a CSV
Basic layer symbology
Attribute driven layer symbology
Basic spatial analysis and geoprocessing
Simple map exports
Visit the QGIS Downloads page to download the desktop app. There are usually several versions to choose from. We recommend always installing the Long Term Release for best compatibility.
Click the Workshop Data link to download the zipped data packet for this workshop.
Once downloaded make sure you unzip the data fodler. Mac users can just double click to unzip but Windows users MUST right-click and select Extract All...
A quick note about where to house your GIS projects.
To keep things simple for this workshop we'll keep the data in your Downloads location. But for future GIS projects best-practice is to always set up a project specific folder in the Documents folder on your hard-drive.
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 New Empty Project under the Project Templates in the lower right hand corner.
The large empty main window is your map view. There are a few default toolbars along the top.
On the left you should see a Browser panel and a Layers panel.
The Browser lets you navigate your computers HD from inside QGIS. And Layers is where we will see a list of the map layers added to our project.
You can add GIS data by simply dragging and dropping it from your HD into the QGIS map window, or using the Layer > Add Layer menu.
But its much easier to manage a GIS project when everything is one place and that folder is directly connected to the QGIS Browser.
When you first save your new GIS project, whatever folder you save it in becomes the new Project Home and links itself to the Browser.
Go to the Project > Save menu in the upper left and browse your way to the SF_Data_QGIS folder you downloaded earlier.
Save your new project in the data fodler as SF_Map.
Note that a new Project Home connection is added to the Browser panel once you save the project. You can use this connection to manage all of your project data and exported maps.
If you need to add other folders to this project, you can right-click on Favorites in the browser and add them there.
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.
If you toggle open the Project Home folder in the Browser you will see all of the contents that QGIS recognizes as spatial data (including images and CSV files).
You can right-click on data layers and select Add Layer to Project or simply drag them into the map view or Layers panel.
Click and drag the SF_county.shp layer into your map.
You should see the new layer draw in the map view window. If nothing appears, right-click on the new layer in your Layers panel and select Zoom to Layer.
Add the SF_liquefaction_hazard.gpkg layer.
Add the SF_streets.gpkg layer.
You can use the pan and zoom tools from the top toolbar to explore the map now. Note the Coordinate and Scale readouts at the bottom of the map view and how they change as you move around the map and scroll in or out.
If you look at the extent of the various layers in our map project you can see that one covers only San Francisco City, one includes offshore islands, and the other covers the entire bay area. There are a few different ways of dealing with mismatched data extents in GIS but one of the quickest is to set a Spatial Bookmark to the extent and scale you want to prioritize.
Right-click the SF_streets layer from the Layers panel and select Zoom to Layer.
Right-click on the Spatial Bookmarks folder in the Browser and select New Spatial Bookmark...
Name the bookmark SF City and set the Saved in location to Project Bookmarks.
Click Save.
Now when you open the Spatial Bookmarks folder you should see the new bookmark. If you pan or zoom the map away from this view you can always snap back to the exact same spot by double clicking the bookmark. You can use multiple bookmarks for different views.
Bookmarks are also a great way to ensure maps are always set to the exact same view when exporting a series of maps of the same place with different data shown (same data over time, or different data at the same place).
Not all map data needs to be in a GIS format. Anything you can get into a table with Lattitude and Longitude coordinates can be mapped as points in a GIS.
Tables show up in the Browser panel but you can't add them like other layers. We need to import table data through the Data Source Manager.
Click the Data Source Manager button in the toolbar.
Select Delimited Text from the left side of the window.
In the File name bar, browse to the SF_data_qQGIS folder on computer and select the HealthCareFac.csv file.
In the Geometry Definition options, check that the X field is set to longitude and the Y field is set to lattitude .
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.
New GIS users often get confused by what to choose in the Geometry CRS dropdown. The map project or your other data layers may be in different coordinate systems. Just remember that in the case of importing ccordinates from a CSV, QGIS is not asking us what CRS we want our data in. Its asking what CRS the coordinates in the X and Y column are from. In most cases that's going to be EPSG 4326 WGS 84.
If you ever add a CSV layer and find that the points do not show up on the map at all it's usually from picking the wrong import CRS.
If your points get added to the map but are transposed and appear in the wrong location it can sometimes be from assigning your Lattitude and Longitude values in the wrong order (X is longitude, Y is lattitude).
The order of your layers in the Layers panel is the drawing order they will have in the map. When an image or polygon layer is above a point or line layer, those layers will not be visible. Always try to arrange your layers with rasters at the bottom, followed by polygons, then lines, and points at the top.
You can re-order your map layers by clicking and dragging them around in the Layers panel.
Clicking the check mark next to a layer turns its visibility in the map on or off.
Double clicking on a layer name will open its Properties menu.
Associated with each vector layer is a table of attributes that helps describe the features on that layer. You can right-click on any layer in the Layer panel to open its attribute table.
Right-click on the SF_liquefaction layer and select Open Attribute Table.
The top bar on the attribute table will tell you how many total features re in the layer and how many are currently selected.
From the icon bar you can do thing like turn on an editing sessions and edit the values in the table. Or select features by attribute values with an SQL expression. Or create new attribute types and values with the field calculator.
If you click on the numbered button to the far left of any row that feature is selected in the map, you can then use the Zoom to selected row icon (magnifying glass) to zoom the map in to the selected feature.
From the SF_liquifaction note that there are a few general purpise id and gemoetry attributes as well a few that repesent data. The LIQ field is the text label for each ranking of liquifaction susceptibility (from very low to very high). The LIQ_rank field is the numeric value associated with those ranks from 1-5 (plus 0 for water).
If you open the attribute table for the HealthCareFac layer you'll notice a services attribte with categorical information for what services each facility specializes in.
Later we will learn how to use these attibutes to automatically style map layers by their data values.
A Coordinate Refernce System (CRS) is an framework for connecting geospstial coodrinates (XY or Lat/Long) to real world locations.
In QGIS both the map project and each map layer have a CRS. The project CRS is displayed as an EPSG code in the lower right hand corner of the map view - the layer CRS can be found in the Properties window under the Source menu (more on that later). EPSG codes are the unique numeric identifier for each CRS.
Each map layer in your project can have a different coordiante systems, but QGIS can only display one CRS at a time. As your map layers are added to the project, QGIS will perform an "on-the-fly" reprojection in order to display your layers together in the map view.
You can change the project CRS at anytime by clicking on the EPSG button in the lower right corner of the map view to open the Project Coordinate System menu.
From here you can see the full name and description of any 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 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 project CRS.
There are a lot of different options for picking a new CRS for your project. The most important considerations are that the new CRS be Projected rather than Geographic (more on this below). And that the envelope of the new CRS (shown as a red box in the Project Coordinate System menu) be as small as possible, but still contain all of your project data.
Changing the CRS of your project only changes how your map layers appear in the map view. When running geo-processing tools, QGIS will use the layer CRS to make its calculations, not the project CRS. If that system is Geographic rather than Projected the results of your analysis will be inaccurate (or the processing tool won't work at all).
Best-practice is to change all of your map layers into the same projected CRS. This is called warping or reprojecting.
Go to the Vector menu and open Datamanagement Tools > Reproject Layer...
Set the Input layer to HealthCareFac_SF.
Click the the Target CRS dropdown and set it to Project CRS: EPSY 32610.
Next the the fiedl that says [save to temoorayr layer] click the browse icon (three dot button).
Choose Save to file and browse your way to the SF_Data_QGIS folder on your HD.
Name the new layer HealthCareFac_UTM and click Save to close the Save to file window.
In some versions of QGIS you may need to look behind the main QGIS interface now to find the Reproject Layer menu.
Click Run to reproject you layer.
You can now Close the Reproject Layer menu.
Back in your Layers panel there will be a new HealthCareFac_UTM layer.
Right click on the old HealthCareFac_SF layer and select Remove.
As map layers are added to your project QGIS will assign random default styles and symbols. We can change those symbol styles through the Symbology menu in the layer Properties window or by opening the Layer Styling Panel from the Layers panel.
The Layer Styling Panel is generaly a better option as it is easier to work with and shows a live view of our styling changes as we make them.
First we'll change the color of the background layer SF_counties to a simple grey.
From the Layers panel click on the small paint brush icon to open the Layer Styling Panel to the right of the map view.
Click the layer dropdown at the top to pick the SF_county map layer.
Leave the styling type set to Single Symbol.
Select Simple Fill to change the symbol options below.
Click on the Fill color bar to open the Color Selection menu.
In the HSV sliders set H and S to 0, set V to 60% (for a 60% grey fill).
Click the back arrow at the top to retrun to the previous menu.
Now click on the Stroke color bar.
Ignore the HSV sliders but set the Opacity slider to 0% to make the outline stroke disapear.
Click the back arrow again.
Now lets set the Health Care Facilites layer to a new blue dot symbol.
Change the Layer Styling dropdown to the HealthCareFac_UTM layer.
In the Project Styles window under All Symbols, find for the blue dot and clck it.
And finally we can set the SF_ streets layer to a uniform dark grey street line.
Change the Layer Styling dropdown to SF_Streets.
In the Project Styles window under All Symbols, scroll down and find the grey 4 line and clck it.
Change the line Width to 0.25mm.
Building a good basemap is often as simple as removing all the color and extra lines or detail from any layers that are not part of the main project data. By changing the background and streets to different greys and removing the extra outlines, its easier to make the other layers stand out and draw attention with a little color or unique symbols.
If you click the Single Symbol dropdown in the Layer Styling panel you'll see there are several other methods of styling. Of these Categorized and Graduated are the most commonly used (after Single Symbol).
Categorized symbols use unique colors, patterns, or shapes to your map features based on qualitative attributes.
Pick the HealthCareFac_UTM from the Layer Styling dropdown.
Change the Single Symbol style type to Categorized.
From the Value dropdown select services.
Click Classify to have QGIS assign a random set of unique colors to each category.
Find the bottom class for 'all other values' and double click in the empty Legend feild.
Enter Various as the new custom category.
If you're not happy with the random colors assigned you can reshuffle them from the Color Ramp drop down. Or you can double click on any single color class and manually set its color and symbol.
Graduated symbols are used to show quantitative differences between mapped features by varying symbol size or color saturation for a single color (light to dark).
Pick the SF_liquefactionfrom the Layer Styling dropdown.
Change the Single Symbol style type to Graduated.
From the Value dropdown select LIQ_rank.
Click the Color Ramp drop down and select Reds.
Click the Mode dropdown and choose Equal Interval with 5 Classes.
If you would like to change the legend for this layer to use real labels rather than numbers double click under Legend and rename each class based on its value range: 0-1=Very Low, 1-2=Low, 2-3=Medium, 3-4=High, 4-5=Very High.
The new graduated symbolgy for our liquifaction layer has one minor porblem, there is a 0 value for all water polygons that's getting lumped into our Very Low category. We can use a Feature Filter to dynamically remove those fetures from the map layer.
Double click the SF_liquefaction layer to open its Properties.
Go to the Source menu and open the Query Builder from the button in the lower right.
In the menu that opens double click the LIQ_rank field to add it to the Expression window.
Single click the != (is not equal to) operator.
In the Values window click All then double click 0.
The Expression window shoudl ook like this: "LIQ_rank" != 0
Click OK to close the Query Builder and and OK again to close apply the Properties window.
The water polygons (including the large ocean polygon) should now all be missing from the SF_liquefaction layer. If you want to bring them back you just need to clear the Feature Filter. The Layers panel will show a small filter icon next to any layer with an active filter.
You can add a variety 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.
Go to Web > QuickMapServices and select the OSM Standard basemap.
Note that basemaps like this require an internet connection to work since they are always being re drawn as you pan and zoom around the map. They can also slow down the QGIS interface so you may want to turn them off when not needed.
Mapping spatial data is one thing, but the real power of a GIS is in its ability to manipulate and analyze your data. There are a number of preinstalled spatial analysis tools in QGIS - and many more you can access through the plugin manager. The most commonly used tools will show up under the Vector or Raster menus but the full set of spatial analysis tools can be accessed through the Processing Toolbox panel.
We're going to run what's commonly referred to as a Spatial Join using the Liquefaction hazard polygons and Health Care Facility points. The question we're asking is, what hazard zone does each HCF fall into. Because the data overlap geographicaly, we can spatially join one layer to the other (Liquefaction hazard to HCF points) to add to each point the attribute information of the polygon it overlaps.
Open the Vector menu and go to Data Management Tools > Join Attributes by Location...
Click the Join to Features dropdown and select the HealthCareFac layer.
Leave the join type set to Intersect.
Click the By comparing to drop down and select SF_liquefaction_hazard layer.
Leave all other values set to default.
Leave the output file type as [create temporay layer].
Click Run.
A new layer will show up in your Layers panel called Joined layer. The small micro chip icon to the right of the layer name is to let you know this is an in-memory only layer, and it will be erased when you close the project. If you right-click on the Joined layer and open the attribut table you should see that all of hte attributes of the liquefaction hazard layer have been appended to the HCF point layer attributes. So each point now shows its own attributes and the attributes of the hazard zone it overlaps.
You can use a temporary layer output anytime you don't need to permanently keep a tool result. You might be iterating between different settings or simply creating a scrtatch layer to be the input to another tool process. You can always make a temporary layer permanent by right-clicking and selecting Export > Save Features As.
Now lets use this information to create a summary table of how many health care facilities there are in each unique hazard zone.
Go to the Processing menu and Open the Toolbox (or click the gear icon in your toolbar).
In the Toolbox Search bar search for the Statistics by categories tool.
Set the Input vector layer to the temporary Joined layer.
Leave Field to calculate statistics empty so we get just a count of HCFs.
Click the browse icon next to the Fields with categories box and select the LIQ attribute.
Click Run.
Right-click the new Statistics by category layer to open the attribute table.
You now have a table detailing the number of health care facilities in each hazard zone and a metric for further analyzing the level of hazard risk to these places.
When its time to export your map (for print or as an image to embed in another document or website) you'll need to switch over to the Print Layout tool.
Print Layouts start with an empty layout document that you then add your map view to (or multiple map views) along with marginalia like Titles, Scales, Legends etc.
A full tutorial on building a sound cartographic style and working with the QGIS Print Layout tool can be found here. For now we can focus on creating a simple map export.
From the main toolbar click 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 window 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 and drag in the art-board to place a new map.
Select the Move item content tool to reposition the map view and scale. You can also directly enter a new scale in the Map 1 Item Properties.
Use the Add Label tool to add a map title and the 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.