8 Import Data into QGIS
Let’s load some data.
8.1 Raster Data
Let’s start by loading the raster data:
- 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.
- Click the Raster button (it looks like a checker board) on the left side of the Data Source Manager window.
- 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.
- Click Open.
- Some options will appear on the page. We can leave the defaults for this dataset.
- 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:
- In the Data Source Manager, click on the Vector tab on the left.
- In the Source section, click on the “…” and navigate to the folder containing your vector data.
- 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.
- 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.
- 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:
- In the Data Source Manager, click on the Delimited Text tab on the left. Notice that the icon is a comma.
- Next to the File Name text box, click the “…” button, then navigate to your Street_Tree_Map.csv file and click Open.
- 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.
- 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.
- 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”.
- 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.
- 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).
- If everything looks good, click Add. This is a reasonably large file, so be patient as it loads.
- Close the Data Source Manager window because we are done adding data.