-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support non-mercator projections #3184
Comments
I'm really looking forward to this, and it's a bit of a blocker for using it in our project. We're using Mapbox for a data visualization, and everything is working smoothly with the exception of the unwanted Mercator projection. Any tips of how to turn off manually would be much appreciated as well! |
Support for a simple |
+100 |
To disambiguate this conversation, since it's floating in a familiar direction of indirection: There are two things we talk about when we talk about projections: Projections in data. This means you store data in coordinates that are not longitude and latitude, but instead meters or some other units. This is common for high-accuracy local data or state government data, and so on. This is what @dannybloe refers to, but it isn't what this ticket discusses. It's also a much simpler problem than the one this ticket discusses: if you upload data to Mapbox, it's reprojected automatically, and if you run it through a utility like ogr2ogr or reproject, it can easily be translated from any projection to any other projection. Display projections. The kind you see and people argue about more, because opinions are like kittens. This is the thing this ticket discusses, and the much harder one, for a variety or reasons - the biggest one, in my opinion, being the lack of standardized scales and origins for display projections. And, for Mapbox GL JS, the ability to reproject data, deal with potentially non-square tiles, and so on and so forth. This is what this ticket discusses. |
I would like it to support custom projections. In other words, not just other standard projections, but also custom projections. Google has this if that helps explain: https://developers.google.com/maps/documentation/javascript/examples/map-projection-simple |
@tmcw thanks for insightful reply. The two seem to go hand in hand actually, at least for our use case. We basically enjoy quite a few features MapBox has (zoom, panTo, scrolling, etc etc) but also displaying a visualization thats not a map. Given we don't want mercador projection, it would go hand in hand to also not have to convert all our data to lat/lng. So at least for the use case of flat projections, the data side seems naturally linked. I could dedicate the next two weekends to implementing this. Questions:
If it's not too large a task, this would be very much helpful for us and worth exploring very soon! Would be glad to dive into it. |
@natew We'd definitely be interested in working with you to put together & merge a PR that implements this functionality provided that this can be done in an elegant, backwards-compatible, and performance-neutral way. As a first step, I'd suggest designing a public API using the RFC template: https://github.com/mapbox/mapbox-gl/blob/master/RFC_TEMPLATE.md |
Hey all! This issue is coming up a bit more for us, any thoughts on the future of projections in Mapbox GL JS? It's probably unique to our use case, but would love to hear more! |
Question: If I did use mapbox-gl-js to show a building floor plan (tiled or simply image overlay), and I wanted to show a marker at a specific X,Y coordinate from a reference point on the floor plan, can I transform thee X,Y plan-specific coordinates to lat, lng such that it will display correctly with mapbox-gl-js? Is this tricky or hacky, or can it be done elegantly? Looks like this somewhat answers the first part of my question: http://wiki.openstreetmap.org/wiki/Zoom_levels |
@vjpr so long as Mapbox GL JS does not support projections other than mercator, doing this will involve at least some hackiness. Here's a blog post that describes how one can do this (and points to a utility library that may help): https://developmentseed.org/blog/2016/12/15/dirty-reprojectors/ |
It dawned on me this morning that you've created an excellent platform for optimized, zoomable, 2d interactive visualization! Support for cartesian coordinates would be dreamy! |
Would love some pointers from a maintainer about how to approach this. |
Hi there. Is there something new about using non webmercator projection on Mapbox? I would like to use Ordnance survey raster maps with Mapbox, but they're available only with EPSG:27700 projection. Looks like these files are concerned :
But I'm not sure how to achieve this and I fear this is much more complicated. Does someone work on it? |
Just thought I'd chime in while researching both Mapbox and Carto support for non-Mercator projections. Here's Carto's documentation on the subject: https://carto.com/help/working-with-data/changing-map-projections/ |
Any news on this ? |
@xawill No updates on this issue at this time. It's still something we're actively thinking about and exploring, but it's not on our current timeline. Implementation of this is not trivial and we need to carefully consider the issue. It would be helpful for us to understand what use cases people have and what projections they're most interested in. Also, we do have a work-around that may fit certain use cases. Check out https://github.com/developmentseed/dirty-reprojectors It has limitations but if you don't need a queryable map, it might satisfy your use case. |
@ryanhamley Thanks a lot for the feedback and precisions. My use case is to use a raster tiles (256x256px) dataset provided by the Swiss government. The coordinate system is EPSG:21781 (WMTSCapabilities.xml). The dataset is also available in WGS84, but not at the highest zoom level (10cm resolution), probably due to WGS84 conversion not being precise enough for the dataset to be useable. So for now, I am stuck at zoom level 21 or something. Thank you for pointing out the workaround, but I had already checked it and it looks like it would not fit my use case, right ? I am available to give you more info about my use case if needed, and even potentially available to help on the implementation of this improvement. I am not (yet) an expert on the topic, but I already learned a lot struggling with my own project and would be interested in learning even more. |
It would be good to have some capacity for working with UTM zones. |
cc @chloekraw ☝️
It's hard to say. I think you'd have to test it out and see. The library is based on a trick described in this blog post which uses the |
This looks amazing! Great work! 🙌 |
Great work! Is there any chance of added support for transverse mercator projections? We are specifically looking for support for either ETRS89 or WGS84 over Europe. |
@eivsal we're looking into supporting UTM projections in the future, but it might be difficult due to how heavily distorted they get outside of the targeted range. Meanwhile, for Europe, I'd recommend either Lambert conformal conic (recommended by European Environment Agency and INSPIRE for Europe) or Albers equal-area conic. |
@mourner Thanks for reply 💯 |
Oh wow! Can't wait to see how terrain looks like in custom projection. ⚡⚡ |
To @ansis @mourner and all who worked on this feature, thank you very much! Is there any easy possibility to specify that the reprojection "wrap" on a meridian other than the antemeridian? This would be particularly useful to improve maps of Alaska which otherwise suffer from this nearby edge: { //EPSG 102006: Alaska Albers Equal Area Conic
name: "albers",
center: [-154, 50],
parallels: [55, 65],
} |
Is there any hope of this feature making it out into the Power BI Custom Visual integration? If not please tell us now so we can work on alternatives. |
Great work here. I'm using the Albers projection now at https://www.govtrack.us/congress/members/map and https://www.govtrack.us/congress/members/OR/4 and similar pages, and it feels good to be able to use an equal-area projection. Some feedback that I hope is useful (all with respect to the Albers projection):
It would also be very interesting (and this is just a fun thought) if the reference longitude changed dynamically based on panning, so that the map's center was always the reference center of the projection. The reference latitudes (parallels) could also change while maintaining a fixed separation. This would eliminate the distortion and rotation you get when panning on an actual Albers projection (and it would reduce the number of projection parameters to just one parameter, the separation between the reference latitudes). But I recognize that this might be... a bit difficult. Thanks again. |
Interesting. But... Does it mean when you zoom in the map will always be projected to Web Mercator? Hm. One reason for using a selective map projection is precision, not just for the looks of it when zoomed out. Anyways, congrats. This is technically very interesting. |
I agree. I would prefer the opposite way: Having local projections and when zooming out, slowly migration to Web Mercator. IMHO global projections are for gourmets (unless you are interested in areas close to the poles), while local projections are what most people are interested in or are forced to use. |
I was really hoping to be able to use custom local projections / coordinate systems. EPSG:29882 in my case. I'll still have to stay with Leaflet for the foreseeable future then. |
Firstly nice work, this is really cool! Unfortunately it doesn't help my use case. As @mathiash98 mentioned, the ability to use a simple CRS like Leaflet JS would be amazing! Whilst i know that Mapbox is built primarily to display a world map, the tool is much more powerful than just that and I've had success using it with custom map tiles generated from drawings for example. The only thing is I've had to run custom co-ordinate conversions because of the mercator projection. |
@benstadin @marcelnormann this would defy the purpose of using projections on an interactive map. All map projections are a way to flatten the globe onto the screen while trying to find a balance between three types of distortion — of relative sizes, distances, or shapes of geographic objects. Mercator is fantastic at higher zoom levels, because it's conformal — preserving shapes, local angles between lines, and local directions (up is north, down is south), making it the best projection for navigation on a city-level. Its biggest shortcoming comes out on low zoom levels — since it severely inflates sizes of objects the closer they are to the poles, when you have a big range of latitudes on one screen, relative sizes are very misleading. For example, Greenland looks the same size as Africa, even though it's actually 14 (!) times smaller. GL JS projections were designed to minimize distortion across all zoom levels in an interactive context. This means you can choose the best projection for your use case on low zooms, be it a world projection like Natural Earth for thematic mapping, or a conic projection like Albers or Lambert that's configurable for a specific range of longitudes and latitudes (best for minimizing distortion on a specific continent / country level), and then have GL JS gently transition to Mercator on higher zooms so that it's usable for city-level mapping, and shapes of roads and buildings are not diagonally squished in a weird way. This may be an unusual approach for a GIS professional used to traditional maps, but it's a rare attempt at reimagining projections for the interactive maps era from the ground up, and you might warm up to it if you actually try it in practice. As for specific projections that are not yet supported — stay tuned, we'll listen to your feedback very closely when deciding how to expand the feature in future releases. |
Congratulations on some really amazing work here folks. Could you comment if you ever foresee supporting user-supplied tiles in different projections, please? e.g. equivalent of this OpenLayers example. |
@JoshData This is because it's a part of the style specification, so it has to be strict JSON.
Latitude is officially a part of the parameters for the Albers projection (e.g. as described on Wikipedia), so we kept it and used a generic
@timrobertson100 This is technically possible to implement in the future, but there are no plans for this in the short-term as far as I know. Our bet was on reprojecting from Mercator since most of our existing services and tooling are built around it, and we wanted to introduce projections in a way that's 100% compatible with existing Mapbox tilesets. |
@mourner I respectfully disagree that projections are not practically relevant for high zoom levels. I'm not false advertising our product at this place, but our proprietary 3D (or 2.5D) vector map rendering engine supports those projections for good reasons and due to customer demands. Thus I'm a bit surprised by the statement that a zoomed out non-mercator map is good (a nice feature indeed and technically interesting), while a zoomed-in non-mercator map has rare practical use. And that approach somehow "reimagines" maps. We usually use UTM projections for e.g. city, fair ground or shop floor navigation where a mercator map does often not provide acceptable results - even for very small areas (think of shelves inside a shop). It means on a technical side of things some challenges for projection-agnostic indexing and processing for our vector tiles storage. We also use Mapbox maps for some projects, mostly where we just need an outdoor map. For projects where precise mapping or indoor mapping is required we either use our own technology, or another map framework that supports projections. These maps are not for GIS professionals but for actual end users who otherwise often complain. As another example, telling map app users or customers to print out their campus or building maps in less precise / distorted web mercator to make them match to the distortion of the map in an app when zoomed in is also not an option. In the end the only truth is in the ball shaped globe ;-). |
@benstadin please excuse me for my ignorance on the topic of high-precision indoor maps, but aren't you conflating two concepts here — display projection, and coordinate (e.g. datum) mismatch between datasets? If coordinates of your data are transformed properly for overlaying on a Web Mercator map, I believe the latter can be used well even for highly detailed (mm-precision) maps given high enough max zoom and vector tile extent. To be able to represent detailed local data without distorting shapes, a projection has to be conformal — meaning having constant local scale in every direction around one point, and preserving relative angles. Web Mercator is slightly non-conformal due to spherical math applied to ellipsoidal (WGS84) datum, and this deviation is well documented — reaching at max ~0.67% distortion for local scale in N/S direction, and ~0.1% distortion for local angles (both at equator). This kind of distortion may be important for GIS analysis, but it's pretty much imperceptible to the human eye when used for display purposes. So I'm really surprised to hear that users complain about Web Mercator distortion of their campus or building maps — perhaps a concrete illustration would be helpful here? What am I missing? |
It works brilliantly, thanks a lot! One thing I noticed is that the calculation of region bounds seems to not apply correctly, i.e. options.bounds values which work on Mercator projection are too narrow on naturalEarth, for example, cutting off the edges of the region. |
This may be related to #10064 |
@mourner No, I do not talk about data mismatches or any other technical aspect at all. These are solved problems. It's different projections and different maps with different looks for certain use cases. I understand that indoor or venue mapping is not the targeted audience for MapBox. I just wanted to keep the record straight that such maps are not just used to look at them when zoomed out for esoteric reasons, but find actual practical use in application where, to quite the contrary, it's about rather small areas like campus sites or fair grounds. |
Is there any plans for enabling the use of maps that are Ordnance survey raster maps with Mapbox, but they're available only with EPSG:27700 projection? |
We also need accurate projections at higher zoom levels. For us, Mapbox GL is not the main mapping library; we just use it to render vector tiles for base layers. We plot the other layers in EPSG:4326 (aka WGS84 / equirectangular) and we need the points to line up with the base layer. Unfortunately since the Mapbox renderer doesn't preserve the equirectangular projection at all zoom levels, we can't use it. Instead we have to use the webmercator projection and add a postprocessing step to "squish" the raster. |
Hi, I'd like to know how does mapbox support no-mercator projection: 1 The vector tiles are generated with mercator projection, and mapbox-gl-js support other projections by reproject the tile on the fly during client rendering. 2 The vector tile are generated with no-mercator projection, and mapbox-gl-js render them as they are without any reprojectiong. |
@exotfboy it's the first; you can read about the way projections are implemented in GL JS in detail in this blog post: https://www.mapbox.com/blog/adaptive-projections |
@mourner Thank you. |
Hi all, do you know if the mobile SDKs are also supporting non-mercator projections for vector tiles? What about raster tiles? |
I would also like to know this.
|
Adding this back as an issue, since its original one was converted into stagnated PR #1466, but remains a pretty cool feature!
Original Issue Text:
The text was updated successfully, but these errors were encountered: