ArcDesktop 10.5 - arcpy.da Geometry Issues

2353
10
11-07-2017 08:48 AM
Kathleen_Crombez
Occasional Contributor III

I have a quality control script that recreates features from a line work layer to ensure all our taxing districts are following the tax parcel boundaries.

We have been running this script every year since version 10.0

We recently upgraded to 10.5 and ran into a scenario where the union tool was creating features (in a file geodatabase featureclass) that have a shape_length value but the shape_area was zero. These features are tiny slivers (usually on curves) that appear to be lines (but are really polygons).

The script copies the fallout features from the union layer to a quality control featuredataset in SDE using arpy.da cursors (search and insert).

where these areas are zero we started getting the following error:

SystemError: error return without exception set

running a quick test, I tried to use the getArea() method to put in an exception for areas equaling zero.

layer = r"\\path\to\featureclass"

with arcpy.da.SearchCursor(layer, ["SHAPE@"]) as cursor:

   for row in cursor:

      if row[0].getArea() == 0.0:

         # do something

what I ran into was sometimes it worked and sometimes it through an error:

AttributeError: '_passthrough' object has no attribute 'getArea'

so then I decided to just print row[0] and my results have mixed geometries...

<arcpy.arcobjects.mixins._passthrough object at 0x1585D610>
<geoprocessing describe geometry object object at 0x0297E0C0>
<arcpy.arcobjects.mixins._passthrough object at 0x1585D610>
<geoprocessing describe geometry object object at 0x0297E0C0>
<arcpy.arcobjects.mixins._passthrough object at 0x1585D610>
<geoprocessing describe geometry object object at 0x0297E0C0>

what is this all about?

I have never seen these arcpy.arcobjects.mixins._passthrough objects.

can someone please explain the difference between these geometry types?

and was this just introduced in version 10.5?

Any insight would be helpful.

Thanks,

Kathleen

0 Kudos
10 Replies
RebeccaStrauch__GISP
MVP Emeritus

I can't answer you question, since we haven't upgraded to 10.5.x yet, but I'm wondering if you use topology rules.

You mention SDE and marking exceptions, so my guess is you already do have them setup, but just in case...

An overview of topology in ArcGIS—Help | ArcGIS Desktop 

0 Kudos
Kathleen_Crombez
Occasional Contributor III

Rebecca,

We do have topology on the original layers in SDE. these areas are not being identified in the topology errors. we do have Boundary Must Be Covered By the line work layer. we also have Must Not Overlap and Must Not have Gaps.

however, this is not what I meant by marking it as an exception.

I meant that I was using a conditional statement (if row[0].getArea() == 0.0) to provide a different error message to prompt the person running the script to check a different location to find these sliver errors where the polygons do not match the line work because they cannot be copied to the final fallout location.

But that conditional statement was throwing an error on the arcpy.arcobjects.mixins._passthrough objects.

Thanks anyways.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

If you print the WKT, what do some of these polygons look like?

0 Kudos
Kathleen_Crombez
Occasional Contributor III

with arcpy.da.SearchCursor(t, ["SHAPE@","SHAPE@WKT"]) as cursor:
      for row in cursor:
            print row[0], row[1]

where the area is zero the SHAPE@WKT is None (however they look like slivers when I view them in ArcMap)

otherwise my print statement looks something like this...

<geoprocessing describe geometry object object at 0x02B31820> MULTIPOLYGON (((1057644.6332177445 1225359.5342195705, .... , 1055905.6406327449 1225768.6685719043)))

<arcpy.arcobjects.mixins._passthrough object at 0x02B31810> MULTIPOLYGON (((1005439.4298855774 1219931.8436314017, ... , 1005750.351835914 1217696.1525647417)))

NOTE: the ... in the examples above elimates numerous XY coordinates. All polygons are legitimate multipolygons with a minimum of 4 vertices.

0 Kudos
DanPatterson_Retired
MVP Emeritus

rather than 'SHAPE@' just try 'Shape'  ie the shape field name (they have their own issues)

0 Kudos
Kathleen_Crombez
Occasional Contributor III

Not really sure what this is providing me.

It looks like a single point tuple. It is close to the first point in the multipolygon, but not exactly.

Here are the first two records when I use "Shape"

These are the same two records as the ones shown in the post above.

(1057423.7430463613, 1223122.6208914442)

(1004102.0138055336, 1210731.6523156033)

0 Kudos
DanPatterson_Retired
MVP Emeritus

just checking are the ... 's missing the the 'Shape' return? if so, that would be a 2 point polygon (not going to happen) or were the ... 's omitted during transcription. which also leads to the suggestion of counting the length of the returned array to ensure that there are 4 points at least, which wouldn't solve the co-located problem, but it would further help with the messed up geometry objects

0 Kudos
Kathleen_Crombez
Occasional Contributor III

My apologies.

The "..." was written so I did not have to post a 500 line post because every multipolygon that did not have and area of zero had hundreds of XY vertices. I was just short handing the response.

Sorry. I should have made that clear in my post.

also note that out data is in State Plane US Feet.

0 Kudos
Kathleen_Crombez
Occasional Contributor III

Just to be clear, I am not looking for a solution to the getArea() function.

I decided to use SHAPE@AREA to get the area and test if it is zero.

but I do not understand why there are these different geometry types within a single feature class.

The original layer in SDE only contains <geoprocessing describe geometry object objects>

but after running the union against the rebuild layers I end up with a combination of "geoprocessing describe geometry object objects" and "arcpy.arcobjects.mixins._passthrough objects"

what are these arcpy.arcobjects.mixins._passthrough objects?

0 Kudos