Exporting/Converting Data from ArcGIS Online to WGS 84 Spherical Mercator (EPSG:3857-style) Coordinates

5418
2
Jump to solution
02-26-2015 07:14 AM
PhilipWalter
New Contributor

Hey all,

I am trying to export some feature layers from ArcGIS Online for use with the Google Maps API.  The most intuitive way to do this seems to be to use GeoJSON multipolygon or polygon objects.  I have been able to export my feature layers in GeoJSON format, but they don't seem to translate into usable coordinates for Google Maps.

What I get looks like this:

{"type":"FeatureCollection",
  "crs":{"type":"name","properties":{"name":"EPSG:3857"}},
  "features":[{"type":"Feature","id":1,
  "geometry":{
  "type":"Polygon",
  "coordinates":[
        [
     [-10516017,4054040],
  [-10490946,4054346],
  [-10492475,4076666],
  [-10397693,4074220],
  [-10392189,4074220],
  ....etc....,
  [-10516017,4054040]
  ]
  ]},
  "properties":{"FID":1,"TITLE":"UAMS Southwest Region","VISIBLE":1,
  "DESCRIPTIO":"Counties Served by UAMS Southwest","IMAGE_URL":" ","IMAGE_LINK":" ","DATE":null,"TYPEID":0}}]}

This object does not show up when integrating it with the Google Maps API.  My assumption is that the coordinates here are not in EPSG:3857.  Based on other GeoJSON objects I've seen working with the API, these numbers need to look like standard latitude and longitude coordinates.  I know it is possible to make this conversion somehow, given only the data in the GeoJSON file.  I know this because I've uploaded sample files to this tool: http://converter.mygeodata.eu/.  After upload, the feature layer in placed in just the right spot on an OpenStreetMap, and I am told the following information:

Feature type:Polygon
Feature count:1
Data extent:Min X:-10325536
Min Y:4094705
Max X:-10244207
Max Y:4165944
WGS-84 extent:Min X:-92.76
Min Y:34.49
Max X:-92.03
Max Y:35.02
Coordinate reference system (CRS):
     Name:WGS 84 / Pseudo-Mercator
Code:EPSG:3857

After all that, no matter how I try running it through this tool, all exports retain the Data Extent coordinate system and not the WGS-84 Translations.  Does anyone have experience with this or similar situations?

Any feedback is greatly appreciated.

0 Kudos
1 Solution

Accepted Solutions
ChrisSergent
Regular Contributor III

I'm not sure if this will help, but I have an application where I right click on an Esri JS API map app I created using our web services and then it converts the location to Google maps location to show street view in a pop-up.

Here is my project if you want to take a look and see if that helps: csergent45/gisWeb · GitHub

The other thing I was wondering is have you considered generating a KML?

View solution in original post

2 Replies
ChrisSergent
Regular Contributor III

I'm not sure if this will help, but I have an application where I right click on an Esri JS API map app I created using our web services and then it converts the location to Google maps location to show street view in a pop-up.

Here is my project if you want to take a look and see if that helps: csergent45/gisWeb · GitHub

The other thing I was wondering is have you considered generating a KML?

PhilipWalter
New Contributor

Thanks so much, Chris!

What I ended up doing it was going through the KML intermediary.  For the sake of saving someone else time in the future, the components I'm using are:

  • ArcGIS Online - for creating and exporting Feature Layers
  • MyGeoData Converter - for converting to GeoJSON
  • My own simple C++ program to swap longitude and latitude values in the JSON object
  • gmaps.js - as a simplified way to access Google Maps API (you could use their API directly just as well)

What you do is create your Feature Layer, and publish it as a hosted feature layer.  Then you can export it out of ArcGIS as either a shapefile or GeoJSON.  At this point, you go to the converter tool, upload your GeoJSON file, or the entire zip file containing the shapefile information (you can upload multiple files at a time for a batch conversion).  From here, choose KML as your target format, and hit Convert.  Somehow, this strips out the projection coordinates, and leaves the geographic coordinates.  You can then convert your KML output back to GeoJSON or whatever you want.

One strange thing I noticed was that my final result looked fine in viewers like geojson.io, but failed to render properly using the drawPolygon() method in gmaps.js.  After looking at their documentation, I figured out that my coordinates were opposite those in their example.  Not sure if that is specific to gmaps.js or what, but I just wrote a simple C++ program to swap each coordinate set, and the feature layers render as expected.  There are probably more efficient ways to go about this but the results were a success.

Thanks again to Chris Sergent for your help!