How can I download a Feature Layer from my AGO account using the Python API

1309
4
Jump to solution
08-29-2018 04:36 PM
deleted-user-4LjGx0CueIPn
New Contributor II

Hello everyone,

I am trying to download a feature layer from my AGO enterprise account as a shapefile or CSV. I have the following code:

item_id = select_item.id

agolItem = gis.content.get(item_id)

outputGDB = extract_data([agolItem], data_format='Shapefile')

this code gives me the following error:

{"messageCode": "AO_100026", "message": "ExtractData failed."} Failed to execute (ExtractData). Failed.

I read a few other post just like mine but I couldn't figure out why I keep getting an error. 

Thank you 
0 Kudos
1 Solution

Accepted Solutions
simoxu
by MVP Regular Contributor
MVP Regular Contributor

The following code works for me, and my environment is Python API version 1.5.0

 

from arcgis.gis import GIS
from arcgis import extract_data

gis=GIS(profile="agol_simoprofile")

# test_item is a feature service item
test_item=gis.content.get("<my item id>")

result=extract_data(test_item.layers,output_name="test_extract_data"
                    ,data_format="SHAPEFILE")
result

View solution in original post

4 Replies
simoxu
by MVP Regular Contributor
MVP Regular Contributor

The following code works for me, and my environment is Python API version 1.5.0

 

from arcgis.gis import GIS
from arcgis import extract_data

gis=GIS(profile="agol_simoprofile")

# test_item is a feature service item
test_item=gis.content.get("<my item id>")

result=extract_data(test_item.layers,output_name="test_extract_data"
                    ,data_format="SHAPEFILE")
result
AzinSharaf
Occasional Contributor II

hi @simoxu 

exports_data() exports data in AGO not on local disk. Do you know any way that I can download the secured feature layer directly to the disk?

 

0 Kudos
deleted-user-4LjGx0CueIPn
New Contributor II

Simo,

I tried the code you provided me and it works perfectly. 

Thank you so much! 

simoxu
by MVP Regular Contributor
MVP Regular Contributor

Not problem  

0 Kudos