I am running in some strange problems in ArcGIS Pro 2.7.2. Within a notebook I started to define some environmental settings, setting addOutputsToMap to false and overwriteOutput to true, and I specify the outputCoordinateSystem via
arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(25832)
I retrieve an iterator containing the path of a number of tif files and iterate over it.
Within the iteration I utilize RasterToPolygon
arcpy.conversion.RasterToPolygon(tif,out_fc,simplify="NO_SIMPLIFY",raster_field="Value")
Even though I set outputOverwrite = True I am getting ERROR 000528: Output Path/to/File already exists from RasterToPolygon. Does not happen all the time, but from time to time.
The other problem is the coordinate system defined for the notebook. In case I leave the environmental attribute addOutputsToMap at the default value I get the immediate response while running the RasterToPolygon cell. The feature classes created by the tool are missing the spatial reference!
I checked... all tif files are in EPSG 25832, the feature dataset I am writing the feature classes into is defined in EPSG 25832, and the notebook defines the coordinate system to EPSG 25832.
I was also running the RasterToPolygon in an with-statement, utilizing EnvManger... to no avail.
I wonder where RasterToPolygon drops the coordinate system.
In case it's not meant to honour neither environmental settings, nor inherit spatial references from input files then I wonder why there is no parameter, offering the possibility to define the output coordinate system for the method.
The Python used here is in version 3.7.9 and I did not clone the environment... it's the default.
From...
Raster to Polygon (Conversion)—ArcGIS Pro | Documentation
these are the environment parameters that are supported
Auto Commit, Current Workspace, Default Output Z Value, Extent, Geographic Transformations, M Resolution, M Tolerance, Maintain Spatial Index, Output CONFIG Keyword, Output Coordinate System, Output has M values, Output has Z values, Output M Domain, Output XY Domain, Output Z Domain, Scratch Workspace, Snap Raster, XY Resolution, XY Tolerance, Z Resolution, Z Tolerance