Difference between revisions of "Editing Vector Data in GRASS GIS"

From CUOSGwiki
Jump to navigationJump to search
 
Line 3: Line 3:
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.
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. [https://dges.carleton.ca/CUOSGwiki/index.php/Intro_to_GRASS_workshop]
If you currently DO NOT have GRASS GIS installed, this is the link to download it, including installation instructions. [https://dges.carleton.ca/CUOSGwiki/index.php/Intro_to_GRASS_workshop Intro to GRASS workshop]


== Data ==
== Data ==

Latest revision as of 18:30, 6 October 2026

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. Intro to GRASS workshop

Data

There will be three main Vector datasets used in this tutorial, all from the City of Ottawa:

  • Traffic Collision by Location (2019): [1]
  • Red Light Camera Violations (2019): [2]
  • Road Centrelines: [3]

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.

Selecting the option to read the project CRS from a georeferenced data file.

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.

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.

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
The three Ottawa vector datasets loaded into the GRASS GIS Project.

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.

The Selection tab provides access to the SQL Builder for filtering vector features.

It should look like this " "TOTAL_VIOL" >= 500 "

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.

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 .

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.

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.

Changing the Traffic Collision point symbol to a circle with a size of 6.

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.

Changing the Traffic Collision feature color to green and the area fill color to yellow.

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.

Changing the Red Light Camera Violations feature color to red.

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.


The Road Centrelines layer opened in the GRASS GIS Vector Digitizer.

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.

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.

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.

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.

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.