arcpy.Clip_analysis produces feature output without spatial reference

330
2
08-21-2020 01:02 PM
MichaelJust
New Contributor

When I use `arcpy.Clip_analysis()` in a stand-along Python 3.6 script, the output is missing a spatial reference. When I complete the task within ArcGIS Pro using the GUI, the feature output maintains the spatial reference. 

The input feature, the clipping feature, and the output feature are each in a different file geodatabase. The clipping feature is a polygon and the clipping feature can be point, line, or polygon; I am experiencing the same issue with each feature type. The input feature and the clipping feature are both projected with "USA Contiguous Albers Equal Area Conic USGS."

Is there something I can change int the environmental settings? Other suggestions?

0 Kudos
2 Replies
MichaelJust
New Contributor

arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(102039)

Seems to have solved the issue. Is this best practice when working with feature data?

0 Kudos
DanPatterson
MVP Esteemed Contributor

Michael Just‌ I would say yes, because explicit is better than implicit, especially is you look at all the considerations involved in determining an output coordinate system

Spatial reference and geoprocessing—ArcGIS Pro | Documentation 

Even though Clip supports the coordinate system environment variable, why assume


... sort of retired...
0 Kudos