Hi,
I was trying to use the item's download method to download the data associated with a map image layer on Portal. But it doesn't seem to be able to download the data and I got b' ' as the output. I also tried the get_data method, which returns an error message saying "the JSON object must be str, not 'bytes'".
I did a similar workflow on a hosted feature layer on ArcGIS Online. And this time, it was able to download the item. But it only returns the data schema in a dictionary. Is there way to download the actual data behind a hosted feature service? Can the download method work with map image layers?
Or did I miss something here?
Thank you!
Ahjung Kim
You might want to consider creating a replica. However, this might be a premium service.
The arcgis package appears to support this functionality:
arcgis.features.managers module — arcgis 1.0.1 documentation
That was the answer I got from the Esri Support: create a replica. Below is the answer I got from the Esri Support. I tried it and was able to download with attachments. Thank you. Phil.
In terms of another way to download the data to file geodatabase, without consuming credits, you could create a replica using the Python API and then download. This is the programmatic equivalent of exporting to a file geodatabase from the Item Details page of a service, or creating a replica and manually entering paramters at the REST endpoint. You may want to test manually from the Item Details page first and ensure that it works there; if it doesn't it won't work programmatically either, and confirms our suspicion that there could be a data-specific problem.
Hi Ahjung Kim and Phil Larkin,
I was trying the same and I got a .zip with a filegdb, which was great!
However, the filename is 32 random characters long. In the above mentioned Python guide I find this code:
replica1 = ports_flc.replicas.create(replica_name = 'arcgis_python_api_2', layers='0', data_format='filegdb', out_path = 'E:\\demo')
replica1
Can I set the filename of the output-file? I was searching in the list of optional attributes in Phil's link, but all I found was this:
create
(replica_name, layers, layer_queries=None, geometry_filter=None, replica_sr=None, transport_type='esriTransportTypeUrl', return_attachments=False, return_attachments_databy_url=False, async=False, attachments_sync_direction='none', sync_model='none', data_format='json', replica_options=None, wait=False, out_path=None)
Did I miss this option?
Thanks in advance!
EDIT: To be clear: I mean the name of the .gdb in the resulting zip.
I think this is by the API design. When you create a replica, you need replica's ID needs to be unique so the system assigns global ID to each replica. If you leave naming to the humans, it's likely there will be errors and duplicate values will be generated. So the API doesn't want to expose that option. These are just my thoughts, you probably want to ask Esri staff
The replica_name parameter will only define the replica name on the server.
Would make sense. Still, I think it would be better if the name was for the gdb and you could still use unique-id's for references. Anyhow, I solved it with Python. Thanks for the response
I am trying to create a replica using the process in the link below. The reference says the feature layer needs to have the Extract capability. Mine doesn't, is there a setting I need to change on the item details page that will give the feature layer the Extract capability?
In terms of another way to download the data to file geodatabase, without consuming credits, you could create a replica using the Python API and then download. This is the programmatic equivalent of exporting to a file geodatabase from the Item Details page of a service, or creating a replica and manually entering paramters at the REST endpoint. You may want to test manually from the Item Details page first and ensure that it works there; if it doesn't it won't work programmatically either, and confirms our suspicion that there could be a data-specific problem.
Thanks,
Jeff
From the feature layer's setting's page, check "Allow others to export to different formats." I think this enables extract.
That was what I needed. I had actually done that before posting but I was using Jupyter Notebooks to run my script - I needed to run the previous cells to reload the variable I was checking.
Thanks for your help!
I have a hosted feature service in AGOL which contains multiple hosted feature layers and tables. I'd like to programmatically create backup for these data. In AGOL the layer export is configured enabled, so under each feature layer I can manually export each layer (or table) to another folder in AGOL, which is the desired output. For example: