Identifying and fixing irregular polygons

5192
5
08-22-2015 03:54 AM
SharonDagan
New Contributor

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:

polygons.png

I want to write a Python program that will:

  • Identify that an input polygon is irregular; and then
  • Transform it into a set of regular polygons, i.e., break the irregular polygon into several regular polygons. A simple case is to break a figure "8" polygon into two "0" polygons.

I have ArcGIS for Desktop and Server.

Thanks,

-S.

0 Kudos
5 Replies
JayantaPoddar
MVP Esteemed Contributor

Hi Sharon,

You might like to move this thread to Python

Moving Content



Think Location
0 Kudos
DanPatterson_Retired
MVP Emeritus

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

  • you would have to explode multiparts into singleparts (there is a tool for this)
  • any polygon pieces that share a common border will be dissolved into one (there is no work around)
  • in short...you will have to construct what you want from the pieces that are salvageable and ensure that the bad structure doesn't happen during construction in the first place
0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

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")
0 Kudos
ModyBuchbinder
Esri Regular Contributor

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

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

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.

0 Kudos