Is there a way to iterate through features in a feature class and perform a geoprocessing function on them feature-wise, one-by-one?

2722
3
06-17-2019 11:43 PM
ThomasBlankinship
New Contributor

I am working on a project in which there is considerable geometric overlap in polyline data in the same feature class. These polylines are from old property records taken from land grants and were initially not closed polylines because of inexact surveying methods. I closed each individual feature by assigning each entry in the raw polyline data an ID, running the Feaures to Vertices tool, and then running the Points to Lines tool and selecting to close the line. Now I have a bunch of closed polylines corresponding to each lot in my dataset.

What I would like to do is turn each of these closed polylines into its own polygon (along with the data associated with it). The problem is, when I try to use the Feature to Polygon tool, it causes major problems at places where these lines overlap. It either causes slivers or does not recognize the fact that smaller polygons can exist within larger ones. I know it is doing exactly what it is expected to, but it isn't what I'm looking for. It works exactly as I want it to if I manually go through each feature in the attribute table and click Modify and then Construct Polygons. I imagine it would also work perfectly if I were to take each feature and turn it into its own layer, Construct Polygons, and then merge these layers back together.

What I would like to do, however, is write code to either:

1) Iterate through each row entry (feature) in the attribute table and perform the Modify and Construct Polygons under the Edit ribbon.

2) Under the Analysis ribbon and Geoprocessing Tools, use the Feature to Polygon tool to run through each row entry (feature) if that is possible. This would be the preferred method as it would allow me to transfer wanted information for the attribute table of the polylines to the attribute table of the new polygons. I'm not sure how to do that otherwise without exporting to Excel or something and reimporting it after editing.

In general I'm wondering if there is a way to perform geoprocessing functions on individual features (rows) at a time. I know I can edit attributes in the attribute table in that way using ArcCursor, but I'm hoping that I can isolate and iterate through each row and perform some sort of Geoprocess at each step.

0 Kudos
3 Replies
MehdiPira1
Esri Contributor

One way is to convert each row into a feature class, apply your geoprocessing then merge them back into one feature class. The steps are:

1. split layer by attribute.

2. convert (polyline to polygon),  you can find scripts in python online for this if you don't have the license.

3. merge all the geoprocessed features into one.

4. done.

ThomasBlankinship
New Contributor

I was unaware of the tool to split by attribute, so I appreciate that.

The problem is, and I was afraid of this, this method is taking forever. I've had it running on a dataset that is 722 polyline features for over 12 hours and only about 43% have been converted to their own layers with the tool. Add in whatever time it'll take to convert each layer's polylines to polygons and then merge them back together and we're looking at probably two full days at least. I'm hoping to find a way to operate on each feature in a layer at a time without the need to split the layers. Looking into a few of the suggestions that showed up below. Will update if I find anything.

0 Kudos
BruceHarold
Esri Regular Contributor

You should be able to leverage the pattern of using geometry objects as a tool input, in your case Feature to Polygon:

Using geometry objects with geoprocessing tools—ArcPy Get Started | ArcGIS Desktop 

Another way would be to get an array from the polylines and make polygons with the constructor:

Polygon—ArcPy classes | ArcGIS Desktop 

0 Kudos