Is there an ArcPy method to merge polylines within the same layer?

4802
13
07-03-2018 03:44 PM
GuyBeels
New Contributor II

Is there a way using ArcPy to merge features selected from the same layer into a new feature, exactly as the Edit > Merge tool does it?  I want to script this, because several dozen merges need to be done on a series of feature selections (iterating through a list of saved SQL expressions).  I looked, but could not find. 

I am working in ArcGIS Pro 2.0, but I also have ArcGIS Desktop 10.6 available.  Thanks for your help.

Tags (2)
0 Kudos
13 Replies
GuyBeels
New Contributor II

To clarify, I designed a flow that would create no merged features in the original dataset - and for this I actually like Dissolve.

0 Kudos
JohnGaiot
Occasional Contributor

Hi Joshua, I am very much interested in how you would apply the merge functionality using arcpy. To answer your question, I would like to merge to the lowest OID feature. Thanks.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

From earlier comments, it seems you have 3 or 4 attributes (not sure if you are including the spatial attribute in those numbers).  What does your table/feature class structure look like, and how to you want to handle the merge?  If there are integer fields, do you want so sum them, keep the value from the lowest OID, etc...?

0 Kudos
JohnGaiot
Occasional Contributor

Basically I'd like to keep all the attributes from the record with the lowest OID. I am dealing with a large scale watercourse dataset that has hundreds of small gaps in the original capture. Most of them are within 4 metres, and so by performing a Near Analysis on the from and to nodes of the dangles, I can create a line feature class from the From-XY and To-XY attributes to connect them.

But the merging part has me perplexed...

0 Kudos