8 Import Data into QGIS

Let’s load some data.

8.1 Raster Data

Let’s start by loading the raster data:

  1. Click on the Open Data Source Manager button on your toolbar. It looks like three cards (one red, one yellow, and one blue) fanned out. Or, find it on the Layer menu.
  2. Click the Raster button (it looks like a checker board) on the left side of the Data Source Manager window.
  3. Click on the “…” button in the Source section in the middle of the window. Navigate to where you saved your workshop data and select the DEM_SF.tif file.
  4. Click Open.
  5. Some options will appear on the page. We can leave the defaults for this dataset.
  6. Finally, click “Add” and you should see a black and white raster image appear in the map canvas below the dialog you’re working in. If the Select Transformation dialog pops up, select a transformation you feel fits the data well. I’d recommend NAD83 to WGS 84 (43) because the table of options says this one has a high accuracy and is intended for California north of 36.5 degrees north, which fits our data.

You can leave the Data Source Manager window open so we can add some more data.

8.2 Vector

8.2.1 Shapefiles

Shapefiles are a very popular vector data format, so that’s what we’ll work with today, but geopackage is a good open format alternative (and has the advantage of being just one file). Let’s load our shapefile data:

  1. In the Data Source Manager, click on the Vector tab on the left.
  2. In the Source section, click on the “…” and navigate to the folder containing your vector data.
  3. Holding down the Ctrl (Windows) or Command (Mac) button on your keyboard while you click, select the StreetCenterlines.shp, SeismicHazardZones.shp, and Shoreline.shp (don’t worry about the other files that make up a shapefile - QGIS will know to look for these when you specify the .shp file). Then click Open.
  4. In the Options section, you can leave the default values as they are for this data. Make note of what options are there - the ENCODING section is particularly helpful if your attributes are written in a different character set than the default, UTF-8.
  5. In the Data Source Manager click Add. If the Select Transformation dialog appears, pick a transformation that fits the data, such as NAD83 to WGS 84 (43). If if the Select Transformation dialog doesn’t appear, it means the projection of your dataset matched the projection of the project so you don’t need a transformation.

8.2.2 CSV Data

It’s pretty common to get point data in “CSV” file, especially if the spatial data is represented by latitude and longitude coordinates. CSV stands for Comma Separated Value. Typically this is tabular data where the edge of each cell of the table is indicated by a comma. Sometimes people use a different character instead of the comma such as a semicolon, tab, or pipe. The character used to indicate the edge of the cells is called the “delimiter”. If a file has tabs as the delimeter, for example, you would call that file a “tab delimited” file.

To load our .csv file:

  1. In the Data Source Manager, click on the Delimited Text tab on the left. Notice that the icon is a comma.
  2. Next to the File Name text box, click the “…” button, then navigate to your Street_Tree_Map.csv file and click Open.
  3. In the File format section, we’ll leave the default selection of CSV (comma separated values), but if you had a file with a different delimiter, you could change the delimiter by using Custom delimiters.
  4. In the Records and Fields Options section, make sure First record has field names is checked. If your data didn’t have table headings, you would want to uncheck this box. You can also check Detect field types.
  5. In the Geometry definition section is where we indicate what kind of geometry we have. For ours, select Point coordinates and in the X field, pick “Longitude”, and for the Y field pick “Latitude”.
  6. For the Geometry CRS, click on the Select CRS button (it looks like a little globe wearing a cone-shaped hat). In the Filter, type 4326 to find and select WGS 84, then click OK.
  7. Review the Sample data section to preview how the attribute table will look. This is a good way to find out if you picked the right delimiter or if your data has some formatting issues (such as someone put commas in a text field and use commas as the delimiter).
  8. If everything looks good, click Add. This is a reasonably large file, so be patient as it loads.
  9. Close the Data Source Manager window because we are done adding data.