jupyter-widgets / ipyleaflet

A Jupyter - Leaflet.js bridge
https://ipyleaflet.readthedocs.io
MIT License
1.49k stars 363 forks source link

What coordinate system is used under the EPSG:4326 projection? #867

Open PROgram52bc opened 3 years ago

PROgram52bc commented 3 years ago

I am a little bit confused by the coordinate system used in the ipyleaflet Map object. Below is a simple example demonstrating what I mean:

from ipyleaflet import Map, Marker, projections

Map with the EPSG:4326 projection system

m = Map(center=[0, -90], zoom=1, crs=projections.EPSG4326)
m.add_layer(Marker(location=(0,-90)))
display(m)

Screenshot from 2021-09-08 11-53-38

Map with the default projection system

m2 = Map(center=[0, 0], zoom=1)
m2.add_layer(Marker(location=(0,0)))
display(m2)

Screenshot from 2021-09-08 11-53-49 The two markers are referencing the same point, but it seems like the longitude value is off by 90 degrees under the EPSG:4326 projection system. Is this behavior documented anywhere? Is there any standard functions to convert between one coordinate to another?

Thanks!

davidbrochart commented 3 years ago

In ipyleaflet the CRS is just passed to Leaflet, so I guess this is a Leaflet issue. Did you try to see if it behaves the same in pure Leaflet.js?

giswqs commented 3 years ago

This issue might be related to the upstream leaflet JavaScript. A relevant issue: https://github.com/jupyter-widgets/ipyleaflet/issues/684