-
Notifications
You must be signed in to change notification settings - Fork 35
/
07_Import-data-into-QGIS.Rmd
39 lines (31 loc) · 4.5 KB
/
07_Import-data-into-QGIS.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Import Data into QGIS
Let's load some data.
## 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.
1. Click the *Raster* button (it looks like a checker board) on the left side of the *Data Source Manager* window.
1. 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.
3. Click *Open*.
4. Some options will appear on the page. We can leave the defaults for this dataset.
5. 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.
## Vector
### 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.
1. In the *Source* section, click on the "..." and navigate to the folder containing your vector data.
1. 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*.
1. 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.
1. 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.
### 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.
1. Next to the *File Name* text box, click the "..." button, then navigate to your *Street_Tree_Map.csv* file and click *Open*.
1. 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*.
1. 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*.
1. 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".
1. 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*.
1. 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).
1. If everything looks good, click *Add*. This is a reasonably large file, so be patient as it loads.
1. Close the *Data Source Manager* window because we are done adding data.