A while back, I posted about my desire to see GeoJSON supported as an output format from ArcGIS Server. I found myself needing that capability so I recently completed, and posted to GitHub, a first cut at a server object extension (SOE) for ArcGIS Server 10.1 that enables output of GeoJSON via an HTTP GET.
Using the SOE is fairly straightforward. If you download the code and build it (ensuring you have installed the ArcObjects SDK for .Net), you can simply move the project outputs to your target machine and use the ArcGIS Server manager to install the SOE. Once you log into the manager application, click “Site” at the top of the page and then “Extensions” on the left. Click “Add Extension” and browse to the .soe file. You should end up seeing something like this:
After, that you can go back to “Services,” choose a map service, select “Capabilities,” and you should see “Open Data Formats” as a choice to select. At that point, you should be ready to go.
That’s all meat-and-potatoes configuration workflow that Esri has made very easy at 10.1. Once you’ve been through all of that, you should be able to go to your map service properties using a URL like this:
http://localhost/arcgis/rest/services/SampleWorldCities/MapServer
…and you should see be able to scroll to the bottom and see “GeoJSONServer” (which will change in a future version) as a supported extension.
Following that link should take you to a page that shows “GeoJSON” as a supported operation. From there, you should be taken to a page that allows you to enter in a layer number (required) or a query (optional). The layer number is the layer’s ordinal shown in the map service properties above. The query parameter can be a SQL WHERE clause that is valid for the layer in question (leaving off the word “WHERE”). This is consistent with how definition queries are handled elsewhere in the Esri REST API. At this point, GET and POST do the same thing though that may change in the future. You can use this form (which is generated by default) to test the SOE and get examples of valid URLs. For example, this URL returns GeoJSON for the continent of Asia from my sample map service:
http://localhost/arcgis/rest/services/SampleWorldCities/MapServer/exts/GeoJSONServer/GeoJSON?query=CONTINENT%3D%27Asia%27&layer=1&f=json
In the process of developing the SOE, I tested the outputs using geojsonlint.com and the OpenLayers vector format example page (see the following screen shot).
A few nuts and bolts:
- I refactored my previous extension methods for the File Geodatabase API to work with ArcObjects for this SOE. The code is functional but I’d call the conversion about 75% complete. A close examination by an experienced ArcObjects developer may lead to some head-scratching as there are some artifacts from the FGDB API oriented code that I’ll be cleaning up over the next couple of weeks.
- The SOE is currently output-only and only supports attribute queries. I plan to work on the ability to pass in a GeoJSON geometry to do a spatial filter as well but my GeoJSON code currently only persists Esri geometries to GeoJSON but does not yet de-persist. For the sake of consistency, I don’t want to mix JSON syntax, so I want to add in de-persistence before implementing spatial filters.
- The SOE always transforms geometries to WGS84 for GeoJSON output. The GeoJSON spec doesn’t specifically require this; it was just my call.
- The SOE has been tested with ArcGIS Server 10.1 only. I don’t know if the current code will present any issues with previous versions but I really have no plans to go back and test them. The actual GeoJSON generation shouldn’t be much of an issue but I can’t speak for the SOE interface itself. Forks are welcome.
As can be seen, the code is still under active development but it works in its current configuration. It’s actually performed pretty well on a very modest Amazon instance so I’m somewhat encouraged. I’ll post some issues to GitHub as a nominal road map.
In a semi-related note, it looks like Marten Hogeweg of Esri is working on integrating GeoJSON support into Esri’s portal server project, so users of that tool may want to hold on for that.
So… looking at adding #geojson to #esri #opensource #geoportal server. What do I see… There's multiple flavors of it? #whatsupwiththat
— Marten Hogeweg 🇺🇦 (@martenhogeweg) June 8, 2013
I’m looking forward to checking out Marten’s work and am glad to see Esri taking greater notice of GeoJSON.
Heya, This is really great. Are you considering posting prebuilt versions for those people who are unable to build their own?
Yes, I am. However, due to the fact that I forgot to post a .gitignore file with the repository, you can find the current binaries here: https://github.com/geobabbler/AGSOpenFormats/tree/master/GeoJSONSOE/bin/Debug
That’s purely an accident which I’ll fix soon but you grab them right now if you want them.