export hosted feature layer using python

12364
7
Jump to solution
07-12-2016 03:03 AM
BertKraan1
Occasional Contributor III

I would like to create a fgdb from a hosted feature layer automatically via a schedule or script and download that fgdb so I have a local copy, as a backup but also to update my local data.

Manually it's no problem to export to fgdb and download that file that but how can I automate it?

Preferrably using python. I suspect this might be possible using REST but I find/understand no leads to do this, help is appreciated, (you will be mentioned in the credits and we might send cookies :-))

Bert

Tags (1)
1 Solution

Accepted Solutions
BertKraan1
Occasional Contributor III

I 've found a solution for my problem using the create_replica_portal_item.py from GitHub - Esri/ArcREST: python package for REST API (AGS, AGOL, webmap JSON, etc..) ​.

Had to modify the script slightly (see comment at github) but now I can download what I want. When there are attachments they are downloaded too.

regards,

Bert

View solution in original post

7 Replies
JakeSkinner
Esri Esteemed Contributor
BertKraan1
Occasional Contributor III

Hello Jake,

Yes, I've seen and used your service before (and I am grateful you wrote it) but unfortunately it doesn't download the attachments in the database like it is on the online site. If I remember correct the attachments are send to a separate folder but this morning I could not even get any attachments to download using the toolbox (arcmap 10.3.1 for desktop, 10.3.1.4959, basic license). I retried after a fresh download of your tool but still no attachments ... The toolbox returns a message about 'no attachments found'.

It seems really strange to me that I am capable of manually exporting and downloading a filegeodatabase (in which I find all photo's with their relations) but that it is impossible to script that workflow.

Another thing I've tried is opening the hosted feature service in arcmap for desktop and 'create a local copy for editing' which took quite a while but also lacked the photo's/attachments.

0 Kudos
JakeSkinner
Esri Esteemed Contributor

The tool will store the attachments in the geodatabase.  It does download the attachments to a folder, but then creates them as geodatabase attachments afterwards.  Not sure why this tool isn't downloading the attachments, but after you stated that creating a local copy for editing didn't bring the attachments across either, it leads me to believe something is wrong with the service.

Another option you could do is download the data as a zip file.  Take a look at the following blog for more details:

How to Access Item Data Stored in ArcGIS Online or Portal with ArcGIS REST API

I haven't tested this, but you could use python to post the URL to create a zipped geodatabase, and then download this zip file.

0 Kudos
BertKraan1
Occasional Contributor III

Is it possible this tools doesn't download the attachments when used from a basic (arcview) license?

I ask because I've published a brand new feature layer using my basic licensed arcmap for desktop and after that I've enabled attachments in that layer in the agol desktop.

I am now able to add pictures in collector on my ipad and I see those pictures/attachments in the agol desktop.

I can also see them after dragging the feature service from "My Hosted Services" in the Catalog window to the toc.

But after 'create local copy for editing' I've got everything but the attachments so I wonder if technology is required for which i'm not licensed. No error message was seen, only:

Capture.JPG

It would be usefull to know whether or not we need to upgrade our license or investigate other tips shared in this thread.

thanks in advance for your time!

Bert

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Bert,

Yes you will need at least a ArcGIS Desktop Standard license to create attachments.  I will have to update the tool so that is first checks if the user is using a Standard license and then report an error is they are not.

BertKraan1
Occasional Contributor III

I 've found a solution for my problem using the create_replica_portal_item.py from GitHub - Esri/ArcREST: python package for REST API (AGS, AGOL, webmap JSON, etc..) ​.

Had to modify the script slightly (see comment at github) but now I can download what I want. When there are attachments they are downloaded too.

regards,

Bert