Is there an existing library for converting ArcGIS IFeature types to and from Json/GeoJson?
7 Answers
ArcGIS 10 has the AsShape
function for converting GeoJSON to arcpy geometries, which mimics Shapely's AsShape
, and arcpy geometry objects implement the __geo_interface__
standard (also from Shapely) for getting arcpy geometries back as GeoJSON.
-
While this is a good time, I'd have liked them to use a similar idea to the IXMLSerializer interface, but with Json. More consistent, and available in all languages which can use ArcObjects. Aug 11, 2010 at 3:17
-
1You could roll your own in ArcGIS 10 with IJSONWriter and the JSONWriter CoClass: help.arcgis.com/en/sdk/10.0/Arcobjects_CPP/componenthelp/… Sep 28, 2010 at 6:12
-
arcpy's AsShape/__geo_interface__ is handy but just don't pass in any polygons with interior rings: gis.stackexchange.com/questions/10201/… Dec 14, 2011 at 18:55
You should check out GeoJSON.Net by Vish: http://viswaug.wordpress.com/2008/05/11/geojsonnet-a-net-library-to-produce-geojson-output/
It should be pretty easy to extend it to use ArcObjects geometries.
Also, you can take a look at the GeoJSON exporter I did for SharpMap (you'll have to Google that since StackExchange won't let me post a second hyperlink). The geometry objects in SharpMap have a very similar structure to those in ArcObjects so that should be pretty easy to extend as well.
-
A lot of good pointers there, but like most other options, I'd have to write my own implementation, which is the route I've gone. Aug 11, 2010 at 3:18
This question with answer from Stack Overflow may work.
https://stackoverflow.com/questions/2223979/convert-a-shapefile-shp-to-xml-json
-
1Thanks for the suggestion. Sadly the library referenced reads shapefiles natively, rather than using the ArcObjects framework. Aug 5, 2010 at 2:17
Your best bet is to write your own framework. Use arcobjects so you can use geometries stored in any kind of geodatabase/shapefile/coverage. It shouldn't be too hard to do it.
-
1It's fairly easy to write one for simple geometries, less so when you need to support the more exotic cases. This is however the route I've gone. Aug 11, 2010 at 3:12
I don't see any existing library, but this C# REST interface from ArcDeveloper provides a start. There's also this CC-AO licensed Python toolbox to export a feature class to GeoJSON which should fit the bill, it handles the five major vector types.
The GeoJSON spec is straightforward and shouldn't be too onerous to implement, if the toolbox doesn't meet your needs.
-
Sadly the python option, while it fits the bill, needs to be used in a server context, where using the geoprocessing object creates threading and scaling issues. Aug 11, 2010 at 3:14
ESRI has this free Python script that converts from feature class to json, geojson or csv. esri2open
A bit of a late addition, but figured it's a useful addition...
I use ArcGIS.PCL which works very well. Allows you to interact with ArcGIS and spit out any of the geometries as GeoJson.