Using item.export arcgis.gis module — arcgis 1.4.2 documentation I'm able to download data to a zip file from a feature service like this (I''m the item owner and an admin on the site):
from arcgis.gis import *
gis = GIS(username="user_name", password="password")
data_item_id = "abcde12345"
data_item = gis.content.get(data_item_id)
output_file = data_item.export(title=data_item_id,export_format="Shapefile",wait=True)
output_file.download(save_path = "D:\\temp\\data\\")
The documentation states: "Available only to users with an organizational subscription. Invokable only by the service item owner or an administrator."
How do I export data from a public feature service item available from an organization of which I am not a member? The data are available from an Open Data site and I can choose 'Download' using the web page but how do I export the data using the Python API? I have a number of items I would like to download.
Thank you for any help. I'm stuck.
There are 3 functions that I can think of in response to your question: export, download and create replica.
1. If you want to use export, you need to be a named user. by default, you can only download your own items or others' items in your organisation if you have the administrator privilege, it is also possible to export others' item if they "allow others to export to different formats". But anyway, I don't think you can export the items in another organisation if you are not a part of that organisation. It sort of make sense that you only can export when you are inside of an org, and when you are outside of an org, you can only "import" its items ...
2. You can download items if they are downloadable, for example, shape files, all sorts of packages (layer, project...), etc.
3. The last one is my favorite, replica. you can checkout feature layers in different formats by creating a replica if the sync is enabled by the service owner. here is an ESRI example how to do it.
Thank you for that information simo. I'll dig into the replica function a bit and see what I can come up with.
#2 (download) sounds like it would work well for my needs. But, I can't seem to get it to work for a feature service item. For example, how do you download the shapefile for this item: https://data-nctcoggis.opendata.arcgis.com/datasets/1990-census-block-groups
I can get properties like the item title and item type and I can download the metadata. On the item page (https://data-nctcoggis.opendata.arcgis.com/datasets/1990-census-block-groups) I can select Download > Shapefile. How do I download the shapfile for this item using the API?
No worries Bruce.
Although the open data website provides download function on the interface but it does not provide an API for people who want to do it programmatically.
Why not use the service as a direct datasource? you can query it using "http://gis4.dfwmaps.com/arcgis/rest/services/rdc/rdc_Census/MapServer/14/query?outFields=*&where=1%3... " , and with the query it is completely possible to create a shapefile using ArcPy if you really need it.