Editing Vector Data in GRASS GIS

From CUOSGwiki
Revision as of 14:59, 21 December 2022 by SheaTimmins (talk | contribs)
Jump to navigationJump to search

Introduction

This tutorial will demonstrate how to do a vector analysis using GRASS GIS. By the end, you should be a little more comfortable using the program. Please note that for this tutorial we are using GRASS 8.2, older versions of GRASS may not reconcile with this tutorial. Our goal is to use the 2020 Red Light Camera Violations data from open.ottawa.ca to make a map that displays the safest areas in Ottawa to drive based on the number of traffic violations. If you do not already have GRASS installed on your computer, you can go to this Intro to GRASS workshop page with detailed instructions on how to download it.

Data

First we will need to download our data. You can download the Ottawa Traffic Collision data here. After you proceed to the link, click the download button, and select "shapefile." Once you have downloaded the Traffic Collision data, click here to download the Red Light violations data. Finally, download the Road Centrelines data here.

Getting Started with Grass

Start by launching the GRASS software. You should see three windows, one is a terminal, one is the Map Display, and one is the main interface that includes tabs along the bottom of the window such as "data" and "layer," which we will refer to as the Layer Manager for convenience. You need to add a new "database," which is essentially a folder that you will keep "locations" in. Within the "locations," you will store your mapsets.

By default, you have a database named something similar to "C:\Users\YourUserName\Documents\grassdata."

Once done, go back to the Layer's Interface window in GRASS, and select the "add new location" icon.

GRASS newlocation1.png

Name your location "ottawa_road_safety" and click Next.

Ottawa road safety.png

Select "Select CRS from a list by EPSG or description" and press Next.

Selectingcoordinatesystem.png

Chose NAD27(CGQ77)/UTM zone 19N. This is the ideal projection for the Ottawa area. Select Next, and then Finish.

UTMzone19.png

You should now see a new location in your Layer Manager titled ottawa_road_safety.

Allsetup.png

Before we upload our data in GRASS, open your filefolder on your computer and make sure that the data you downloaded from open.ottawa.ca is in the correct folder location (i.e. C:\Users\YourUserName\Documents\grassdata\ottawa_road_safety\PERMANENT.)

Next, navigate back to the Layers Manager window in GRASS. Ensure that you are working in the correct location by right-clicking ottawa_roads_safety and selecting "switch mapsets." Next Select the icon shaped like a "V" to import vector data.

ImportV.png

Select browse, and navigate to where you stored your downloaded data. Select the "Traffic_Collision_by_Location_2019.shp" file and select "Import."

Importingshape1.png

Select "Import and reproject" when prompted.

Reproject1.png

You should now see a display similar to the one below on your Map Display window.

Mapdisplay1.png

Repeat these same steps to import the Red Light Violations data; select the icon shaped like a "V." This time, after you select browse, and navigate to where you stored your downloaded data, select the "Red_Light_Camera_Violations_2019.shp" file and select "Import." Next, repeat this for the Road Centrelines data. At the end you should have two layers in your Layers tab.

Layerstab1.png

Editing the Map Display

First, make sure the layers are in the correct order. Roads_Centrelines.shp should be the bottom layer. If this is not the case, simply click and drag that layer to the beneath the other two. We are then going to edit our Map Display so that it displays the intersections and areas in Ottawa with a significant number of red light traffic violations and traffic violations in one year.

Displaying Layers Based on Attribute Data

The first thing we will edit in our Map display is the Red_Light_Camera_Violations_2019.shp data. We are going to display only the intersections that have 700 or more traffic violations in the year of 2019. Right-click on Red_Light_Camera_Violations_2019.shp and select "Properties."



Redlight1.png

Select the "Selection" tab. Then, underneath where it says (where=sql_query), select the blue and white rectangle/square icon.

Sql redlight.png

Next, double click the TOTAL_VIOL column. Then select the >= sign, and type 500. Your final query should look like the one below. Press "Apply."

Grassslqred.png

Press "Apply" again. Then close the d.vect window.

Montgomery.png

If you uncheck the boxes for each layer except for the Red_Light_Camera_Violations_2019 layer, your map display should look like the one below. We have successfully displayed only the intersections with 500 or more violations in the year 2019.

Stage1.png

Now we will repeat these steps with the Traffic_Collision_by_Location_2019 layer. Right-click on this layer, and select "Properties." Next, select the "Selection" tab. Select the same square icon again underneath (where=sql_query). This time, double-click the Total_Coll column. Then select the >= button, and type 10. Select "Apply." Select "Apply" again then close the d.vect window. We have now set the Map Display to only display areas with 10 collisions or more in the year 2019.

Collisions10.png

Editing Symbols

We will start by editing the Traffic_Collision_by_Location_2019 symbols on our Map Display. By default, they are the same color as the other layers, making the information very difficult to discern. We will start by changing the color of the symbol. Right-click on the Traffic_Collision_by_Location_2019 layer, and select “Properties.” Then select the “Colors” tab. It should look like the photo below.

Colorz.png

Click on the “Feature color.” Then select a new color, in the example below a bright green was selected. Click “OK” and then “Apply.” There is an example of what your Map Display should look like below.

Colorzz.png

Mapz.png

Now we will repeat these steps with the Red_Light_Camera_Violations_2019 layer. Right-click on this layer, and select “Properties.” Navigate to the “Colors” tab, and select a red color. Click “OK” and then “Apply.” Now your Map Display should look like the one below.

Displayz.png

Our data is concentrated in the downtown area of Ottawa, so we are going to zoom in this area to make our Display more readable. Select the magnifying glass at the top of your screen that has the plus sign. Then click the center of the most concentrated area of your map. The result on your map display should be similar to the one below.

Yeehawz.png

Next we are going to edit the symbol size and shape. Right-click on the Traffic_Collision_by_Location_2019 layer. Select “Properties,” then select the “Symbols” tab. Click on the “X” to change the shape of the symbol. Select the circle as the new symbol. Next change the symbol size to 6. Your “Symbols tab should look like the photo below.

Coloredit.png

Before you press “Apply” and close this window, navigate back to the “Colors” tab and change the “Area fill color” to yellow. Then press apply. The Map Display should now look like the one below.

Symbolstuff.png

Now we will do the same thing for the Red_Light_Camera_Violations_2019 layer. Right-click on this layer, and select “Properties.” Then, go to the “Symbols” tab and change the symbol from “X” to a circle, and the size from 5 to 6. Before you press “Apply,” navigate to the “Colors” tab and select the color red for the “Area fill color.” You Map Display should now look like the one below.

Peachtea.png