What regions intersect pipelines?

We can answer this with a spatial query. In QGIS, this tool is called Select by Location; search for this term in the Processing Toolbox, then double-click on the tool to open the dialog box. We want to use this tool to select all of the features from the regions layer that intersect with pipelines. The input will look like this:

Select by Location tool

The output in QGIS will look like this:

Selected regions highlighted

Open the attribute table by right-clicking on the layer and choosing Open Attribute Table. You will see the selected regions in the table. It is possible to expand on this query and create a field in the regions layer that notes whether the pipeline intersected the region or not. To do this, we can use the field calculator.

Let's add a field called Pipeline and assign the value one if the pipeline runs through the region and zero if it doesn't. In the attribute table, click on the open field calculator button (the icon is an abacus). Fill in the Field Calculator as follows. Make sure the checkbox next to Only update 5 selected features is selected:

The field calculator

Click on OK and then open the attribute table; you will see a new field called Pipeline. This is shown as follows:

Attribute table with selected feature(s)

We need to add the value zero now to all of the other fields. Invert the selection (the button looks like a yellow triangle underneath a grey triangle). Choose the Pipeline field from the drop-down menu and set the value equal to 0. Click on Update Selected. The value to change is shown in the following screenshot:

Update existing field in the field calculator

Click on OK. Now, the Pipeline field has either zero (not impacted) or one (impacted). Clear the selection and untoggle the editing. We could use the styling skills from Chapter 4Styling Data, to symbolize the region layer based on the newly created Pipeline field.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset