Difference between revisions of "Editing Vector Data in GRASS GIS"
| Line 37: | Line 37: | ||
This step is important because some downloaded shapefiles may have filenames that do not meet GRASS vector map naming requirements. |
This step is important because some downloaded shapefiles may have filenames that do not meet GRASS vector map naming requirements. |
||
[[File:GRASS Red Light Output Name.png|500px|thumb| |
[[File:GRASS Red Light Output Name.png|500px|thumb|center|Setting a valid output vector map name before importing the Red Light Camera Violations dataset.]] |
||
Run it. Repeat this import process for '''Traffic_Collision_by_Location_2019''' if it is not already present in the Project. |
Run it. Repeat this import process for '''Traffic_Collision_by_Location_2019''' if it is not already present in the Project. |
||
| Line 47: | Line 47: | ||
* '''Traffic_Collision_by_Location_2019''' |
* '''Traffic_Collision_by_Location_2019''' |
||
[[File:GRASS Three Vector Layers.png|500px|thumb| |
[[File:GRASS Three Vector Layers.png|500px|thumb|center|The three Ottawa vector datasets loaded into the GRASS GIS Project.]] |
||
== Filtering and Displaying the Vector Data == |
== Filtering and Displaying the Vector Data == |
||
| Line 61: | Line 61: | ||
Open the SQL builder, beside the SQL WHERE condition. Click '''TOTAL_VIOL''', then select the '''>=''' operator, and enter '''500'''. |
Open the SQL builder, beside the SQL WHERE condition. Click '''TOTAL_VIOL''', then select the '''>=''' operator, and enter '''500'''. |
||
[[File:GRASS Red Light Selection Tab.png|500px|thumb| |
[[File:GRASS Red Light Selection Tab.png|500px|thumb|center|The Selection tab provides access to the SQL Builder for filtering vector features.]] |
||
It should look like this " "TOTAL_VIOL" >= 500 " |
It should look like this " "TOTAL_VIOL" >= 500 " |
||
[[File:GRASS Red Light 500 Filter.png|500px|thumb| |
[[File:GRASS Red Light 500 Filter.png|500px|thumb|center|SQL query used to display Red Light Camera locations with 500 or more violations.]] |
||
Apply the changes in SQL then apply it in the layer properties. The Red Light Camera will now only display locations with 500 or more violations in 2019. |
Apply the changes in SQL then apply it in the layer properties. The Red Light Camera will now only display locations with 500 or more violations in 2019. |
||
| Line 73: | Line 73: | ||
This exact process will be repeated for the '''Traffic_Collision_by_Location_2019''' layer. In the SQL Builder, you will select '''Total_Coll''' and >= 10 . |
This exact process will be repeated for the '''Traffic_Collision_by_Location_2019''' layer. In the SQL Builder, you will select '''Total_Coll''' and >= 10 . |
||
[[File:GRASS Traffic Collision 10 Filter.png|500px|thumb| |
[[File:GRASS Traffic Collision 10 Filter.png|500px|thumb|center|SQL query used to display locations with 10 or more traffic collisions.]] |
||
Apply it and the layer will now display only locations with 10 or more collisions. |
Apply it and the layer will now display only locations with 10 or more collisions. |
||
| Line 81: | Line 81: | ||
The two point layers can be very hard to distinguish when they are the same similar symbols. we will now change the colors, shapes and sizes to make them easier to interpret. |
The two point layers can be very hard to distinguish when they are the same similar symbols. we will now change the colors, shapes and sizes to make them easier to interpret. |
||
[[File:GRASS Traffic Collision Symbol.png|500px|thumb| |
[[File:GRASS Traffic Collision Symbol.png|500px|thumb|center|Changing the Traffic Collision point symbol to a circle with a size of 6.]] |
||
==== Traffic Collision Symbology ==== |
==== Traffic Collision Symbology ==== |
||
| Line 91: | Line 91: | ||
Go to the '''Colors''' tab and change the '''Area fill color''' to yellow. Click '''Apply''' to update the map display. |
Go to the '''Colors''' tab and change the '''Area fill color''' to yellow. Click '''Apply''' to update the map display. |
||
[[File:GRASS Traffic Collision Colors.png|500px|thumb| |
[[File:GRASS Traffic Collision Colors.png|500px|thumb|center|Changing the Traffic Collision feature color to green and the area fill color to yellow.]] |
||
==== Red Light Camera Symbology ==== |
==== Red Light Camera Symbology ==== |
||
| Line 101: | Line 101: | ||
You can use the Zoom In tool to focus on somewhere in Ottawa, where many of the displayed locations are concentrated. |
You can use the Zoom In tool to focus on somewhere in Ottawa, where many of the displayed locations are concentrated. |
||
[[File:GRASS Red Light Camera Color.png|700px|thumb| |
[[File:GRASS Red Light Camera Color.png|700px|thumb|center|Changing the Red Light Camera Violations feature color to red.]] |
||
== Editing Vector Features == |
== Editing Vector Features == |
||
| Line 112: | Line 112: | ||
[[File:GRASS Vector Digitizer Roads.png|700px|thumb| |
[[File:GRASS Vector Digitizer Roads.png|700px|thumb|center|The Road Centrelines layer opened in the GRASS GIS Vector Digitizer.]] |
||
=== Moving a Vertex === |
=== Moving a Vertex === |
||
| Line 118: | Line 118: | ||
Select the '''Move vertex''' tool from the Vector Digitizer toolbar. Click a vertex on a road feature, move it to a new position, and click again to place it. |
Select the '''Move vertex''' tool from the Vector Digitizer toolbar. Click a vertex on a road feature, move it to a new position, and click again to place it. |
||
[[File:GRASS Move Vertex Tool.png|700px|thumb| |
[[File:GRASS Move Vertex Tool.png|700px|thumb|center|Road Centrelines displayed in the Vector Digitizer while using the Move vertex tool.]] |
||
If you are only trying the tools out, use '''Undo''' after moving the vertex to return the road feature to its original geometry. |
If you are only trying the tools out, use '''Undo''' after moving the vertex to return the road feature to its original geometry. |
||
| Line 128: | Line 128: | ||
An attribute window will open and display the fields associated with the selected feature. |
An attribute window will open and display the fields associated with the selected feature. |
||
[[File:GRASS Update Vector Attributes.png|600px|thumb| |
[[File:GRASS Update Vector Attributes.png|600px|thumb|center|Viewing the attributes of a selected road feature using the Vector Digitizer.]] |
||
Attribute values should only be changed when there's a valid reason to modify the data. For this tutorial, viewing the attributes is sufficient to demonstrate the tool. |
Attribute values should only be changed when there's a valid reason to modify the data. For this tutorial, viewing the attributes is sufficient to demonstrate the tool. |
||
Revision as of 18:26, 6 October 2026
Contents
Introduction
This tutorial will introduce basic GRASS GIS tools for working with vector data and editing aswell. This will include the use of three open datasets from the open source site of the City of Ottawa: Traffic Collisions, Red Light Camera Violations and Road Centrelines. The tutorial on this page will cover the creation of a GRASS project, importing the vector data, selecting specific features using attribute conditions, changing vector symbology and the use of basic vector editing tools.
If you currently DO NOT have GRASS GIS installed, this is the link to download it, including installation instructions. [1]
Data
There will be three main Vector datasets used in this tutorial, all from the City of Ottawa:
- Traffic Collision by Location (2019): [2]
- Red Light Camera Violations (2019): [3]
- Road Centrelines: [4]
Download each of the linked datasets as SHAPEFILES and extract the files to start. The 2019 datasets are retained, this is for the purpose of this tutorial, in order to demonstrate vector data operations rather than analyze present traffic conditions
Creating a GRASS Project
GRASS GIS specializes in organizing spatial data by using projects and mapsets. For this tutorial, we will create a new Project for the Ottawa vector datasets.
From the GRASS startup interface, select "Create a new GRASS project". Enter a descriptive project name like Ottawa_Vector_Editing.
On the following screen, you will be prompted to enter and select a Coordinate Reference system (CRS), choose Read CRS from a georeferenced data file. Click on the downloaded SHP file Road_Centrelines.shp and continue through creating the project. Using the supplied georeferenced dataset will allow GRASS to establish the Project CRS directly from the data and helps avoid a CRS mismatch during import.
Once the Project has been created, ensure that its PERMANENT Mapset is active before importing the remaining vector datasets.
Importing the Vector Data
From the GRASS menu, select File → Import vector data → Import of common vector formats [v.in.ogr].
Find the downloaded Red Light Camera Violations SHP file and select it as the input . Before running the import, open the Output tab and enter a simple output vector map name such as:
Red_Light_Camera_Violations_2019
This step is important because some downloaded shapefiles may have filenames that do not meet GRASS vector map naming requirements.
Run it. Repeat this import process for Traffic_Collision_by_Location_2019 if it is not already present in the Project.
After you've imported the datasets, the data and layers panel should contain the following three vector layers:
- Road_Centrelines
- Red_Light_Camera_Violations_2019
- Traffic_Collision_by_Location_2019
Filtering and Displaying the Vector Data
After you've imported, place the Road_Centrelines layer beneath the points layers (two) in the layers panel. This will keep traffic collision and red light camera locations visibile above the road network.
In the following steps, we will use attribute conditions in order to display the locations with higher numbers of violations or collisions.
Filtering Red Light Camera Violations
Right-click the Red_Light_Camera_Violations_2019 in the layers panel on the left and select properties. You will then open the Selection tab.
Open the SQL builder, beside the SQL WHERE condition. Click TOTAL_VIOL, then select the >= operator, and enter 500.
It should look like this " "TOTAL_VIOL" >= 500 "
Apply the changes in SQL then apply it in the layer properties. The Red Light Camera will now only display locations with 500 or more violations in 2019.
Filtering Traffic Collisions
This exact process will be repeated for the Traffic_Collision_by_Location_2019 layer. In the SQL Builder, you will select Total_Coll and >= 10 .
Apply it and the layer will now display only locations with 10 or more collisions.
Improving Layer Symbology
The two point layers can be very hard to distinguish when they are the same similar symbols. we will now change the colors, shapes and sizes to make them easier to interpret.
Traffic Collision Symbology
Right-click Traffic_Collision_by_Location_2019 and select Properties.
Open the Colors tab and change the Feature color to a green preset. Next, open the Symbols tab, change the point symbol to basic/circle, and set the Symbol size to 6.
Go to the Colors tab and change the Area fill color to yellow. Click Apply to update the map display.
Red Light Camera Symbology
Right-click Red_Light_Camera_Violations_2019 and select the Properties.
Open the Colors tab and change the Feature color to red. You will then open the Symbols tab and increase the symbol size so that the filtered red light camera locations are clearly visible on the map.
You can use the Zoom In tool to focus on somewhere in Ottawa, where many of the displayed locations are concentrated.
Editing Vector Features
On top of changing how the vector data is displayed, GRASS GIS can be used to edit the vector features themselves. The Vector Digitizer provides tools for modifying vector geometry and attributes.
Starting the Vector Digitizer
In the Layers panel, right-click the Road_Centrelines layer and select Start editing. GRASS will then activate the Vector Digitizer toolbar and display the editable vertices of the selected vector layer.
Moving a Vertex
Select the Move vertex tool from the Vector Digitizer toolbar. Click a vertex on a road feature, move it to a new position, and click again to place it.
If you are only trying the tools out, use Undo after moving the vertex to return the road feature to its original geometry.
Viewing and Updating Attributes
The Vector Digitizer can also be used to view and modify attribute information linked with a feature. Select the Display/update attributes tool and click a road feature on the map.
An attribute window will open and display the fields associated with the selected feature.
Attribute values should only be changed when there's a valid reason to modify the data. For this tutorial, viewing the attributes is sufficient to demonstrate the tool.
When finished, exit the Vector Digitizer to stop editing the Road Centrelines layer.
Conclusion
This tutorial has introduced multiple tools that help learning and working with vector data in GRASS GIS. The work that was displayed for the GRASS project included using coordinate reference system for an existing georeferenced dataset, importing vector SHP, filtering the features by using attribute conditions tool and improving the layer symbology.
This tutorial also introduces the Vector Digitizer for editing vector geometry and also viewing feature attributes. A foundation for working with vector data sets in GRASS GIS using the tools and application of spatial data and GIS projections.