I am looking to select/retrieve the polygon, based on a hosted layer, that contains a given point. The SelectLayerByLocation on my test works for local .gdb feature classes. I was not able to make it work using an online FeatureLayer. This is the error I get: RuntimeError: Object: Error in executing tool
I appreciate any ideas...
Here is a code example I have:
import arcpy
from arcgis.gis import GIS
from arcgis.features import FeatureLayer
gis = GIS()
#load online layer
CaLayer = FeatureLayer("https://services.arcgis.com/BLN4oKB0N1YSgvY8/arcgis/rest/services/Counties_in_California/FeatureServer/0", gis)
#verify the variable has content
print(CaLayer)
print(type(CaLayer))
print(CaLayer.properties.capabilities)
#create a point
point = arcpy.Point(-117.182, 34.055)
ptGeometry = arcpy.PointGeometry(point, arcpy.SpatialReference(4326))
#try to run SelectLayerByLocation
selection = arcpy.management.SelectLayerByLocation(CaLayer, "CONTAINS", ptGeometry)