I'm looking for a simple way to delete all of the "interior" (non endpoint) vertices in a line. It can't be a GP tool that writes a new output, I need to modify the existing features. Generalize wont work because the data is in a geometric network that I cannot delete and recreate. Ideally I could select multiple lines and have them processed with a single button click. Is there anything out there that will do this?
You do realize that is you delete all the vertices that you will have a straight line between the two end points, correct?
If you are editing Deleting a vertex—Help | ArcGIS for Desktop but since you are using a network, maybe this will help
I do not use networks myself, but that looks like it will help remove some vertices without compromising the network itself. there are also several other links available from that landing page that might be of help.
Yup a straight line is exactly what I want. This is for a water utility when a bunch of service connections are snapped to a line. If you move the line endpoints you wind up with a funky looking water line, unless you manually adjust all of the vertices where the services are snapped to the line. If you delete all of the middle vertices the geometric network retains the service snapping while giving you a nice straight line. I just need to figure out hot to do it efficiently. Delete vertices takes too long when there are thousands of features.
You can get to the geometry and grab the first and last points using python
but again, since I do not work with networks, I'm not sure how this would effect your original data (so always test on a copy).
How Simplify Line works—Help | ArcGIS for Desktop might be another option.
Thanks for the suggestions. My python skills are not ready to quickly tackle this issue. If I had 40 hours to play with I'm sure I could make it happen, but that's not the case for this one. Thanks again.
If anyone else has suggestions please let me know. ET GeoTools has a Generalize tool that works about 60% of the time but that still also requires hitting individual features.
Here's one more effort to help.
Since you can't create a new network you may not be able to get away without some manual work, but looking at the network tools avaiable, have you looked at Update by Geometry—Help | ArcGIS for Desktop
Updates all the edge references in the turn feature class using the geometry of the turn features. This tool is useful when the IDs listed for the turn can no longer find the edges participating in the turn due to edits to the underlying edges
I have no idea whether this will work or not (again, I don't use networks), but reading this I'm thinking if you can get a layer of just the end points, then maybe you can use this to modify the lines. (again, test on a copy).
There are many suggestions for getting a new layer of jut the end points. Have you done a basic browser search on something like "arcgis find endpoints" or "arcgis find nodes" ? Sometimes that pops up ArcGIS help or geonet, but also Stackexchange.
has some decent options, including the first suggestion by Richard Fairhurst
I'll back off this thread now....hopefully someone with Network experience will jump in. I'll tag
As an update for anyone interested, I found that the ET GeoTools generalize will work on a line in a geometric network. While it still requires processing individual lines one at a time it is a better solution than manually deleting vertices.
I am not sure if this will work when the layer is part of a network, but below is an example of how a MULTILINESTRING can be collapsed to just the endpoints of the individual LINESTRINGS. The code will work against a single-part MULTILINESTRING too.
>>> polyline = arcpy.FromWKT('MULTILINESTRING((0 0, 5 0, 7 0, 7 1, 9 1, 9 3, 9 5),(3 2, 5 2, 6 2, 8 5))')
u'MULTILINESTRING ((0 0, 5 0, 7 0, 7 1, 9 1, 9 3, 9 5), (3 2, 5 2, 6 2, 8 5))'
>>> arr = arcpy.Array()
>>> for line in polyline.getPart():
... arr.add(arcpy.Array([line, line[-1]]))
>>> polyline = arcpy.Polyline(arr)
u'MULTILINESTRING ((0 0, 9 5), (3 2, 8 5))'
The following code could be wrapped in an ArcPy Data Access cursor.
The following Python code would accomplish what you're after:
fc = arcpy.mapping.Layer('C:/Temp/Temp.gdb/myFc')
with arcpy.da.UpdateCursor(fc,["SHAPE@"]) as cursor:
for row in cursor:
#loop through parts
for part in row:
count = 0
# loop through verticies
for pnt in part:
count = count + 1
if count >= 3:
arr = row.getPart(0)
newLine = arcpy.Polyline(arr)
row = newLine