Select to view content in your preferred language

Use python to download hosted feature layer as geodatabase?

4531
8
09-08-2020 03:25 PM
KevinBracy_Knight1
New Contributor

Hi there, 

I have been using a script to extract attachments (photos) from a geodatabase and place them into folders named based on a field. However, these data "begin their lives" as attachments on a hosted feature layer on AGOL. Is there a script to automate the conversion of a hosted feature layer to FGDB and download it from AGOL? This would allow me to schedule and automate the entire process (which would be simply smashing!). Can anyone help me out?

Thanks,

Kevin Knight

0 Kudos
8 Replies
by Anonymous User
Not applicable

Hi Kevin, this Esri Support KB article should provide a good start: How To: Back up hosted content by looping through and downloading hosted feature services in FGDB fo... 

Hope this helps,

-Peter

0 Kudos
AFackler_NAPSG
Frequent Contributor

Hi Peter,

I ran into this article and tried it out on my end, but I am having issues with the layers downloading onto my machine. I got it to at least export the data and commented out the delete line to make sure they export, but I can't figure out what I'm doing wrong to have it download locally.  Do you have any guidance? 

0 Kudos
by Anonymous User
Not applicable

Hi @AFackler_NAPSG -  what is the error message returned? 

I would use a print statement on your path to make sure it's going to an actual location on your machine - additionally, are you running this locally in an ArcGIS Pro Python environment?

Thanks,

-Peter 

0 Kudos
AFackler_NAPSG
Frequent Contributor

Peter-

I was running it on PyCharm, but after running it on the Acrpy environment in Pro I was able to download the data locally. Thanks!

0 Kudos
Henry_PeleshBW
Regular Contributor

Hi Peter, I am running into this same issue. My folder path is correct, but the content does not download to my folder location. I am running this on ArcGIS Notebook within our ArcGIS Online Organization. I am assuming the Notebook can't access or understand my local machine folder path. Any advice to make this work?

Thanks,

Henry

0 Kudos
DianaKalil
Esri Contributor

Is there a chance for you to try it in a Jupyter notebook? As you stated, I think that ArcGIS Online Notebooks don't have access to overwriting local files. The code posted here works on Jupyter https://support.esri.com/en/technical-article/000022524, kindly let me know if it works.

0 Kudos
ChuckWerstak1
Emerging Contributor

Hi Peter,

I came across this Esri Support KB article and was wondering if there would be a way to modify it to download hosted feature services that are part of an Organization? 

Thoughts?

Thanks,

Chuck

 

0 Kudos
by Anonymous User
Not applicable

Hi @ChuckWerstak1 - absolutely. You will just need to modify the search query to create a list of items in your organization. This will just look like items = gis.content.search(query='') as the search is limited to only your organization by default. This great article by my colleague goes over the different options for searching for content with the API for Python. 

0 Kudos