Code Monkey home page Code Monkey logo

Comments (3)

chris48s avatar chris48s commented on May 18, 2024

RFC 7946 does state WGS 84 should be used and removes the CRS member of the 2008 standard, but it does include the caveat

However, where all involved parties have a prior arrangement, alternative coordinate reference systems can be used without risk of data being misinterpreted.

so a GeoJSON file using a non-WGS84 CRS isn't strictly invalid. Refs

So this behaviour is intentional: We convert the file using the input CRS and emit a warning if its not 4326. It is out of scope for a simple format conversion tool to attempt to transpose between co-ordinate reference systems.


If you're looking for a way to emit ArcGIS JSON which isn't stored natively using WGS 84, your ArcGIS server can probably do it for you. If you're outputting from ArcGIS REST server, have a look at the outSR param. For example if I request:

https://ons-inspire.esriuk.com/arcgis/rest/services/Administrative_Boundaries/Combined_Authorities_December_2019_Boundaries_EN_BFE/MapServer/0/query?where=objectid%3D1&f=pjson

this outputs ArcGIS JSON using the server's default srid 27700, but if I append &outSR=4326

https://ons-inspire.esriuk.com/arcgis/rest/services/Administrative_Boundaries/Combined_Authorities_December_2019_Boundaries_EN_BFE/MapServer/0/query?where=objectid%3D1&f=pjson&outSR=4326

it will convert it to 4326 🎉

from arcgis2geojson.

GCOGit avatar GCOGit commented on May 18, 2024

Ah. Didn't see that exemption in the spec. Guess that's why ESRI's FeatureSet.to_GeoJSON preserves WKID 102100 and doesn't convert to WGS 84/4326. All I have access to is "item = gis.content.get(id)" (which returns "OperationalLayers"). I think a layer needs to be "published" for GeoJSON, etc. export options to appear. I didn't seem to see a way to do a REST query using an item id along with outSR.

I finally got a working Python script that converts the data to valid GeoJSON, also using json, pyproj, shapely, etc. libraries. Basically:

# EPSG:3857
# WGS 84 / Pseudo-Mercator -- Spherical Mercator, Google Maps, OpenStreetMap, Bing, ArcGIS, ESRI
# Alternatives codes : 900913 3587 54004 41001 102113 102100 3785
esriwgs = pyproj.CRS('EPSG:3857')
wgs84 = pyproj.CRS('EPSG:4326')
project = pyproj.Transformer.from_crs(esriwgs, wgs84, always_xy=True).transform

gis = GIS()
item = gis.content.get(id)
wm = WebMap(item)

for layer in wm.layers:
  fc = FeatureCollection(layer.featureCollection)
  fs = fc.query() # Only way to get a functional FeatureSet? This query apparently accepts no options.

  # print "type": "FeatureCollection", "features": [", etc.

  for feature in fs:
    # print "type": "Feature"...
    print('"properties": ' + json.dumps(feature.attributes))
    geom = arcgis.geometry.Geometry(feature.geometry)

    newgeom = transform(project, geom.as_shapely)
    print(', "geometry": ', geojson.dumps(newgeom))

I tried ArcGIS's "fc.query(out_sr=4326)" and "geom.project_as('EPSG:4326')" variations, but didn't seem to work. Anyway, I couldn't find any existing script or program out there that does this. Maybe I or somebody else could release one. :)

from arcgis2geojson.

chris48s avatar chris48s commented on May 18, 2024

Glad you managed to find a solution 👍

from arcgis2geojson.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.