0

I am trying to write an ArcMap 10.6 Python add-in, which cuts narrow places of polygons. In the script I work with geometry objects. Testing my add-in I noticed, when I use geoprocessing tools with geometry object input, the output does not have the same spatial reference.

poly_geometry = arcpy.management.CopyFeatures('layer_name', arcpy.Geometry())[0]
print poly_geometry.spatialReference.exportToString()
poly_from_poly_geometry = arcpy.CopyFeatures_management(poly_geometry, arcpy.Geometry())[0]
print poly_from_poly_geometry.spatialReference.exportToString()
print poly_from_poly_geometry.area == poly_geometry.area

By means of logic both polygons areas must be equal. And after using an object as input, poly_geometry spatial reference have changed as well. If output and input is a layer, spatial reference (sr) and areas are equal. But if the output is in_memory workspace, sr and areas again are not equal. If edit is off (Stop Editing button), sr and areas are equal in both methods (input/output is object/layer). If I try to set outputCoordinateSystem as sr, nothing changes.

My add-in needs to use an edit session and geoprocessing tools, such as CopyFeatures. The code example is not from my script, but it perfectly represents my problem.

How to make outputs have same spatial reference and areas in editing session?

2
  • I ran your code in edit node, not in edit mode, workspace set to IN_MEMORY and not IN_MEMORY and for me both coordinate systems are the same and your last line evaluates to TRUE. So I cannot replicate your problem. I ran your code in the python console and I'm running ArcMap 10.7. Commented Oct 15, 2021 at 12:21
  • @Hornbydd, thsanks fot your test. Maybe, arcpy.env or layer have properties, who control output spatial references. Commented Oct 15, 2021 at 12:30

1 Answer 1

1

It sounds like you have a geoprocessing setting at the application level that is overriding the coordinate reference system output from ArcPy.

See Environment levels and hierarchy in the ArcMap Online Help.