<?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 Why can't I use a FeatureLayer object directly in arcpy? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/why-can-t-i-use-a-featurelayer-object-directly-in/m-p/782943#M1268</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to use some arcpy tools in Jupyter Notebooks but it doesn't appear as though I can use a FeatureLayer object as an input. Here is an example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I obtain my feature layer by getting the feature collection using the item id and then calling the first (and only in this case) layer. This returns a FeatureLayer object. I can easily find the fields as follows:&lt;/P&gt;&lt;P&gt;&lt;IMG class="jive-image image-4" src="https://community.esri.com/legacyfs/online/436406_pastedImage_6.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, when I use the arcpy equivalent function it tells me that &lt;/P&gt;&lt;P&gt;&lt;SPAN class="" style="font-weight: bold;"&gt;OSError&lt;/SPAN&gt;: "&amp;lt;FeatureLayer url:"https://services8.arcgis.com/.../FeatureServer/0"&amp;gt;" does not exist"&lt;BR /&gt;even though it actually does.&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/436403_pastedImage_3.png" /&gt;&lt;/P&gt;&lt;P&gt;Interestingly when I pass the FeatureLayer object's URL in it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-3 jive-image" src="https://community.esri.com/legacyfs/online/436404_pastedImage_4.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone explain why I can't use the FeatureLayer object directly or what the difference is?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Feb 2019 19:59:05 GMT</pubDate>
    <dc:creator>BenjaminSperry1</dc:creator>
    <dc:date>2019-02-01T19:59:05Z</dc:date>
    <item>
      <title>Why can't I use a FeatureLayer object directly in arcpy?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/why-can-t-i-use-a-featurelayer-object-directly-in/m-p/782943#M1268</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to use some arcpy tools in Jupyter Notebooks but it doesn't appear as though I can use a FeatureLayer object as an input. Here is an example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I obtain my feature layer by getting the feature collection using the item id and then calling the first (and only in this case) layer. This returns a FeatureLayer object. I can easily find the fields as follows:&lt;/P&gt;&lt;P&gt;&lt;IMG class="jive-image image-4" src="https://community.esri.com/legacyfs/online/436406_pastedImage_6.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, when I use the arcpy equivalent function it tells me that &lt;/P&gt;&lt;P&gt;&lt;SPAN class="" style="font-weight: bold;"&gt;OSError&lt;/SPAN&gt;: "&amp;lt;FeatureLayer url:"https://services8.arcgis.com/.../FeatureServer/0"&amp;gt;" does not exist"&lt;BR /&gt;even though it actually does.&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/436403_pastedImage_3.png" /&gt;&lt;/P&gt;&lt;P&gt;Interestingly when I pass the FeatureLayer object's URL in it works.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-3 jive-image" src="https://community.esri.com/legacyfs/online/436404_pastedImage_4.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone explain why I can't use the FeatureLayer object directly or what the difference is?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2019 19:59:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/why-can-t-i-use-a-featurelayer-object-directly-in/m-p/782943#M1268</guid>
      <dc:creator>BenjaminSperry1</dc:creator>
      <dc:date>2019-02-01T19:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why can't I use a FeatureLayer object directly in arcpy?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/why-can-t-i-use-a-featurelayer-object-directly-in/m-p/782944#M1269</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&amp;nbsp;Benjamin,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it is because arcpy.ListFields is expecting a &lt;STRONG&gt;string&lt;/STRONG&gt; type and not an &lt;STRONG&gt;object&lt;/STRONG&gt; type for the first parameter according to the &lt;A href="http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-functions/listfields.htm"&gt;documentation&lt;/A&gt;. This would make sense why &lt;EM&gt;feature_layer.url&lt;/EM&gt; works because that would be a string.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Feb 2019 20:50:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/why-can-t-i-use-a-featurelayer-object-directly-in/m-p/782944#M1269</guid>
      <dc:creator>MunachisoOgbuchiekwe</dc:creator>
      <dc:date>2019-02-01T20:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why can't I use a FeatureLayer object directly in arcpy?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/why-can-t-i-use-a-featurelayer-object-directly-in/m-p/782945#M1270</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Honestly, I am surprised &lt;SPAN style="font-family: courier new, courier, monospace;"&gt;arcpy.ListFields()&lt;/SPAN&gt; works at all in this case.&amp;nbsp; FeatureLayer is an ArcGIS API for Python object, not ArcPy, and the interchange/translation between the two APIs doesn't always work, even when the objects share the same name (see &lt;A href="https://community.esri.com/thread/211220" target="_blank"&gt;arcgis...FeatureSet != arcpy...FeatureSet&lt;/A&gt; ).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The way to print field names using only the ArcGIS API for Python, which I suggest for stability and portability, is:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;field_list &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; feature_layer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;properties&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;fields
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; f &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; field_list&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;f&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:55:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/why-can-t-i-use-a-featurelayer-object-directly-in/m-p/782945#M1270</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-12T08:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why can't I use a FeatureLayer object directly in arcpy?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/why-can-t-i-use-a-featurelayer-object-directly-in/m-p/782946#M1271</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Munachiso, yes that appears to be the case. The integration of arcpy and the python api is proving more difficult that I thought it would be. Is there a place where I can find more information on how the two work together?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Feb 2019 13:50:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/why-can-t-i-use-a-featurelayer-object-directly-in/m-p/782946#M1271</guid>
      <dc:creator>BenjaminSperry1</dc:creator>
      <dc:date>2019-02-06T13:50:40Z</dc:date>
    </item>
    <item>
      <title>Re: Why can't I use a FeatureLayer object directly in arcpy?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/why-can-t-i-use-a-featurelayer-object-directly-in/m-p/782947#M1272</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Essentially, there isn't concrete information on how the two API's work together. In general, they are two separate products. ArcGIS API for Python, is supposed to be used for automation of your web GIS while ArcPy is used for automation of GIS workflows when using ArcMap or ArcGIS Pro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might get instances where you can use the two API's together and it works but you can't always rely on that since an object in&amp;nbsp;&lt;SPAN&gt;ArcGIS API for Python may not be the same in ArcPy and vise versa (as Joshua Bixby pointed out). &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Your best bet is to stick with one API. It looks like you are mostly doing Web GIS related workflows. So,&amp;nbsp;Joshua Bixby sample would get you the fields without using ArcPy.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Feb 2019 17:40:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/why-can-t-i-use-a-featurelayer-object-directly-in/m-p/782947#M1272</guid>
      <dc:creator>MunachisoOgbuchiekwe</dc:creator>
      <dc:date>2019-02-06T17:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Why can't I use a FeatureLayer object directly in arcpy?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/why-can-t-i-use-a-featurelayer-object-directly-in/m-p/782948#M1273</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks again Munachiso,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I am really trying to do is compensate for not having ArcGIS for Server and geoprocessing services. I need to run desktop caliber tools in a distributed web environment. I was hoping that this could be accomplished by using arcpy in conjunction with the python API. I get the sense from your's and Joshua's comments that it is not a natural thing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It would be handy if there was a reference that compared the two and outlined any possible touch points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I really appreciate your's and Joshua's insights.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Feb 2019 17:58:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/why-can-t-i-use-a-featurelayer-object-directly-in/m-p/782948#M1273</guid>
      <dc:creator>BenjaminSperry1</dc:creator>
      <dc:date>2019-02-06T17:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Why can't I use a FeatureLayer object directly in arcpy?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/why-can-t-i-use-a-featurelayer-object-directly-in/m-p/782949#M1274</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Searching though something entirely unrelated I found this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/441574_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;The .as_arcpy converts the features into features that can be used in arcpy. I haven't seen any official documentation on this anywhere but it seems to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a link to the reference &lt;A class="link-titled" href="https://developers.arcgis.com/python/guide/visualizing-data-with-the-spatially-enabled-dataframe/" title="https://developers.arcgis.com/python/guide/visualizing-data-with-the-spatially-enabled-dataframe/"&gt;visualizing data with the spatially enabled dataframe | ArcGIS for Developers&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Apr 2019 16:58:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/why-can-t-i-use-a-featurelayer-object-directly-in/m-p/782949#M1274</guid>
      <dc:creator>BenjaminSperry1</dc:creator>
      <dc:date>2019-04-09T16:58:08Z</dc:date>
    </item>
  </channel>
</rss>

