Hy guys, is there any way to use the select by location tool (via python) but using layer URL not layer name
eg: arcpy.SelectLayerByLocation_management(URL layer1"CROSSED_BY_THE_OUTLINE_OF",URL layer2,"","ADD_TO_SELECTION")
also I want to use searchCursor and updateCursor using Layer URL not layer name
I mean by URL, the REST URL of my layer service on arcgis online
I am using ArcGis Pro
With arcpy in arcgis pro
using the api for python
no mention of url's though
Take a look at an earlier post of mine : Using arcpy to copy a portal feature service to a fgdb feature class
In it, Joshua Bixby provides me with a solution that I got to work to downloade a feature in a hosted feature layer to a local file gdb. He may be able to provide a bit more insight to your specific quest. I too have a need to use arcpy functions like arcpy.ListFields() on a hosted feature service; it would be nice to use cursors as well.
Dan Patterson : if it ain't one new thing it's another: arcade one day, python api the next...
This can all be done using ArcPy. Just use Make Feature Layer—Data Management toolbox | Documentation to make a layer first and then run your selection against it. If you are running a standalone script outside of ArcGIS Pro, use SignInToPortal—ArcPy Functions | Documentation to authenticate your Python session first.
This morning I was able to use arcpy commands easily by simply referring to a feature layer's url:
fc = r'https://www.my.org/gisfed/rest/services/###/FeatureServer/9'
for f in arcpy.ListFields(fc):
with arcpy.da.SearchCursor(fc,'*') as cursor:
for row in cursor:
# both work as expected from a spyder console...