I run distance accumulation in a standalone Python script and save the resulting raster as follows:
dist_acc_raster = arcpy.sa.DistanceAccumulation(dest_features, "", "",
cost_raster, "", "", "", "",
back_dir_raster, "", "", "", "",
"", "", "GEODESIC")
dist_acc_raster.setProperty("name", "some_specific_name")
dist_acc_raster.save(r"C:\some.gdb\some_specific_name")
# EDIT: replaced path variable with path to make it clearer
The raster name is always set to the default "Distanc_{suffix}" name which annoys me when adding the data to a map later. This does not happen when I run the tool manually in ArcGIS Pro. How can I set the name property? "setProperty" does not appear to work, and is probably not what I need (from the ArcPy Raster page: "Add a customized property to the raster dataset").
EDIT: added screenshot from FileGDB raster datasets.
According to the help, you specify it using save
Distance Accumulation (Spatial Analyst)—ArcGIS Pro | Documentation
outDistAcc = DistanceAccumulation("insources.shp", "barriers.tif")
outDistAcc.save("c:/sapyexamples/output/distacc.tif")
path_dist_acc_raster has the output path and name and this is not working?
Thanks for the quick answer. Yes, the raster is saved with the correct name in the FileGDB, but when added to a map, shown with name "Distanc_{suffix}".
As a test, try saving it as a *.tif in a folder instead.
If it behaves as expected, perhaps the gdb uses an alias or just ignores anything after.
You could also examine the script to see if anything looks like it might be useful to solving this issue
C:\... your install folder ... \Resources\ArcToolBox\Scripts\distanceaccumulation.py
I just tested saving the accumulated distance rasters as TIF files and this works fine. In the FileGDB they are also saved with their correct name, as displayed in the Catalog pane, but in the Contents pane the default name is displayed. This is why I thought I might have to explicitely set some property.
On a side note, the back direction rasters are displayed correctly in the Contents pane. The difference to the accumulated distance raster is that there is a parameter to set the name.
I will check if I find something useful in distanceaccumulation.py tomorrow (its already late here), thank you for the hint.