I have a polygon data set where some of the polygons are irregular (mostly self-intersecting).
Here's an example of the irregular polygons that I have in the data set:
I want to write a Python program that will:
I have ArcGIS for Desktop and Server.
Thanks,
-S.
Like this...?
import arcpy arcpy.RepairGeometry_management ("c:/data/sketchy.shp")
as cited in this...
http://desktop.arcgis.com/en/desktop/latest/tools/data-management-toolbox/repair-geometry.htm
(gotta love dev's sense of humor)
BUT
Sharon,
Is the layer already a polygon layer, or are they polylines/arcs? If arcs, and have access to the Advanced (ArcInfo) level, you can use Feature To Polygon—Help | ArcGIS for Desktop By default, it doesn't appear that the "preserve attributes" is working, at least not for me in 10.2.2. However, there is an option to add attributes if associated with a point feature class.
For testing, I created an set of arcs similar to what you showed. I then created a point FC (with new fields for attribute data) and added a point to each of the polygonsl. I then ran the tool, and included the point field for the labels. (First time I ran it, I still had the last point I added selected, so that was the only one copied...that is, make sure no points are selected when running....unless you want to limit it.)
Below are the input arcs, and points (labelled). The dialog box for the tool, and the polygons labelled. Is this what you are trying to achieve?
The python snippet is
# Replace a layer/table view name with a path to a dataset (which can be a layer file) or create the layer/table view within the script # The following inputs are layers or table views: "badPolyLabelsPts" arcpy.FeatureToPolygon_management(in_features="testArcs",out_feature_class="C:/Users/Owner/Documents/ArcGIS/Default.gdb/badPolys5",cluster_tolerance="#",attributes="ATTRIBUTES",label_features="badPolyLabelsPts")
Hi Sharon
Adding to Dan post there is a Multipart to Single part tool under data management -> features
Sometimes you want to keep this polygon as one multipart polygon since the attributes are the same for all polygons.
Self-intersecting polygons are not allowed in geodatabase but multipart polygons are fine.
Keep in touch
Mody
I gave up on dealing with invalid/irregular polygons in ArcPy, or really even ArcGIS, a few years back. I kept running into polygons that were invalid but the standard Esri tools couldn't identify them. Eventually, I threw in the towel and now use Safe Software's FME product to do my polygon validation when I run into problems. When access to FME isn't available, I sometimes convert ArcPy Polygon objects to Shapely or GeoDjango geometries to find invalid polygons. It is all a bit kludgy, but I got tired of fighting with Check Geometry and Repair Geometry.