I'm using ArcGIS Pro 3.1.1
I'm encountering an issue when I try to run the "Slope" tool in arcpy. First of all, when I run the tool manually the tool runs without any problems. But in Arcpy, it does not work, even if I use the code from "Send To Python Window" from the manual execution.
Here is my code:
out_raster = arcpy.sa.Slope(
in_raster="dtm_mask",
output_measurement="DEGREE",
z_factor=1,
method="PLANAR",
z_unit="METER",
analysis_target_device="GPU_THEN_CPU"
)
out_raster.save(r"C:\Users\Desktop\slope_test")
Resulting in the following error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\Functions.py", line 8685, in Slope
return Wrapper(
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\Utils.py", line 55, in swapper
result = wrapper(*args, **kwargs)
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\Functions.py", line 8632, in Wrapper
z_meters_per_unit = linear_unit_factors[zlu]
KeyError: 'METRE'
So it says that there is a KeyError with "METRE", but I defined in the "z_unit" "METER".
How can I solve this problem? Is there maybe something wrong in the source code of the "slope" function?