I want to automate a workflow I have in ArcGIS Pro using arcpy.
I am running the Near tool against two secured Portal services within ArcGIS Pro. Everything works well when running it through ArcGIS Pro - I simply run the tool and it successfully updates the secured services.
When I try to automate it I copy the Python snippet for the tool. This is where I run into problems. Naturally within the ArcGIS Pro environment, the layer names have a context as they reference a specific layer (with defined definition queries) within a map within a project. When in an isolated Python environment this context is lost along with the Portal connection.
My question is how can I replicate these within a Python environment? I have seen URL's being used as tool inputs, but these don't honor the definition queries, nor do they take care of authentication.
Thanks for any suggestions and insight.
I suspect arcpy isn't the place for you. The arcgis module is for web stuff
ArcGIS API for Python | ArcGIS Developer for basic entry point
API Reference for the ArcGIS API for Python — arcgis 1.9 documentation api documentation
Esri/arcgis-python-api: Documentation and samples for ArcGIS API for Python (github.com) github site with example code in the Samples folder.
Thanks Dan - the ArcGIS API for Python analysis tools are pretty limited in comparison to arcpy. The Near tool does exactly what I want.
What I ended up doing was downloading the datasets I needed, running the analysis locally using arcpy, then converting the output to JSON, creating a feature set from that before adding it to the Feature Layer via the ArcGIS API for Python. Appending is not supported with our Enterprise version.
The limitation added complexity that I didn't initially consider, but I got there in the end! It would be great if arcpy could run on secured Feature Layers though - it would have simplified the flow quite a bit.