Select to view content in your preferred language

Are updates to ArcGIS Online Open Data hosted feature services supported?

8719
12
Jump to solution
07-21-2014 04:04 PM
TimMinter
Frequent Contributor

I need to manage data as a geodatabase feature class within my employer's computing environment, and provide it for public discovery and access as an ArcGIS Online hosted feature service shared to our Open Data site.

Has anyone found a best or good practice for doing such a thing cleanly?

I was hoping to publish updated content by overwriting an existing hosted feature service because I could be sure to keep the URL to the service resource constant.  This plan does not work well with ArcGIS Online and Open Data because the item ID changes during the overwrite procedure and updating the URL for a hosted feature service item is not supported.  Overwriting the hosted feature service results in the URL remaining the same, but it breaks all of the Open Data item ID-based access to content (spreadsheet, KML, shapefile, API > GeoJSON, and Metadata) and therefore any web apps that expect the content to be available based on persistent URLs.

1 Solution

Accepted Solutions
TimMinter
Frequent Contributor

Thankfully, time continues to pass... and things continue to change.  I'm clicking the "Unmark as Correct" button on Scott's previously correct answer due to an "unsupported workflow" note during an open case with Esri technical support on a big bonk that happened the last time I tried to run the update script.

Now, the correct answer has become:

  • Use ArcMap 10.3 and maybe higher (but test first) to open the source MXD
  • File > Share As > Service > Overwrite an existing service
  • Note that at 10.3 this procedure does not cause the AGO FL(H) (ArcGIS Online Feature Layer (Hosted)) item to have a new item ID.  Therefore, this workflow does not bust any links one might have made to the Open Data item from things like FGDC metadata online resource tags, data catalogs, and such.

...and go ahead and script it up with Model Builder and/or Python.

View solution in original post

0 Kudos
12 Replies
ScottMoore__Olympia_
Esri Contributor

Hi Tim,

You can delete and append using the ArcREST python toolset.  It is downloadable from here: https://github.com/Esri/ArcREST/releases

Set it up using “setup.py install”

Then you can run something like this:

#

# Deletes all rows from feature layer

# Adds rows from local feature class

# to a hosted feature service

#

import arcrest

try:

url = "http://services.arcgis.com/2zRtyrQ6q4mGrLJK/arcgis/rest/services/Snotel_Sites/FeatureServer/0"

username = "YourUserName"

password = "YourPassword"

fl = arcrest.agol.layer.FeatureLayer(url=url,username=username,password=password)

print fl.deleteFeatures(where="1=1")

print 'all features removed'

fc = r"c:\temp\snotel.gdb\snotel"

features = arcrest.agol.common.Feature.fc_to_features(fc)

print fl.addFeature(features=features)

except ValueError, e:

print e

Here are some other simple samples using ArcREST: https://github.com/Esri/ArcREST/tree/master/samples

You can basically perform all CRUD operations on an existing host feature service using ArcREST as well as manipulate it's service definition (update fields, etc...).

I tested it with the above script and it worked well.

I hope that helps!

Scott

TimMinter
Frequent Contributor

Hi Scott,

Good info!  I can use this until enterprise geodatabase replication or similar out-of-the-box capabilities show up in the ArcGIS Platform for managing data locally and publishing in ArcGIS Online.

Thanks,

Tim

0 Kudos
JulieK
by
Regular Contributor

Hi Scott,

I tried your script against ArcREST2 and I get this below error:

fl = arcrest.agol.layer.FeatureLayer(url=url,username=username,password=password)

TypeError: __init__() got an unexpected keyword argument 'username'

any thoughts?

0 Kudos
ScottMoore__Olympia_
Esri Contributor

Hi Julie,

I believe that script uses the v1 of ArcREST.  Did you download ArcREST v2?  Here is the link to v1: Esri/ArcREST at October2014v1.0Final · GitHub

0 Kudos
JulieK
by
Regular Contributor

Hi Scott,

I downloaded and installed v1 and the script runs fine until deleting features. After printing 'All features removed', pythonw.exe stops working.

should I uninstall v2 first? Or is it something else? any thoughts?

0 Kudos
NickO_Day
Occasional Contributor

I'm trying to do the same thing but with the newer version of ArcREST (v. 3.0.1) and I keep getting a very vague error message.  From the samples provided from the github repo, I edited the delete_rows_from_service.py by adding my username, password, organization URL, AGOL item ID, etc.

This is the error:

error on line: 49

with error message: AttributeError: 'NoneType' object has no attribute 'starts with'

... and this is line 49:

fst = featureservicetools.featureservicetools(securityinfo)

Any ideas on how to solve this?  I'm using our AGOL admin account so I'm fairly certain it's not a permissions issue.

Thanks in advance everyone!

0 Kudos
TimMinter
Frequent Contributor

Here's an upcoming correct answer... hopefully

9/23/2014 ArcGIS Online Update

"Feature Layers

In the September update we plan to add an improved user experience for updating data in your ArcGIS Online-hosted feature layers. If you need to update data associated with your hosted feature layer, you will be able to update the layer through My Content and maintain the item URL and details."

0 Kudos
TimMinter
Frequent Contributor

Well, bummer.  Another GOTCHA.

After I opened a case regarding "Overwrite" not being available, "Overwrite hosted feature layers" documentation was updated yesterday to highlight that this capability only works if you publish the hosted feature layers by loading a file geodatabase or shapefile and choosing to create a feature layer at loading time.  However, the doc does not note (today) that if you published the hosted feature layer from ArcMap, that Overwrite is not provided as an option.  Today, that information may only be on this little post in the untraveled hinterlands of GeoNet.

Note that if you publish the hosted feature service from a file geodatabase so you can use Overwrite, then you lose metadata (e.g. description, copyright text, constraints, tags, display field, min/max scales, etc.) in the item and in the service catalog.  Also note that layer names are not generated from feature class aliases if you publish from file geodatabases.  And, I'm not seeing a way to specify max records returned.  Kind of a miss.

Since retaining and presenting service metadata when publishing from a file geodatabase is not supported and other capabilities are missing, Overwrite is of little use to organizations who have a requirement to make the metadata available at the service endpoint along with their Open Data offerings.

I'll have to stick with Scott's customization above until the file geodatabase publishing tools respect the GDB and feature class metadata.  Disappointing for our purposes. 

0 Kudos
TimMinter
Frequent Contributor

Time passes... things change.  Spotted this note today suggesting that maybe this situation has been improved.  It bears a little investigation, maybe!

Sign in to Esri's support system and search for BUG-000082504.  Suggests "Fixed"