<?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 [Python] download feature service from AGOL to folder in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-download-feature-service-from-agol-to/m-p/1080465#M61815</link>
    <description>&lt;P&gt;Using Python I am would like to take files from agol and download them onto my laptop as shapefile.&amp;nbsp; Does anyone have code that they could share with me?&amp;nbsp; I am new to python&lt;/P&gt;</description>
    <pubDate>Mon, 19 Jul 2021 19:29:45 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-07-19T19:29:45Z</dc:date>
    <item>
      <title>[Python] download feature service from AGOL to folder</title>
      <link>https://community.esri.com/t5/python-questions/python-download-feature-service-from-agol-to/m-p/1080465#M61815</link>
      <description>&lt;P&gt;Using Python I am would like to take files from agol and download them onto my laptop as shapefile.&amp;nbsp; Does anyone have code that they could share with me?&amp;nbsp; I am new to python&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 19:29:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-download-feature-service-from-agol-to/m-p/1080465#M61815</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-07-19T19:29:45Z</dc:date>
    </item>
    <item>
      <title>Re: [Python] download feature service from AGOL to folder</title>
      <link>https://community.esri.com/t5/python-questions/python-download-feature-service-from-agol-to/m-p/1080485#M61816</link>
      <description>&lt;P&gt;Here's an example using the gis module:&lt;/P&gt;&lt;P&gt;How can I export a Feature Layer in AGOL to Shapefile, using API for Python?&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-api-for-python-questions/how-can-i-export-a-feature-layer-in-agol-to/td-p/781687" target="_blank"&gt;https://community.esri.com/t5/arcgis-api-for-python-questions/how-can-i-export-a-feature-layer-in-agol-to/td-p/781687&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jul 2021 20:22:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-download-feature-service-from-agol-to/m-p/1080485#M61816</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-07-19T20:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: [Python] download feature service from AGOL to folder</title>
      <link>https://community.esri.com/t5/python-questions/python-download-feature-service-from-agol-to/m-p/1080715#M61822</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;There is a useful code sample in the following link showing how to download all items owned by a particular user -&amp;nbsp;&lt;A href="https://support.esri.com/en/technical-article/000018909" target="_blank"&gt;How To: Download feature service items from ArcGIS Online using ArcGIS API for Python (esri.com):&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcgis
from arcgis.gis import GIS

gis = GIS(None,'username', 'password', verify_cert=False)

# Download all data from a user
def downloadUserItems(owner, downloadFormat):
    try:
        # Search items by username
        items = gis.content.search('owner:{0}'.format(owner))
        print(items)
        # Loop through each item and if equal to Feature service then download it
        for item in items:
            if item.type == 'Feature Service':
                result = item.export('sample {}'.format(item.title), downloadFormat)
                result.download(r'file path of where to store the download')
                # Delete the item after it downloads to save on space
                result.delete()
    except Exception as e:
        print(e)


# Function takes in two parameters. Username and the type of download format
downloadUserItems('username', downloadFormat='Shapefile')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Alternatively, if you have access to arcpy you could use the Feature Class to Feature Class tool -&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/conversion/feature-class-to-feature-class.htm" target="_blank"&gt;Feature Class To Feature Class (Conversion)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Finally, the following post may also be of use -&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-api-for-python-questions/downloading-agol-feature-as-excel-file-and/m-p/1035323/highlight/true#M5697" target="_blank"&gt;Solved: Re: Downloading AGOL feature as Excel file and sha... - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Hamish&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jul 2021 07:48:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-download-feature-service-from-agol-to/m-p/1080715#M61822</guid>
      <dc:creator>HamishMorton</dc:creator>
      <dc:date>2021-07-20T07:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: [Python] download feature service from AGOL to folder</title>
      <link>https://community.esri.com/t5/python-questions/python-download-feature-service-from-agol-to/m-p/1361053#M69413</link>
      <description>&lt;P&gt;Hi, I posted an error when I tried the code sample from &lt;A href="https://support.esri.com/en/technical-article/000018909" target="_blank" rel="nofollow noopener noreferrer"&gt;How To: Download feature service items from ArcGIS Online using ArcGIS API for Python (esri.com):&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# define the download format and the specified output path

# path = my_test_path ## changed for forum post 

def downloadUserItems(owner, downloadFormat):

    try:

        # Search items by username

#         items = gis.content.search('owner:{0}'.format(owner))

#         print(items)

        # search items by group

        group = gis.groups.search("title:ArcGIS API Test", max_groups=15)[0]

        items = group.content()

        print(items)

        # Loop through each item and if equal to Feature service then download it

        for item in items:

            print(item.type)

           # if item.type in ['Feature Service', 'Vector Tile Service', 'Scene Service']:                

            result = item.export('sample {}'.format(item.title), downloadFormat, wait =True)

            result.download(path)

            # Delete the item after it downloads to save space (OPTIONAL)

           # result.delete()

            print("Exported item: {}".format(result))

    except Exception as e:

        print(e)

# Function takes in two parameters. Username and the type of download format
downloadUserItems('dsfgis', downloadFormat='Shapefile')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;And I get this error:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;[&amp;lt;Item title:"Storm_Feature" type:Feature Layer Collection owner:dsfgis&amp;gt;]
Feature Service
Could not export item.&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Your help/insights would be appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 19:04:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-download-feature-service-from-agol-to/m-p/1361053#M69413</guid>
      <dc:creator>WillemVan_Riet1</dc:creator>
      <dc:date>2023-12-14T19:04:26Z</dc:date>
    </item>
  </channel>
</rss>

