<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to access layer using feature service URL/path in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-access-layer-using-feature-service-url-path/m-p/1333400#M9067</link>
    <description>&lt;P&gt;I tried that. Similar issue. I can access the layer but not the table.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;feature_service_item = arcgis.features.FeatureLayer('https://maps.url.com/arcgis/rest/services/Hosted/FL/FeatureServer')
print(feature_service_item)

sdf = pd.DataFrame.spatial.from_layer(feature_service_item)&lt;/LI-CODE&gt;&lt;P&gt;Returns&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Exception: Could not load the dataset: Cannot perform query. Invalid query parameters.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Sep 2023 15:16:05 GMT</pubDate>
    <dc:creator>ZacharyKasson</dc:creator>
    <dc:date>2023-09-28T15:16:05Z</dc:date>
    <item>
      <title>How to access layer using feature service URL/path</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-access-layer-using-feature-service-url-path/m-p/1333206#M9058</link>
      <description>&lt;P&gt;Hey there,&lt;/P&gt;&lt;P&gt;I am trying to access a feature layer within my portal using the layers path. I have been accessing the data within visual studio code using the feature layers ID like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;feature_service_layer = gis.content.get('964b4b7b112347e9ff76609bfc75432').layers[0]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to make a Geo Processing tool out of the code. The tool would accept the parameter under the format of&amp;nbsp; the URL which would be something along the lines of:&amp;nbsp; '&lt;A href="https://maps.hamptonlumber.com/arcgis/rest/services/Hosted/Feature" target="_blank" rel="noopener"&gt;https://maps.portaladdress.com/arcgis/rest/services/Hosted/Feature_layer&lt;/A&gt;/FeatureServer/0'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried to add the url to the code but it is unsuccessful. Here is what it looked like (I also tried the .Search method):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;feature_service_layer = gis.content.get(https://maps.portaladdress.com/arcgis/rest/services/Hosted/Feature_layer/FeatureServer/0)

feature_service_layer = gis.content.search(https://maps.portaladdress.com/arcgis/rest/services/Hosted/Feature_layer/FeatureServer/0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I can't use these methods how am I supposed to take a feature layer in as a parameter and access its data?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2023 00:10:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-access-layer-using-feature-service-url-path/m-p/1333206#M9058</guid>
      <dc:creator>ZacharyKasson</dc:creator>
      <dc:date>2023-09-28T00:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to access layer using feature service URL/path</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-access-layer-using-feature-service-url-path/m-p/1333210#M9059</link>
      <description>&lt;P&gt;Update,&lt;/P&gt;&lt;P&gt;I have found that this actually does work :&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;feature_service_layer = gis.content.search('https://maps.portal.com/arcgis/rest/services/Hosted/feature_layer/FeatureServer')&lt;/LI-CODE&gt;&lt;P&gt;But it gives me the content as a a list which has proven hard to get to a sdf.&lt;/P&gt;&lt;P&gt;I tried :&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sdf = pd.DataFrame.spatial.from_layer(feature_service_layer[0])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;but received this error:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Traceback (most recent call last):
  File "y:\Zack\Other_Projects\Python_projects\Duplicate Stand ID Tool\id_duplicate_tool_featureservice.py", line 33, in &amp;lt;module&amp;gt;
    sdf = pd.DataFrame.spatial.from_layer(feature_service_layer[0])
  File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\features\geo\_accessor.py", line 3077, in from_layer
    raise Exception("Could not load the dataset: %s" % str(e))
Exception: Could not load the dataset: 'Item' object has no attribute 'filter'
PS Y:\Zack\Other_Projects\Python_projects\Duplicate Stand ID Tool&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 28 Sep 2023 00:17:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-access-layer-using-feature-service-url-path/m-p/1333210#M9059</guid>
      <dc:creator>ZacharyKasson</dc:creator>
      <dc:date>2023-09-28T00:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to access layer using feature service URL/path</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-access-layer-using-feature-service-url-path/m-p/1333353#M9065</link>
      <description>&lt;P&gt;Have you considered just using FeatureLayer? If you know ahead of time what the URL is, you don't have to search for it.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;from arcgis import GIS
from arcgis.features import FeatureLayer

gis = GIS()
url = "https://urlforlayer/0"
fl = FeatureLayer(url, gis)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 28 Sep 2023 14:09:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-access-layer-using-feature-service-url-path/m-p/1333353#M9065</guid>
      <dc:creator>EarlMedina</dc:creator>
      <dc:date>2023-09-28T14:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to access layer using feature service URL/path</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-access-layer-using-feature-service-url-path/m-p/1333400#M9067</link>
      <description>&lt;P&gt;I tried that. Similar issue. I can access the layer but not the table.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;feature_service_item = arcgis.features.FeatureLayer('https://maps.url.com/arcgis/rest/services/Hosted/FL/FeatureServer')
print(feature_service_item)

sdf = pd.DataFrame.spatial.from_layer(feature_service_item)&lt;/LI-CODE&gt;&lt;P&gt;Returns&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Exception: Could not load the dataset: Cannot perform query. Invalid query parameters.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Sep 2023 15:16:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-access-layer-using-feature-service-url-path/m-p/1333400#M9067</guid>
      <dc:creator>ZacharyKasson</dc:creator>
      <dc:date>2023-09-28T15:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to access layer using feature service URL/path</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-access-layer-using-feature-service-url-path/m-p/1394641#M9753</link>
      <description>&lt;P&gt;Hi, there is a section on the site &lt;A href="https://developers.arcgis.com/python/api-reference/arcgis.features.toc.html#featurelayercollection" target="_self"&gt;featurelayercollection&lt;/A&gt;&amp;nbsp;, that will solve your problem.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;You already know the url of the feature service and login credentials&lt;/P&gt;&lt;LI-CODE lang="python"&gt;url = 'https://maps.portaladdress.com/arcgis/rest/services/Hosted/Feature_layer/FeatureServer'
portalUrl = 'https://maps.portaladdress.com/portal/'
portalUser = 'portaladmin'
portalPassw = 'xxxxxxxxxx'&lt;/LI-CODE&gt;&lt;P&gt;GIS login&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
gisP = GIS(portalUrl, portalUser, portalPassw)&lt;/LI-CODE&gt;&lt;P&gt;and you have access to layers and tables in the feature service&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.features import FeatureLayerCollection
flc=FeatureLayerCollection(url, gisP)
print(flc.layers) # or flc.tables&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;and you can continue processing&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for item in flc:
   print(item.url)
   ...&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 12 Mar 2024 14:00:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-access-layer-using-feature-service-url-path/m-p/1394641#M9753</guid>
      <dc:creator>maile</dc:creator>
      <dc:date>2024-03-12T14:00:22Z</dc:date>
    </item>
  </channel>
</rss>

