For many of my clients purchasing and managing ArcGIS Server has been out of the question based on limited IT and GIS resources. So for years I’ve been testing hosted services that would allow them to get maps out to their customers via the web. None of them allowed for timely data updates to ever changing data however. So naturally when ArcGIS Online rolled out I had to take it for a spin to see how it might work.
My goal is to publish a map service to ArcGIS Online once and be able to update it through a simple console application that could be launched at some interval (hourly, daily, weekly).
In order to mimic a real world scenario as best I could (for a geo dev anyway) I created a fairly simple web map that shows recreation sites on top of a topo base map. Clicking on the map then displays that general area in a floating box with an aerial base and info about a rec site as the title if one is within clicked range. Simple (yet I have spent far too much time just browsing it). I’ll be honest, that was the fun part. The feature service is obviously also available directly in an ArcGIS Online map.
Develop the .Net console application to update the feature service data from a local source
My console app is using the ArcObjects .Net SDK to access a feature class within a file geodatabase to mimic my clients’ typical GIS infrastructure. This requires an ArcGIS license of any flavor to be available from the running server. This could just as easily be any format you like however since all we’re really doing is building JSON objects to pass directly to the ArcGIS Spatial Data Server REST API.
I used brute force in deleting all features and then adding them all back but I could imagine something a bit more elegant. I also noticed in Fiddler that ArcGIS Online uses the applyEdits method for any edit operation (delete, add, update). applyEdits also allows you to cancel the entire request if anything fails. But I’m going for simplicity here.
Here’s the C# code that works to make these updates:
There’s lots of room for improvement here such as serializing the json and handling the updates more elegantly but this is a working example of how you might keep a hosted map service on ArcGIS Online updated.
I’m guessing there are use cases I hadn’t thought of and would love to hear them.