# Find features around a pipeline for every 1 Km segment, within a buffer

1026
16
05-19-2014 08:43 PM
New Contributor
I need to perform following operations.

1. Draw a buffer around a pipeline (Network Data)

2. For each 1 Km pipeline segment, split the buffer polygon

3. For every buffer polygon segment, run query on some layer and find how many features are present in that area

Problem is with the 2nd operation. I am not sure how to achieve this. Please see a screenshot of illustration of what I want. End result will be to show for each segment of pipeline, how many features are present on both sides of pipeline within the buffer.

What tools/commands can be used for this. I eventually want this functionality as a GP service.
Tags (3)
1 Solution

Accepted Solutions
MVP Honored Contributor
Now that I am trying it I see I guessed a few settings wrong and missed a few steps.

The Excel table should be exported to a file geodatabase to create ObjectIDs and to make it possible to recalculate values.  All other exports should be to a file geodatabase.

I applied the RIGHT offset direction option to the Make Route Event Layer tool to make the side offsets relative to the digitized direction of the line.  Also, the angles created by the Make Route Event Layer tool are Arithmetic angles, meaning they increase in a counterclockwise direction that start at the east, while the Bearing Distance to Line tool uses Geographic angles which increase in a clockwise direction and start at the north.  To correct for that difference, calculate a new angle field called NORTH_ANGLE with this VB Script equation (use the Script codeblock check box):

Parser:  VB Script

Use codeblock:  checked

Pre-logic Script codeblock:
`North_Angle = ABS([LOC_ANGLE] - 360) + 90 If North_Angle >= 360 Then   North_Angle =  North_Angle - 360 End If`

NORTH_ANGLE (the field name for the output expression):  North_Angle

Export the event points to a real point layer to make calculation faster.  Add two double fields to the points for the X and Y Coordinate of each side offset point and calculate those fields with a Python calculation using !Shape.Centroid.X! or !Shape.Centroid.Y!

That point feature class should be the input to the Bearing Distance to Line tool and the NORTH_ANGLE field should supply the bearing.

I have attached a picture of results I was able to create.
16 Replies
MVP Honored Contributor
I would make the pipelines LR Routes with M values based on length in km.  (LR is ideal for all things line.)

Create a table in Excel with 4 columns:
1) The pipeline Route ID which will be the same value for every row generated for the next column.
2) A sequential number column for km along the line beginning at 1 and using as many rows that it takes to reach the highest km value for your longest line.
3) A column for side distance offset values that are about the negative double of the length of your buffer width.  This column value is the same for every row generated for column 2.
4) A column of values equal to double the absolute value of column 3 to use as a distance to cut across the buffer polygon.  This column value is the same for every row generated for column 2.

Use the spreadsheet with the Make Route Event Layer tool to make an LR point event table with the options that apply a side offset and that create an autogenerated angle field that is normal to the pipeline.  You should also generate an Event error field so that you can select the set of point that actually fell on the line, which will have a value of 'NO ERROR'.  The points will fall outside the buffer so that the line you generate next will be sure to fully cut across the buffer.  The table is a template that would just need to change the route ID to work on any given pipeline. You should be able to generate a complete table that appends every pipeline Route ID to the last 3 columns using the Make Query Table tool to join the pipeline routes and the template table.

Use that layer as the input to the Bearing Distance to Line tool to create the lines that cut across the pipeline buffer.  Because the offset was negative the autogenerated normal angle will work as a bearing that will cut across the buffered line intersecting the pipeline at every 1 km position on the line.

Finally split the buffer with the lines created by the Bearing Distance to Line tool using the Feature to Polygon tool.  This needs to be processed with an iterator that selects/filters only the related set of cut lines to just one pipeline Route ID at a time to avoid unwanted buffer and cut intersections.  The iterator would also process each separate cut up pipeline buffer one at a time to perform the intersect against the other layers you want to use in your process to avoid excessive polygon creation due to intersections with other pipeline buffers.
New Contributor

Create a table in Excel with 4 columns:
1) The pipeline Route ID which will be the same value for every row generated for the next column.
2) A sequential number column for km along the line beginning at 1 and using as many rows that it takes to reach the highest km value for your longest line.
3) A column for side distance offset values that are about the negative double of the length of your buffer width.  This column value is the same for every row generated for column 2.
4) A column of values equal to double the absolute value of column 3 to use as a distance to cut across the buffer polygon.  This column value is the same for every row generated for column 2.

Thank you Richard for your help. Can you please share a sample Excel file?
MVP Honored Contributor
Here is one.  The Route_ID, Side_Dist and Dist_Along are an arbitrary values in this case.  They should change to be a a real pipeline Route_ID with distances relative to the buffer width you use.
MVP Honored Contributor
Now that I am trying it I see I guessed a few settings wrong and missed a few steps.

The Excel table should be exported to a file geodatabase to create ObjectIDs and to make it possible to recalculate values.  All other exports should be to a file geodatabase.

I applied the RIGHT offset direction option to the Make Route Event Layer tool to make the side offsets relative to the digitized direction of the line.  Also, the angles created by the Make Route Event Layer tool are Arithmetic angles, meaning they increase in a counterclockwise direction that start at the east, while the Bearing Distance to Line tool uses Geographic angles which increase in a clockwise direction and start at the north.  To correct for that difference, calculate a new angle field called NORTH_ANGLE with this VB Script equation (use the Script codeblock check box):

Parser:  VB Script

Use codeblock:  checked

Pre-logic Script codeblock:
`North_Angle = ABS([LOC_ANGLE] - 360) + 90 If North_Angle >= 360 Then   North_Angle =  North_Angle - 360 End If`

NORTH_ANGLE (the field name for the output expression):  North_Angle

Export the event points to a real point layer to make calculation faster.  Add two double fields to the points for the X and Y Coordinate of each side offset point and calculate those fields with a Python calculation using !Shape.Centroid.X! or !Shape.Centroid.Y!

That point feature class should be the input to the Bearing Distance to Line tool and the NORTH_ANGLE field should supply the bearing.

I have attached a picture of results I was able to create.
New Contributor
Thanks alot Richard. That was really helpful. Really appreciate it.
I am able to generate the buffer segments at my end. Now I am working on automating it through model/script.
MVP Honored Contributor
Use the attached template table instead.  I adds two sets of From and To fields for line segments.  One set is the full length of the segment between points on the line.  The second if 1 meter short of that length at both ends.  Use the Make Route Event Layer with the FROM_M_2 and TO_M_2 fields and then Spatially Join those segments to your cut up buffers.  Because the lines will not touch any segment but the one they are within the Spatial Join should assign the attributes of only one segment to the buffer portion.  Then you will know what linear portion of the pipeline each buffer segment represents.

The Spatial Join must occur after the buffer is segmented and before you intersect the buffer segments with any other layers.
MVP Honored Contributor
Sorry.  Here is the attached template spreadsheet.
New Contributor
Ok. Thanks. I will try this template.
Currently I have added all the processes in a model but the problem I am facing is that Bearing Distance To Line tool generates only one line whereas when I run this tool manually on same output from Make Route Events Layer it works fine. Can you suggest what is the issue here?
MVP Honored Contributor
Ok. Thanks. I will try this template.
Currently I have added all the processes in a model but the problem I am facing is that Bearing Distance To Line tool generates only one line whereas when I run this tool manually on same output from Make Route Events Layer it works fine. Can you suggest what is the issue here?

I don't know why that would occur.  You could try clearing any layer selection or copying the Make Route Event Layer to a feature class using the Feature Class to Feature Class tool and using that output.  Anyway, I would have to see the model to have any other ideas of what is occurring.