Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

folium custom map tiles

I want to add this map tile layer to my map – Stamen toner-background. As I read in documentation I need to simply give custom url in the tiles attribute of map

mapa = folium.Map(width=1000, height=700, zoom_start=5.5,
              location=[52.5, 19], tiles='http://maps.stamen.com/toner-background/embed#6/{x}/{z}', attr="toner-bcg")

It loads but nothing is displayed.

I don't really know how this attribution thing works like and what should I do. I like the tile because it's like stamen toner but without country names and that makes my map a lot more beautiful.

like image 221
ggegoge Avatar asked Jan 18 '18 10:01

ggegoge


People also ask

Which of the following is a tile style of Folium maps?

Folium allows us to create maps with different tiles like Stamen Terrain, Stamen Toner, Stamen Water Color, CartoDB Positron, and many more.


1 Answers

This is your lucky day, Stamen designs are built-in in Folium. You should run the following code:

mapa = folium.Map(width=1000, height=700, zoom_start=5.5,
              location=[52.5, 19], tiles='Stamen Toner')

This should solve the issue.

The reason your code was not working is because you were not using the correct URL templates. The format is one specified here:

http://tile.stamen.com/toner/{z}/{x}/{y}.png
http://tile.stamen.com/terrain/{z}/{x}/{y}.jpg
http://tile.stamen.com/watercolor/{z}/{x}/{y}.jpg

The code would look like this:

mapa = folium.Map(width=1000, height=700, zoom_start=5.5,
              location=[52.5, 19], tiles='http://tile.stamen.com/toner/{z}/{x}/{y}.png ')
like image 115
Fernando Irarrázaval G Avatar answered Sep 24 '22 16:09

Fernando Irarrázaval G