Which projection is Mapbox using
Asked Answered
D

2

8

I have UTM coordinates, EPSG: 25833. Looking at the Mapbox documentation it says

Mapbox supports the popular Web Mercator projection, and does not support any other projections. Web Mercator is a nearly conformal projection that is adopted by the vast majority of web maps and its use allows you to combine Mapbox's maps with other layers in the same projection.

Commonly this projection is referred to as EPSG:900913 or EPSG:3857. See epsg.io for more information and alternative encodings.

So, I probably have to transform the UTM Coordinates into Web Mercator. I use the proj4js library to do that.

import proj4 from 'proj4';
const epsg25833 = require('epsg-index/s/25833.json');
const epsg3857 = require('epsg-index/s/3857.json');
const mapboxCoords = proj4(epsg25833.proj4, epsg3857.proj4, [point.utm_point.coordinates[0], point.utm_point.coordinates[1]]);

If I try to display mapboxCoords on the Mapbox Map, nothing is displayed. However, if I transform the coordinates into EPSG: 4326, everything is displayed. However, its possible that the coordinates are slightly off.

import proj4 from 'proj4';
const epsg25833 = require('epsg-index/s/25833.json');
const epsg4326 = require('epsg-index/s/4326.json');
const mapboxCoords = proj4(epsg25833.proj4, epsg4326.proj4, [point.utm_point.coordinates[0], point.utm_point.coordinates[1]]);

What is the correct projection for using Mapbox. The documentation says its EPSG:3857, however, when I transform my coordinates into that EPSG nothing is displayed. Using EPSG: 4326 displays at least something...

Deadwood answered 6/8, 2019 at 12:51 Comment(0)
O
14

With Mapbox's mapping libraries like Mapbox GL JS and Mapbox GL Native, the maps are visually rendered in the Web Mercator Projection (EPSG:3857), however anytime you want to pass data to show on these maps, either as a Marker or GeoJSON layer then that data must be passed as WGS84 LL, ie. EPSG:4326.

Orgell answered 7/8, 2019 at 1:37 Comment(3)
Hi @AndrewHarvey, please could you provide some documentation for this answer? Specifically with regards to why the data must be passed as EPSG:4326? I'm looking to do some further reading on this topic.Learning
@Learning for Mapbox GL JS anytime you pass a set of coordinates like for a Marker then LngLat docs.mapbox.com/mapbox-gl-js/api/geography/#lnglat defines it as expected to be in WGS84 LL, ie. EPSG:4326. Anytime you create a local source if as geojson then per the GeoJSON spec tools.ietf.org/html/rfc7946 "GeoJSON uses a geographic coordinate reference system, World Geodetic System 1984, and units of decimal degrees."Orgell
Just note that RFC7946 GeoJSON is not urn:ogc:def:crs:EPSG::4326 or EPSG:4326, It's urn:ogc:def:crs:OGC::CRS84 The axis order is different.Tailpiece
T
1

Mapbox supports the popular Web Mercator projection, commonly referred to as EPSG:900913 or EPSG:3857.

Mapbox docs link for reference:

Thyroiditis answered 8/8, 2019 at 19:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.