Select to view content in your preferred language

Editing a Hosted Feature Service with Python

3488
1
11-06-2013 06:47 AM
JohnFannon
Frequent Contributor
Hi

I am trying to arrive at a methodology that will allow us to edit features (actually download and then delete) from a hosted feature service in ArcGIS Online using a scheduled python script. After some browsing the forums I see some solutions that use highly customised methods to call the REST api etc. However, what I can looking for is a method that uses arcpy and not lots of custom code.

In ArcGIS 10.1, if I sign in to ArcGIS Online and add the feature service to an ArcMap document, then I can open a cursor (either arcpy.searchcursor or arcpy.da.searchcursor) on a layer in the feature service in the command line window and access the rows (features).

For Example:

featCur = arcpy.SearchCursor(r"myFeatureServiceLayerName")
for feat in featCur:
  print str(feat.getValue("OBJECTID"))


This seems to be close to being the correct solution. However, if I save the layer in the mxd to a layer file and try to open a cursor from outside ArcMap (i.e. in ArcCatalog command line) by using the layer file as input, I get the following error:

ERROR 999999: Error executing function.
Authentication token required.


This occurs whether or not I am signed in to ArcGIS Online.

Has anyone managed to get a similar script working with an online feature service? I cannot be the first person to want to script the download/update of features from a hosted feature service.

Any pointers most appreciated.

Regards

John
Tags (2)
0 Kudos
1 Reply
by Anonymous User
Not applicable
Hi John,

I haven't coded a solution to this, but thought this might help. There are some tools in the Geoprocessing tools for Hadoop that convert 'features to json' and 'json to features'. You could use this to exchange the actual data.

Hope that helps,
Andrew
0 Kudos