4

I have a very long polyline representing a pipeline. I also have another feature class with smaller polylines which are coincident with the pipeline. I am trying to cut the pipeline with the smaller segments to essentially get the inverse of the feature class of smaller segments.

So, I have this:

enter image description here

and I'm trying to get this:

enter image description here

I cannot use the Erase tool because I am using the Standard License of ArcGIS desktop. I cannot install third-party software (ET-Geowizards) or QGIS due to IT policies.

Normally, I would use the Union tool but it only works for polygons.

One thought I had was to use linear referencing and create an event table of the gaps and generate line segments from that. Another thought was to use search and insert cursors to build the lines based on the coordinates of the existing lines. But I was hoping to use some workflow of the analysis/overlay tools. Surely, this has been done before using built-in tools.

I don't want to do this manually because I have hundreds of segments.

Any thoughts on a workaround?

  • 2
    Since "buffer with a flat endcap" also requires an Advanced license, you'll need to construct your own flat buffer with Python and trigonometry, at which point you can Union and select out the parts you want to keep. – Vince Dec 22 '16 at 1:58
  • @Vince This would be ideal. Do you have an example of how to do that? – jbalk Dec 22 '16 at 2:17
3

This workflow is suitable for any license type. The key is creation of small perpendiculars at the ends of short lines.

arcpy.AddGeometryAttributes_management("SHORT_LINES", "LINE_START_MID_END")
arcpy.MakeXYEventLayer_management("SHORT_LINES", "START_X","START_Y", "starts_Layer")
arcpy.MakeXYEventLayer_management("SHORT_LINES", "END_X", "END_Y", "ends_Layer")
arcpy.Merge_management("ends_Layer;starts_Layer", "D:/Scratch/ends.shp")
# create tiny buffer around short lines ends
arcpy.Buffer_analysis("ends", "D:/Scratch/buffs.shp", "0.1 Meters")
arcpy.Clip_analysis("LONG_LINE", "buffs", "D:/Scratch/clipped.shp")
arcpy.Dissolve_management("clipped", “D:/Scratch/directions.shp", multi_part="SINGLE_PART")

Run this field calculator expression on Shape field of “directions”, to get perpendiculars. Use 0.1 m or even smaller as parameter.

arcpy.Merge_management("directions;LONG_LINE", "D:/Scratch/merged_lines.shp")
arcpy.Dissolve_management("merged_lines", "D:/Scratch/splitted.shp", multi_part="SINGLE_PART")
arcpy.SelectLayerByLocation_management("splitted", "SHARE_A_LINE_SEGMENT_WITH", "LONG_LINE")

Switch selection to delete parts of “splitted”. Do similar thing to delete bits sitting under short lines.

  • This partially works. A few comments: I had to define a spatial reference for the MakeXYEventLayer lines because it defaults to WGS84. Also, the final select by location didn't work. Splitting the line worked well and I think that will get me where I need to be. Love the field calculator expression. – Fezter Dec 22 '16 at 4:38
  • I tested this and it works well. The only part that is missing is the spatial reference for the makeXYeventlayer. The field calculator is impressive as ususal. – jbalk Dec 22 '16 at 4:58
  • If select by location SHARE_A_LINE_SEGMENT_WITH didn't work it means that short lines are not fully coincident with long one. It is also possible that features are stored in GDB and this plays tricks. When dealing with precise geometry manipulation, I try to use shapefiles – FelixIP Dec 22 '16 at 4:59
  • I specified spatial reference while testing, but removed rom the post because it made relevant line way to long, sorry – FelixIP Dec 22 '16 at 5:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.