I observed, that calling the distanceTo - Method on Polygons containing circular Arcs can cause python.exe to crash without throwing a exception.
After processing (linearizing the arcs) the polygon featureclass with:
arcpy.Densify_edit(in_features='in_Memory/fc', densification_method='OFFSET', max_deviation=0.001)
it is possible to process the featureclass with "distanceTo" without problems.
I would like to know if this is a bug or a feature? Are there other options of circumventing the problem?
Thank you Bernhard
Solved! Go to Solution.
Try the following in a standalone Python window, what do you get?
>>> import arcpy
>>> esri_json = {
... "curvePaths": [[
... [1,5],
... {"c": [[7,3], [6,2]]}
... ]],
... "spatialReference": {"wkid": 0}
... }
>>> ln = arcpy.AsShape(esri_json, True)
>>> ln2 = arcpy.FromWKT('LINESTRING(0 0, 10 0)')
>>> ln.distanceTo(ln2)
1.4903987973986754
>>>
I don't have any geometry that uses arcs. What is the source data type and its current representation?
From here arcs aren't even mentions, however, geometry consisting of vertices and segments should have no problem if you have densified and converted to one of the mentioned geometry types.
Try the following in a standalone Python window, what do you get?
>>> import arcpy
>>> esri_json = {
... "curvePaths": [[
... [1,5],
... {"c": [[7,3], [6,2]]}
... ]],
... "spatialReference": {"wkid": 0}
... }
>>> ln = arcpy.AsShape(esri_json, True)
>>> ln2 = arcpy.FromWKT('LINESTRING(0 0, 10 0)')
>>> ln.distanceTo(ln2)
1.4903987973986754
>>>
with ArcGIS 10.2 I obtain:
Traceback (most recent call last):
File "_____________________\jsonarc.py", line 16, in <module>
ln = arcpy.AsShape(esri_json, True)
File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\arcobjects\geometries.py", line 164, in AsShape
return convertArcObjectToPythonObject(gp.fromEsriJson(geojson_struct))
File "C:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 483, in fromEsriJson
return self._gp.FromEsriJson(json)
ValueError: Invalid geometry type for method
with ArcGIS 10.3 I obtain your result.
So thank you Yoshua for helping isolating my Problem.
I am glad you were able to sort it out. I took a quick look through the Issues Addressed lists for 10.2.1, 10.3, and 10.3.1; I couldn't see anything that jumped out as this bug being fixed.
astonishing ... I found a secret bug?
I can't say this is unique to Esri, but bugs are like roaches, they are everywhere even if you don't see them.