Select to view content in your preferred language

extract_data sample

1249
2
12-30-2018 01:33 AM
LucasLew
New Contributor
  • I have a Hosted Feature service that I own and also have the Extract capability enabled.
  • Contains two layers, of which I want to download the first layer into a file geodatabase

I was hoping to find a sample that uses arcgis.extract_data

This post is similar, but looks like the op ended up using ArcPy.

Have tried a few things:

from arcgis.gis import GIS
from arcgis.features.manage_data import extract_data

gis = GIS("https://mydevplan.maps.arcgis.com/","un","pw")
waze_hfs_item = gis.content.get('5c80a03f09154b2bb845f986dce325cd')
waze_alerts_layer = waze_hfs_item.layers[0]  # REST Endpoint for layer returned


# outputGDB = arcgis.extract_data(['Alerts'])        # Exception: Job failed.
# outputGDB = arcgis.extract_data(waze_hfs_item)     # Exception: Job failed.
outputGDB = arcgis.extract_data(waze_alerts_layer)   # TypeError: 'FeatureLayer' object is not iterable‍‍‍‍‍‍‍‍‍‍‍

I believe all I really need to supply to extract_data is :

input_layers :Required list of strings

Was wondering if someone could point me to a working sample that leverages extract_data.  I am sure this is a simple one.

0 Kudos
2 Replies
LucasLew
New Contributor
outputFGDB = extract_data(waze_hfs_item.layers, output_name="Waze_Extract", data_format="FILEGEODATABASE")
outputFGDB.download('C:\\Workings\\waze_analysis')

The above works in downloading all of the layers from the hosted feature service to a shapefile.

  • I only want the first layer.  How can I achieve this?  waze_hfs_item.layers[0] throws an error.
  • Has anyone created a clean-up step to remove the new item from the portal after successfully downloading?

If I refer to the credits page:

What does not require service credits?

  • Exporting data stored in ArcGIS Online.

However, I can confirm that using extract_data does indeed use credits.  Is this a bug?

As we are doing this on a daily basis, using credits for exporting our data is not going to be feasible.  Was hoping to take the Extract path over using SYNC/CreateReplica.

0 Kudos
SimonJackson
Frequent Contributor

Using createreplica gets around the credits issue, but the service needs SYNC enabled (which has more overhead for publisher when compared to Extract).

replica = waze_flc.replicas.create(replica_name = 'Waze_Download',
                                   layers = '0',
                                   data_format = 'filegdb',
                                   out_path = './download')
0 Kudos