7

How can one export an attachment enabled feature service from ArcGIS Online and maintain it's integrity, meaning: get the geometry, table values, attachments, and the relationship class which connects them?

The route of "Open in desktop" > select layer > Data > Export only saves the geometry and table values. Ditto for Feature Class to Feature Class tool.

2
  • this is the hosted version of Exporting arcgis features with attachments Commented Jun 17, 2014 at 21:51
  • argh! must get more sleep. Please ignore dupe flag. This Q is about just exporting, which works. The other one is about exporting and exploding so it can be used by other means besides Esri. I will update it accordingly soon. Commented Jan 19, 2015 at 22:52

3 Answers 3

6

Here is the solution I found, I don't know if it's the best (it would be nice to capture symbology as well), but it does work and is straightforward. It's possible to grab a feature service and attachments and relationship class all in go from the server itself in a file-gdb. Esri has updated the export tools. There are now two official routes that I'm aware of for exporting feature service data with attachments.

As a normal user

Navigate to the feature service's main about page (http://arcgis.com/home/item.html?id=xxx123456xxx), and use the [Export] link at right side, select FGDB for output format, and you're done. (If the export link is missing, [Edit] and check the Export Data box first.)

Export drop down menu

Interactively via API

Point browser to http://services.arcgis.com/{xxx123456xxx}/arcgis/rest/services/{folder_name}/FeatureServer//createReplica

Set values to the below, unlisted items can just use default. Click on the resultant “statusURL”, and then “Result Url”, save zip file in wherever and extract a file-gdb with everything intact (except symbology).

Replica Name                  some_meaningful_name
Layers                        0,3 (select by index number)
Return Attachments            TRUE
Return Attachments by Url     TRUE
Create Replica Asynchronously TRUE
Sync                          None
Data Format                   FileGDB

For interest, I also found a script to this the hard way, extracting records and attachments individually and recreating locally; see AGO_PullHostedFeatures.py by Owen Evans.

1

Follow this: http://support.esri.com/en/knowledgebase/techarticles/detail/43333

It is exactly what you need. I ran into this issue recently and this was the solution provided.

3
  • Hi Stella, thank you for you contribution. However this is the same recipe as the existing answer gis.stackexchange.com/a/102360/108. It's good to have the link to the Kb article though, I encourage you to add it as a comment to the answer. Also a general note: link only answers are discouraged. The key points of the destination page need to be included for context. Sooner or later the link is broken and then it doesn't help anyone. Commented Dec 23, 2015 at 20:54
  • You're right, I guess I was just in a hurry.
    – Stella
    Commented Dec 29, 2015 at 23:57
  • No worries, we all are from time to time (plenty of my own rushed and incomplete answers are in evidence without much search work...). Preventing mistakes is a hopeless exercise, it's how we respond when they happen that makes the difference. Commented Jan 4, 2016 at 17:42
0

I know this is an old post, but I have a way to do this from any REST FeatureService that has Sync enabled. First you would need to download my restapi package on GitHub and you could run the following code:

import restapi
import json

url = 'http://yourServer.com/arcgis/rest/services/Folder/Colorado_Webmap_REST/FeatureServer'
fs = restapi.FeatureService(url) # can add username and password if secured

# test with where clause, grab only photos in Buena Vista, CO (can also add geometry filter)
where = json.dumps({"0": {"where": "City = 'BUENA VISTA'"}})
rep = fs.createReplica(0, 'Colorado', layerQueries=where) #zero is layer index, can also go by layer name

# export restapi.Replica() object to file geodatabase 
out = r'C:\TEMP\ReplicaTest' #directory for new file geodatabase 
restapi.exportReplica(rep, out)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.