Hello,
BLUF: Does the script version of CalculateDistance() require an enterprise license/cloud resources?
I am able to use the Geoprocessing|Euclidian Distance tool effectively in the ArcGIS Pro desktop interface.
When I copy the arguments from the desktop interface and try to execute them via arcpy.ra.CalculateDistance(), however, I receive the following error:
Traceback (most recent call last):
File "C:\Users\csmith\Documents\ArcGIS\Projects\final_data_roundtrip\final_data\final_data.py", line 4, in <module>
main()
File "C:\Users\csmith\Documents\ArcGIS\Projects\final_data_roundtrip\final_data\main.py", line 110, in main
arcpy.ra.CalculateDistance( inputSourceRasterOrFeatures = WORKSP + r'\scratch' + str(i) + r'\Band_1'
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\ra.py", line 2156, in CalculateDistance
raise e
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\ra.py", line 2153, in CalculateDistance
retval = convertArcObjectToPythonObject(gp.CalculateDistance_ra(*gp_fixargs((inputSourceRasterOrFeatures, outputDistanceName, maximumDistance, outputCellSize, outputDirectionName, outputAllocationName, allocationField, distanceMethod, inputBarrierRasterOrFeatures, outputBackDirectionName), True)))
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Unable to get rasterAnalytics URL.
Failed to execute (CalculateDistance).
Is there an environment setting that is needful to get around this? Or do I need to work my portal administrator to verify that required server components are installed and permissions granted to my account?
Thanks in advance,
Chris Smith
Raster Analysis toolbox licensing—ArcGIS Pro | Documentation
An overview of the Legacy Use Proximity toolset—ArcGIS Pro | Documentation
Calculate Distance (Raster Analysis)—ArcGIS Pro | Documentation
You can use the substitute locally installed version instead
Thanks for the feedback.
Is the substitute locally installed version scriptable?
I wanted to perform analysis on several hundred rasters; managing them by means of the UI would be a fallback position.
Very respectfully,
Chris Smith
The spatial analyst and image analyst are indeed scriptable. Check out arcpy
ArcGIS Pro Python reference—ArcGIS Pro | Documentation
@DanPattersonYes, but transferring my Euclidian Distance arguments to arcpy triggered the Subject: error. Hence my question of whether AcrGIS Pro acrpy.ra.CalculateDistance() has to be run on a portal server, which seems to be hinted at by the error.
Hi @smitty1e,
The raster analysis tools, such as Calculate Distance, are portal tool and are only available to you when you are signed into an ArcGIS Enterprise portal that has an ArcGIS Image Server configured for Raster Analysis.
When the tool is invoked, ArcGIS Pro serves as a client and the processing occurs in the servers federated with ArcGIS Enterprise. The portal tool accepts layers from your portal as input and creates output in your portal.
The input raster layer supports a layer from the portal, a URI or URL to an image service, or the output from the Make Image Server Layer tool. The input feature layer can be a layer from the portal or a URI or URL to a feature service. This tool does not support local raster data or layers. While you can use local feature data and layers as input to this portal tool, best practice is to use layers from your portal as input.
From your scripting error I think you may not be meeting one of the criteria I mention above.
Also, I'm not sure why you are running Euclidean Distance in the Pro Application first?
If you are trying to get a code snippit you can run Calculate Distance from inside the Pro Application. In Pro if you log into your Portal and have the correct setup and licenses to use Raster Analysis, you are able to access Calculate Distance from in the Pro Application. You can access this tool in 2 places:
1) In the Geoprocessing pane, in the search bar type the name of the tool. (Or in the Geoprocessing pane next to Toolboxes, it says Portal. Click Portal and you can see Raster Analysis Tools toolset, and in there is the Use Proximity (Legacy) toolset.
2) On the Analysis Ribbon --> Raster Analytics
After you run Calculate Distance in Pro you can go to the history, right click the successfully run tool and select Copy Python Command, then use this command in your script- if your script is setup to access Portal.
Also, I suggest that you use Distance Accumulation, instead of Calculate Distance. Calculate Distance is part of a Legacy toolset.
I hope you find this information helpful,
Liz Graham
Spatial Analyst Product Engineer
@smitty1e, your connection, https://smitty-gmu.maps.arcgis.com/home/index.html, is not to a Portal Enterprise, it is to ArcGIS Online. For your script to run you need to be connected to an ArcGIS Enterprise portal that has an ArcGIS Image Server configured for Raster Analysis.