Pipeline Routing

SAIT - GEOS 456 - GIS Programming

Final Project - December 14, 2022

Problem: Using python, develop a script that will determine the optimal pipeline route between a well and a facility with the following criteria and weights, within a specific area:

Rivers - 40% Within 50m of a river - Least desirable - Value = 3. 50m - 250m of a river - Moderately desirable - Value = 2. Greater than 250m from a river - Most desirable Value = 1.

Roads - 15% Within 30m of a road - Most desirable - Value = 1 30m-350m from a road - Moderately desirable - Value = 2 Greater than 250m from a road - Least desirable - Value = 3

Slope - 15% A slope of less than 4 degrees - Most desirable - Value = 1 A slope of 4-10 degrees - Moderately desirable - Value = 2 A slope greater than 10 degrees - Least desirable - Value = 3

Land cover - 30% Cropland - Least desirable - Value = 3 Forage - Most desirable - Value = 1 Grassland - Most desirable - Value = 1 Shrubs - Most desirable - Value = 1 Trees - Moderately desirable - Value = 2 Water - Least desirable- Value = 3

Available Data

The project vector data extends beyond the park boundary.

Boundary Rivers Roads Wells Facilities

The project folder also contained two DEMs giving us full coverage over the park boundary.

Finally, a landcover raster was provided.

Basic Process

DEM

- Merge DEM into a single DEM. - Use DEM to create a slope raster. - Reclass slope based on project requirements.

The two DEMs are merged into a single file and cropped to the Cypress Hill boundary.

Since the path may not leave the park, all the data is clipped to this extent.

From the merged DEM a slope raster is computed...

And then using the defined values for each slope class, the slope raster is reclassified.

Distance From Roads & Rivers

Taking the roads vector layer, the Euclidean Distance tool is used to create a raster of distances away from the roads.

The roads were then reclassified and clipped to the park boundary.

It was important to clip the raster to the boundary rather than the vector layer to ensure a raster was generated over the entire park.

The same steps were completed for the rivers dataset.

Comparing the reclassified rivers to the roads we can see it is desirable to be away from rivers, but towards roads.

Distance From Roads & Rivers

As the landcover was already clipped, it was simply reclassified based on the project requirements, you can compare the original with the reclassified map below.

Land cover compared to its reclassification.

The Cost Surface

Having created the following reclassified maps: Slope, Rivers, Roads, Landcover is is possible to combine them with the project weights and create a final cost surface.

Merging the four reclassified rasters into the final cost surface using the weighted overlay tool.

Isolate the Wells and Facilities

Isolating the wells & facilities with the definition query.

Compare the complete wells and facilities datasets with the new layers containing only the single well and facility of interest.

Comparing the full well & facility inventory with the two of interest.

Cost distance and Backlink Rasters

With a cost surface created and a start and end point determined, the Cost Distance tool to is used to create the final cost raster as well as a backlink raster. These will ultimately allow a final path to be created for the pipeline.

The backlink raster is comprised of values that allow ArcGIS Pro to plot a line from one place to the next. For example if the value of the cell the well is in specifies left, the value of the cell left of it is examined and the next direction is determined.

An example of how the backlink raster is used to determine the best path.

Below is a comparison of the cost distance raster and the back link raster created from the start, stop points and the cost surface.

Plotting the Pipeline

The final steps of the process is to use the backlink raster and the start and end points to plot the course of the pipeline and the convert it to a polyline.

The original route as a raster compared against a final version of the pipeline map.

Automation of the Process

The goal of the project was to convert this process from a collection of manual steps to a Python script that leveraged ArcPy to complete the same task.

Authoring workflows like this within either Python or models can be an essential aspect of a workflow for several reasons:

  1. Easier to see how the entire process works.
  2. Easier to rerun in the case of an error.
  3. Easier to troubleshoot the entire process.
  4. Can be leveraged to solve similar problems.
  5. The model creating the routing can be modified if necessary due to changing parameters.

The maps below show the original map on the left created to determine the workflow and the map created with the script on the right. There are two major differences.

  1. The first difference is the well being shifted north/south. This is actually not a difference, but simply a bad symbology choice of a red pin marker feeding into the same thickness and essentially same color of line marker used for the pipeline.
  2. The second difference is next to the facility. The algorithm during the initial workflows followed the roads along Elkwater lake in preference to the water body, while in the script the water body took precedence.

The initial optimal path compared to the workflow map.

Why is the pathing different? Was there a mistake in how the original data was processed when creating the workflow? Is there another reason?

  1. With the Python script it was easy to go back through and determine all the weightings were correct and run the script multiple times to determine if there was an error.
  2. With the original workflow data, if the working project was saved it might be useful in troubleshooting the problem. If it was not saved, or if some of the intermediate data was not saved, troubleshooting the issue would prove difficult.

In this case the workflow project had been saved and it was determined the difference between the two was the raster resolution. In the manual workflow the chosen resolution of the distance rasters was 25m to match the resolution of the landcover raster, giving a much finer final cost surface.

For the script the defaults were used, resulting in a much coarser raster. Because the rasters and final path was generated with a script it was trivial to modify the code, and re-run the process to generate a new version of the path and final map.

Changing the code to utilize a 25m resolution is trivial.

Now the script generated map much more closely matches the manual workflow map, but you will notice a few differences still. As these maps are created, the pathing is sensitive to the resolution and alignment of the underlying raster grid.

The modified optimal path using a 25m resolution.

This is another strength of using a script, each time you run it, it will generate the same output. The grids will always have the specified size, and the same alignments. The possibility of human error will be drastically reduced, and when it is found it will be easier to fix.

The Code

I considered publishing the code here, but in the end chose to not include it. This was a final project for GEOS 456 at SAIT and I felt including it might give away too much of the solution if someone was to come across it researching the question.

For those interested you can contact me directly.

The image below is the console output from the script showing the main processing steps and their outputs.

Console output from the script as it creates the optimal path.

References

  • ESRI. (n.d.-a). ArcGIS Pro Python Reference. ArcGIS Pro. https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/symbol-class.htm
  • ESRI. (n.d.-b). ArcGIS Pro Tool Reference.
  • ArcGIS Pro. https://pro.arcgis.com/en/pro-app/latest/tool-reference/main/arcgis-pro-tool-reference.htmJay Reid (Director). (n.d.-a).
  • Least Cost Path [Mp4]. SAIT. https://learn.sait.ca/content/enforced/534799-202220GEOS-456-O2A/videos/GEOS456_LeastCostPath.mp4?_&d2lSessionVal=Pj2ytcqGTXNiRbhOFHsFKGXDd&ou=534799JoeBorgione. (2018, December 13). If Feature class is empty append.
  • ESRI Community. https://community.esri.com/t5/python-questions/if-feature-class-is-empty-append/td-p/340503Paul A. Zandbergen. (2020).
  • Python Scripting for ArcGIS Pro. Esri Press.Python. (n.d.). [Python].
  • The Python Standard Library. Python.org

Comparing the full well & facility inventory with the two of interest.

An example of how the backlink raster is used to determine the best path.

The original route as a raster compared against a final version of the pipeline map.

The initial optimal path compared to the workflow map.

Changing the code to utilize a 25m resolution is trivial.

The modified optimal path using a 25m resolution.

Console output from the script as it creates the optimal path.

Land cover compared to its reclassification.

Merging the four reclassified rasters into the final cost surface using the weighted overlay tool.

Isolating the wells & facilities with the definition query.