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.
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>gis <SPAN class="keyword token">import</SPAN> GIS
<SPAN class="keyword token">from</SPAN> arcgis<SPAN class="punctuation token">.</SPAN>features <SPAN class="keyword token">import</SPAN> FeatureLayer <SPAN class="comment token">#Not needed here</SPAN>
<SPAN class="keyword token">from</SPAN> IPython<SPAN class="punctuation token">.</SPAN>display <SPAN class="keyword token">import</SPAN> display <SPAN class="comment token">#Not needed here</SPAN>
<SPAN class="keyword token">from</SPAN> arcgis <SPAN class="keyword token">import</SPAN> features
gis <SPAN class="operator token">=</SPAN> GIS<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"https://amazingportal.com/portal"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"me"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"m3LoG!!N"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Logged in as: "</SPAN> <SPAN class="operator token">+</SPAN> gis<SPAN class="punctuation token">.</SPAN>properties<SPAN class="punctuation token">.</SPAN>user<SPAN class="punctuation token">.</SPAN>username<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#Access feature layers</SPAN>
cruiseFeatureLayer <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>search<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'title: NortheastCruisePoints'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'Feature Layer'</SPAN><SPAN class="punctuation token">)</SPAN>
cruisePoints <SPAN class="operator token">=</SPAN> cruiseFeatureLayer<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>layers<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Item ID:{0}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>cruiseFeatureLayer<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>id<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Input Layer:{0}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>cruisePoints<SPAN class="punctuation token">.</SPAN>properties<SPAN class="punctuation token">.</SPAN>name<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
cruisePoints
clientsFeatureLayer <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>content<SPAN class="punctuation token">.</SPAN>search<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'title: NortheastClientsCollector'</SPAN><SPAN class="punctuation token">,</SPAN> item_type<SPAN class="operator token">=</SPAN><SPAN class="string token">'Feature Layer'</SPAN><SPAN class="punctuation token">)</SPAN>
clients <SPAN class="operator token">=</SPAN> clientsFeatureLayer<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>layers<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Item ID:{0}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>clientsFeatureLayer<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>id<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Input Layer:{0}"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>clients<SPAN class="punctuation token">.</SPAN>properties<SPAN class="punctuation token">.</SPAN>name<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
clients
<SPAN class="comment token">#Query based on ClientID</SPAN>
clientQuery <SPAN class="operator token">=</SPAN> clients<SPAN class="punctuation token">.</SPAN>query<SPAN class="punctuation token">(</SPAN>where<SPAN class="operator token">=</SPAN><SPAN class="string token">"LVI_CODE ='7282'"</SPAN><SPAN class="punctuation token">)</SPAN>
cruiseQuery <SPAN class="operator token">=</SPAN> cruisePoints<SPAN class="punctuation token">.</SPAN>query<SPAN class="punctuation token">(</SPAN>where<SPAN class="operator token">=</SPAN><SPAN class="string token">"LVI_CODE ='7282'"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"{0} stands selected"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>clientQuery<SPAN class="punctuation token">.</SPAN>features<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="string token">"{0} cruise points selected"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>len<SPAN class="punctuation token">(</SPAN>cruiseQuery<SPAN class="punctuation token">.</SPAN>features<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#Review queried feature layers in ipython display [need to modify so queried layers are zoomed-to]</SPAN>
queryMap <SPAN class="operator token">=</SPAN> gis<SPAN class="punctuation token">.</SPAN>map<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
queryMap<SPAN class="punctuation token">.</SPAN>extent <SPAN class="operator token">=</SPAN> clientsFeatureLayer<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>extent
queryMap<SPAN class="punctuation token">.</SPAN>add_layer<SPAN class="punctuation token">(</SPAN>clientQuery<SPAN class="punctuation token">)</SPAN>
queryMap<SPAN class="punctuation token">.</SPAN>add_layer<SPAN class="punctuation token">(</SPAN>cruiseQuery<SPAN class="punctuation token">)</SPAN>
queryMap
features<SPAN class="punctuation token">.</SPAN>analysis<SPAN class="punctuation token">.</SPAN>join_features<SPAN class="punctuation token">(</SPAN>target_layer<SPAN class="operator token">=</SPAN>clientQuery<SPAN class="punctuation token">,</SPAN>join_layer<SPAN class="operator token">=</SPAN>cruiseQuery<SPAN class="punctuation token">,</SPAN> spatial_relationship<SPAN class="operator token">=</SPAN><SPAN class="string token">'intersects'</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Here is the error I get:
Exception<SPAN class="punctuation token">:</SPAN> Invalid format of input layer<SPAN class="punctuation token">.</SPAN> url string<SPAN class="punctuation token">,</SPAN> feature service Item<SPAN class="punctuation token">,</SPAN> feature service instance <SPAN class="operator token">or</SPAN> dict supported<SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
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?