5

My problem relates to how polar projections can be 'recreated' within Mapbox, although officially Mapbox only supports the Web Mercator projection. A working example of how it can work can be found here:

https://blog.mapbox.com/mapping-arctic-sea-ice-in-a-polar-projection-a8fd68a03c53

However, I am unclear from their blog description how GeoJSON files were successfully incorporated onto the map. For background layers such as a coastline I am able to reproject and assign a Web Mercator projection (ogr2ogr -a_srs EPSG:3857) and upload these shapefiles to Mapbox as tilesets fine.

Applying the same process to convert ice extent shapefiles into GeoJSON files basically outputs a json file with coordinates written in metres (e.g., ogr2ogr -f GeoJSON -a_srs EPSG:3857 B3C__2273_WM.json B3C__2273_PS.shp). When uploading to Mapbox an error message indicates that the units are not acceptable and should be degrees (Input failed. Datasets don't support features outside longitude +/-180, latitude +/-90.).

Example data: { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "Id": 0 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ -313218.45268004813, -2070401.2551701278, 259.16299999999649 ], ...

My question then is how is it possible to import GeoJSON files into Mapbox that are projected in something like EPSG:3995 (polar stereographic), such as in the link above? I would like to manipulate the json data with a time slider, so I don't think uploading as shapefiles is a viable option in this case.

2
  • The new shiny GeoJSON spec (tools.ietf.org/html/rfc7946) doesn't allow for projection.
    – Ian Turton
    Commented Nov 16, 2017 at 16:52
  • 1
    Actually it does but does not tell how However, where all involved parties have a prior arrangement, alternative coordinate reference systems can be used without risk of data being misinterpreted. But perhaps MapBox is not willing to make such "a prior arrangement".
    – user30184
    Commented Nov 16, 2017 at 17:11

1 Answer 1

4

Until Mapbox supports other projections https://github.com/mapbox/mapbox-gl-js/issues/3184 this is going to involve lying about the projection in the metadata source file so that you essentially stick a map with a different projection on the Web Mercator Mapbox map.

If you download coastline from http://www.naturalearthdata.com/downloads/10m-physical-vectors/10m-coastline/ then convert this to GeoJSON in a polar projection (EPSG:3413 which is a projected coordinate system in meters) with:

ogr2ogr -f GeoJSON -t_srs 'EPSG:3413' ne_10m_coastline.epsg3413.geojson ne_10m_coastline.shp

Then fake the coordinate reference definition so it thinks this is EPSG:3857 (web mercator, a projected coordinate system in meters) without actually changing any of the numbers:

ogr2ogr -f GeoJSON -a_srs 'EPSG:3857' ne_10m_coastline.asrs_epsg3857.geojson ne_10m_coastline.epsg3413.geojson  

Finally we need to re-project that back to WGS84 since that's what GeoJSON files should be in and it's what Mapbox expects.

ogr2ogr -f GeoJSON -t_srs 'EPSG:4326' ne_10m_coastline.fake_polar.geojson  ne_10m_coastline.asrs_epsg3857.geojson 

Then in Mapbox https://jsbin.com/junemibegi/edit?html,output

There are a few issues since the source data extends beyond the bounds which our polar projection EPSG:3413 supports, but we could either use a different projection or trim out data to not go so far south.

This works because our polar projection is in meters and centered at 0,0, which is also the case for the projection we used in the -a_srs paramater - web mercator, and the extend of the polar projection used is roughly the same scale but a bit less than web mercator, so our polar map fits into the world.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.