Has anyone used the arcpy geometry difference operator and seen unexplained errors like what I describe below?

This is a weird one. I have a script that calculates wave fetch distance in the ocean using a polygon file with land features (coastal areas and islands) and a point file with points for which fetch is to be calculated. It does this by creating a multipart geometry object with numerous individual line segments in a star-shaped pattern radiating around the point (these are bearing lines at user-specified intervals). I am "erasing" this pattern of lines using the geometry.difference method described here: http://bit.ly/1vBMSjP (scroll down to "difference" under the "Methods" section). The object that is used to erase the lines is a multi-part polygon geometry created from the user-defined land features. Both geometries are in the same projection, which is the same as the coordinate system defined in arcpy.env.outputCoordinateSystem. After completing the geometry difference operation, the script moves on to the next point and generates a new set of line geometries. All in_memory objects and variables are erased after each iteration to free up memory.

Randomly, the script throws this error:

Traceback (most recent call last):
      File "c:\data\scripts\py\FetchGeomV3.py", line 182, in <module>
    lineErased = currentLine.difference(landGeom)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\arcobjects\arcobje
    cts.py", line 793, in difference
    return convertArcObjectToPythonObject(self._arc_object.Difference(*gp_fixarg
    ValueError: <geoprocessing describe geometry object object at 0x02447640>

The really weird part is that if I run it again, using the exact same input files and parameters, I cannot reproduce the error. Sometimes it runs all the way through without ever throwing an error, sometimes every 100 points or so will generate the error--on different points than on the previous run.

Original code is here: http://bit.ly/1rtMNtc

  • The link is broken. For questions that involve code we ask that you show us where you are stuck with your own code by including a code snippet in your question. There is an edit button beneath your question which will enable you to do that and a {} button that enables you to format any highlighted code nicely.
    – PolyGeo
    Commented Nov 27, 2017 at 1:51

1 Answer 1


Well I figured it out. I ran a repair geometry on the input polygon feature class. Problem solved. I should have tried that first!

Another thing I found that created problems was feature classes that had a ZM geometry. Simplify all those to plain 2D geometry first.

Not the answer you're looking for? Browse other questions tagged or ask your own question.