0

I'm trying to get familiar with Folium library in Python. I wanted to make a web-map of Turkey. Framework uses EPSG:3857 Web Mercator CRS as default. I tried to use approximate coordinates at the centroid of Turkey in EPSG:4326 CRS which is lat:39.0 and lon:35.0 by specifying EPSG:4326 as CRS while giving the parameters but output map pointed out somewhere out of projection area near Pacific Ocean. I looked at epsg.io to confirm that I'm not confusing CRS but could not figure what is the problem myself. Below are my two examples:

1- crs; EPSG:3857 coordinates;(lat:39, lon:35)

Centers at Syria, unsurprising to have misalignment since CRS is Web-Mercator and coordinates at Geographic WGS84

webMap = folium.Map(location=(39,35),
                    zoom_start=5,
                    crs='EPSG3857') #which is default

# visualize
webMap

Correctish output

2- crs; EPSG:4326 coordinates;(lat:39, lon:35)

Centers at out of projection area

webMap = folium.Map(location=(39,35),
                    zoom_start=10,
                    crs='EPSG4326') 

 visualize

webMap

totally wrong

Can anyone point out what I am missing?

2

There are several things you have to take into account when dealing with coordinates and coordinate systems in Leaflet.

First, regardless of the coordinate system of the actual map displayed, all coordinates passed to Leaflet functions/methods are always EPSG:4326.

Second, order of coordinates passed to Leaflet is [latitude, longitude]. Since in your first attempt you used reversed coordinate order, you ended in Syria instead of Turkey.

And third, when defining/creating map with folium.Map call, actual crs of map has to be specified. Since your map is in EPSG:3857, your second attempt was completely off.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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