Select to view content in your preferred language

Environment Setting - output coordinate system not being applied in Python toolbox arcpy tools

228
3
Jump to solution
12-10-2024 02:18 PM
MollyMoore
Frequent Contributor

I have a custom Python Toolbox script. As a part of the Python toolbox, I apply a multi ring buffer and would like the output to be in consistent coordinate system (which happens to be a custom coordinate system) regardless of the input. I am setting the coordinate system with environment manager, but the output is NOT honoring the environment settings and is in the same projection as the input dataset. Here is the code snippet from the larger script:

with arcpy.EnvManager(outputCoordinateSystem='PROJCS["alber",GEOGCS["GCS_North_American_1983",DATUM["D_North_American_1983",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers"],PARAMETER["false_easting",0.0],PARAMETER["false_northing",0.0],PARAMETER["central_meridian",-78.0],PARAMETER["standard_parallel_1",40.0],PARAMETER["standard_parallel_2",42.0],PARAMETER["latitude_of_origin",39.0],UNIT["Meter",1.0]]'):
    multi_buff = arcpy.MultipleRingBuffer_analysis(input_lyr, os.path.join(scratch_gdb, "multi_buff"), [100, 500], "Meters", "distance", "ALL", "OUTSIDE_ONLY", "GEODESIC")

Curiously, I also just tested the Multiple Ring Buffer tool in ArcGIS Pro as well. I set the output coordinate system in the environment settings. The output was not consistently projected into the output coordinate system. Sometimes it would be and sometimes it wouldn't be. 

Does anyone have any insight on this? Thank you!

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

Not if the coordinate system is getting picked up in one scenario and not another.

Bug ... off to tech support


... sort of retired...

View solution in original post

3 Replies
DanPatterson
MVP Esteemed Contributor

Is a transformation required?

Is the input coordinate system know in the script?

Output Coordinate System (Environment setting)—ArcGIS Pro | Documentation

did you try setting the code outside of a context manager as a test


... sort of retired...
0 Kudos
MollyMoore
Frequent Contributor

For testing, I used a layer that I knew the input coordinate system and added the transformation. I also tried setting the code outside of a context manager.

Curiously, the output coordinate system seems to behave as expected if I set the Dissolve Option to "NONE" (Non-Overlapping (rings)), but does not honor the output coordinate system/transformation if the Dissolve Option is set to "ALL" (Overlapping (disks)).

This seems buggy to me, but is there any potential explanation for why it would behave this way?

0 Kudos
DanPatterson
MVP Esteemed Contributor

Not if the coordinate system is getting picked up in one scenario and not another.

Bug ... off to tech support


... sort of retired...