Select to view content in your preferred language

Queried feature layers as analysis input?

12-09-2019 08:42 AM
Regular Contributor

In this particular case I'm trying to use the arcgis.features.analysis module's join_features function using two feature layers I've applied queries to.

I'm using Jupyter Labs to work on this and I've not included the outputs/responses which the code does return successfully and the queried layers appear as expected in the ipython display.

from arcgis.gis import GIS
from arcgis.features import FeatureLayer #Not needed here
from IPython.display import display #Not needed here
from arcgis import features
gis = GIS("", "me", "m3LoG!!N")
print("Logged in as: " +

#Access feature layers
cruiseFeatureLayer ='title: NortheastCruisePoints', 'Feature Layer')
cruisePoints = cruiseFeatureLayer[0].layers[0]
print("Item ID:{0}".format(cruiseFeatureLayer[0].id))
print("Input Layer:{0}".format(

clientsFeatureLayer ='title: NortheastClientsCollector', item_type='Feature Layer')
clients = clientsFeatureLayer[0].layers[2]
print("Item ID:{0}".format(clientsFeatureLayer[0].id))
print("Input Layer:{0}".format(

#Query based on ClientID
clientQuery = clients.query(where="LVI_CODE ='7282'")
cruiseQuery = cruisePoints.query(where="LVI_CODE ='7282'")
print("{0} stands selected".format(len(clientQuery.features)))
print("{0} cruise points selected".format(len(cruiseQuery.features)))

#Review queried feature layers in ipython display [need to modify so queried layers are zoomed-to]
queryMap =
queryMap.extent = clientsFeatureLayer[0].extent

features.analysis.join_features(target_layer=clientQuery,join_layer=cruiseQuery, spatial_relationship='intersects')

Here is the error I get:

Exception: Invalid format of input layer. url string, feature service Item, feature service instance or dict supported

So does the analysis module only work for feature layers, not feature sets? Is there a way to supply a queried/filtered input to the analysis w/o having to create an entirely new item in your portal?

0 Kudos
0 Replies