11  QGIS Basics

Before any sort of analysis and visualization can take place, you must be extremely comfortable with creating projects, opening files, working with attributes, loading basemaps, and basic symbolization. Think of this chapter as your hands-on introduction to the essential building blocks of working with spatial data in QGIS. The sample data used in this chapter can be found here. Download the folder, unzip it, and add the contents to your GEOG370/lab/lab_1/raw_data folder. The data we will use is:

11.1 Explore the Datasets

Start by looking in the data folder and answering the following questions:

  • How many files are there?
  • Which file likely corresponds with each of the datasets above?
  • What is the file format of each of the datasets? Is it a spatial data type or a non-spatial data type?
  • Can you open the file outside of QGIS? What does the file look like?

11.2 Start a Project

Every time you begin a new lab or analysis, you’ll create a new QGIS project file.

This .qgz file stores the structure of your work: which layers you loaded, how you symbolized them, and what your map looked like when you last saved it. It’s like a snapshot of your workspace. QGIS projects do not store the data itself—they store file paths. If you move, rename, or delete your data after you’ve added it to a project, QGIS won’t be able to find it anymore. Always keep your data organized in a consistent folder structure.

11.3 Add a Basemap

Once you’ve created a project, you typically want to add a basemap. A basemap is a foundational map that provides geographic context for other data. It is often a satellite image, topographic map, or streetmap.

We will use the QuickMapServices plug-in for our basemaps. I highly suggest using the OSM “VersaTiles” basemaps because they are optimized for printing. You can use the “Map Navigation Toolbar” to zoom in, out, or pan on your basemap.

11.4 Add Raster or Vector Data

Now that you have your project set up, you are ready to add some vector and raster data.

You will add two datasets: a raster representing elevation in Orange County, and a vector representing census block groups across North Carolina.

There are multiple ways to add data, but the simplest way is to use the Browser panel. If you are missing your panels, watch this video.

11.5 Working with Attributes

11.5.1 Explore the Data Properties

When you read in vector data (which is our census block groups), one of the first things you should do is explore the properties of the data, including looking at the data type of each of the fields, exploring the attribute table, and looking at summaries of important fields

For raster data you will want to look at the properties and look at a summary of the raster.

11.5.2 Add a Field to Vector Data

We often want to manipulate vector attribute data to create new attributes. In this case, we will calculate population density based on two existing fields- one representing population and one representing area (in square meters). We will use the formula: pop_density = total_population / (area/2589988) to calculate the number of people per square mile.

After you add a field, you must save the layer.

11.5.3 Selecting Features Based on Attributes

We often want to isolate a subset of features based on an attribute. We can select features from an attribute and save those as a new layer.

We will isolate only census block groups with a population density over 100 people/ square mile.

11.5.4 Manually Selecting Features

We can also manually select features using the attribute table.

11.6 Basic Symbolization

Chances are, the symbolization that is automatically applied when you add your data into QGIS is not going to be sufficient. Symbology choices are some of the most important choices that you will make when creating maps. There are many symbology choices available in QGIS. You should symbolize your elevation and census data. Here are the basics of changing vector and raster symbology

Explore these resources for more information:

11.7 Adding Tabular Data

Sometimes geospatial data comes in a tabular format. This means that the file is not already in a spatial format (usually it is a .csv), but you can add it into QGIS in a spatial format by pointing QGIS to the fields in the data that represent latitude and longitude and providing QGIS with the correct CRS of the data (this would be found in the metadata. In this case, I provide you with the correct CRS, which is EPSG:4326).

Using a CRS that does not match the latitude/longitude values means that your data will not be in the correct location. You can easily add tabular data that has a lat, lon fields by using the Data Source Manager. For this project, you will add in tabular data representing the maximum temperature at North Carolina ASOS stations (weather stations) during a June 2024 heatwave.

11.8 Executing Table Joins

Finally, table joins are an absolutely essential pre-processing step for many spatial analyses. A table join involves joining tabular data and spatial data based on a matching key. For instance, you might have data about geographical locations (for instance, census block groups) but the data doesn’t actually have the geometry information.

In this case, you could match census data to the census block group boundary file using a shared key (GEOID). For this to work in QGIS, it is required that the matching keys are exactly the same (which is often a problem) and are set as the same data type in QGIS.

For this project, you will add census block group data that represents median income and join this to your census block group boundary file. When you add tabular data, you MUST use the Data Source Manager.

12 Cartography Basics

A map is the most common output of a spatial analysis. A map should be designed to deliver only the information needed in as simple a manner as possible. While this isn’t a cartography class, there is a basic expectation that your maps will follow basic design principles and contain the required map components.

We will practice cartography basics by creating a well-designed map of high population density census block groups in the Triangle region of North Carolina

12.1 Basic Design Principles

  • Features must use an appropriate visual variable.
    • If you are displaying quantitative data you should use value or size. If you are displaying categorical data you should use hue or shape.
  • Features must use an appropriate classification scheme and an appropriate number of classes (usually between 4-7)
  • Color ramps should be appropriate
    • Use a single-color (sequential) ramp for values that go from low to high (e.g., population density).
    • Use a diverging ramp only when the data have a meaningful middle value (e.g., above and below zero).
    • Use different hues to represent different categories (e.g., land cover types).
    • Avoid colors that imply unintended meaning (e.g., red = danger).
  • If you use a basemap, important basemap features MUST be visible under the features
    • Basemaps are not required. Only include a basemap if it provides useful geographic context or helps readers interpret the map.

    • Choose a basemap that supports the map’s purpose. For example, use a street basemap to show roads and place names, or a satellite basemap when land cover or imagery is important.

    • If you are displaying areal data and using a VersaTiles basemap only the labels will appear over the features. If the labels aren’t sufficient, add transparency to your features

  • The map must be appropriately zoomed and centered on the features
  • There should be a small amount of white space on the edges of the map, and the map should have a frameline
  • Additional map components (title, legend,etc.) should be appropriately sized
    • Additional map components should never take attention away from the map features
  • Include only the map elements that are needed

12.2 Required Components

  • Map
  • Title
  • Metadata (should include data source, CRS of the map, and author information)
  • Legend
    • Legend items MUST be renamed if the legend name isn’t clear
    • You should not include any features in the legend that are not on the map
  • Frameline

13 Making Our First Map!