Select to view content in your preferred language

New GeoJSON Capabilities for Developers

13979
6
12-10-2014 04:47 PM
AllanLaframboise
Esri Contributor
6 6 14K

There’s a lot of cool things available with the December release of ArcGIS Online, but if you are a dev, here’s something you are not going to want to miss: The enhanced interop (data) support for GeoJSON!  At this release, you can now import, export and access data from ArcGIS Online hosted feature services via GeoJSON.

Here’s what you can do:

  1. Import GeoJSON: Using the Add Item button you can simply import GeoJSON to create a new ArcGIS Online hosted feature service.



  1. Export GeoJSON: For all feature services, you can also export features out as GeoJSON.
  2. Access Directly:  And lastly, you can access all hosted feature services as GeoJSON simply by adding the f=geojson query parameter.  You can even change the outSR if you happen to need the GeoJSON in a different spatial reference.

Accessing GeoJSON from a Feature Services

http://services.arcgis.com/uCXeTVveQzP4IIcx/arcgis/rest/services/Portland_Coffee_Shops/FeatureServer...

Accessing GeoJSON from other Applications

View it live

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=1024, user-scalable=no">
    <style>
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0;}
      #map{ height: 100% }
    </style>
    <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
<!--[if lte IE 8]>
    <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" />
<![endif]-->

  <script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>
  <script type="text/javascript" src="https://rawgit.com/calvinmetcalf/leaflet-ajax/master/dist/leaflet.ajax.js"></script>
    <title>Leaflet AJAX</title>
    </head>
    <body>
    <div id="map"></div>

    <script type="text/javascript">
      var m = L.map('map').setView([45.52, -122.6819], 13);
      var osmDataAttr = 'Map data &copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors';
      var osm = L.tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",{attribution:osmDataAttr});
      osm.addTo(m);

      var geojson = new L.GeoJSON.AJAX("http://services.arcgis.com/uCXeTVveQzP4IIcx/arcgis/rest/services/Portland_Coffee_Shops/FeatureServer...", {});

      geojson.addTo(m);
    </script>
       
    </body>
</html>

NOTE:  Special thanks to Calvin Metcalf's L.GeoJSON.AJAX plug-in ‌that gives you direct access GeoJSON resources.

So there you have it.  But what about ArcGIS Server?  Well, the team says it’s coming soon, so keep your eyes peeled!

Happy interoping!

6 Comments
FilipKrál
Frequent Contributor

This it is such a major break through!!!

Oh my, oh my, I cannot wait for Server to support f=geojson too.

Huge thank you and lots of respect!

Filip.

BenScott1
Deactivated User

This sounds great but it seems that support for Geojson only goes as far as turning a snapshot of a geojson file into a static feature service.  It is often the case nowdays that geojson is being used to replace georss, and in that case arcgis online needs to be able to read a web-based geojson file in the same way it does with georss.

FilipKrál
Frequent Contributor

There have been some more improvements in GeoJSON support I think.

You can now select GeoJSON as output format for the query operation.

See for example this.

Another interesting change I noticed just is is the quantisation parameter. Thanks to that you can compress the geometries and drastically reduce the size of JSON responses (EsriJSON only though).

simoxu
by MVP Regular Contributor
MVP Regular Contributor

I noticed this post has been more than 2 years old, I am just wondering what has changes on ArcGIS server since then when it comes to GeoJSON support? can I publish a GeoJSON file as a service now?

Just give you some context, I have an ArcGIS sever (10.4.1) federated with portal for ArcGIS server, but I can't import GeoJson file and publish it as a hosted feature service...

JohnGravois
Deactivated User

hi simo,

Filip (above) is correct that you can now specify f=geojson in ArcGIS Server feature layer queries to ensure that the response uses GeoJSON format, but as far as i know it is not possible yet to use .geojson files directly to spin up hosted feature services outside of ArcGIS Online.

arcgis desktop - Methods for importing GeoJSON feature collection into ArcMap? - Geographic Informat... 

JohnGravois
Deactivated User

it turns out the capability of uploading flat .geojson files and publishing them as hosted feature layers was added to Portal at 10.4

What's new in Portal for ArcGIS 10.4.1—Portal for ArcGIS (10.4.1) | ArcGIS Enterprise 

About the Author
Esri Geo Developer