Skip to content
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

Remove Stamen #1811

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/advanced_guide/custom_panes.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ We'll make an example to show how the GeoJson we add hides any labels
underneath.

```{code-cell} ipython3
m = folium.Map([43, -100], zoom_start=4, tiles="stamentoner")
m = folium.Map([43, -100], zoom_start=4)

folium.GeoJson(geo_json_data, style_function=style_function).add_to(m)

Expand All @@ -43,14 +43,14 @@ Now we'll create a custom pane and add a tile layer that contains only labels.
The labels will show on top off the geojson.

```{code-cell} ipython3
m = folium.Map([43, -100], zoom_start=4, tiles="stamentonerbackground")
m = folium.Map([43, -100], zoom_start=4)
Conengmo marked this conversation as resolved.
Show resolved Hide resolved

folium.GeoJson(geo_json_data, style_function=style_function).add_to(m)

folium.map.CustomPane("labels").add_to(m)

# Final layer associated to custom pane via the appropriate kwarg
folium.TileLayer("stamentonerlabels", pane="labels").add_to(m)
folium.TileLayer(pane="labels").add_to(m)
Conengmo marked this conversation as resolved.
Show resolved Hide resolved

m
```
3 changes: 1 addition & 2 deletions docs/advanced_guide/subplots.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ subplot1 = fig.add_subplot(1, 2, 1)
subplot2 = fig.add_subplot(1, 2, 2)

subplot1.add_child(
folium.Map([0, 0], tiles="stamenwatercolor", zoom_start=1)
folium.Map([0, 0], zoom_start=1)
)
subplot2.add_child(
folium.Map([46, 3], tiles="OpenStreetMap", zoom_start=5)
Expand Down Expand Up @@ -54,7 +54,6 @@ f = branca.element.Figure()
# Create two maps.
m = folium.Map(
location=[0, 0],
tiles="stamenwatercolor",
zoom_start=1,
position="absolute",
left="0%",
Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ m.save("index.html")
Choosing a tileset
------------------

The default tiles are set to `OpenStreetMap`, but a selection of tilesets from Stamen and CartoDB are also built in.
The default tiles are set to `OpenStreetMap`, but a selection of tilesets also built in.
Conengmo marked this conversation as resolved.
Show resolved Hide resolved

```{code-cell} ipython3
folium.Map((45.5236, -122.6750), tiles="cartodb positron")
Expand All @@ -81,7 +81,7 @@ There are various marker types, here we start with a simple `Marker`. You can ad
tooltip. You can also pick colors and icons.

```{code-cell} ipython3
m = folium.Map([45.35, -121.6972], zoom_start=12, tiles="Stamen Terrain")
m = folium.Map([45.35, -121.6972], zoom_start=12)

folium.Marker(
location=[45.3288, -121.6625],
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ It enables both the binding of data to a map for choropleth visualizations
as well as passing rich vector/raster/HTML visualizations as markers on the map.

The library has a number of built-in tilesets from OpenStreetMap,
Mapbox, and Stamen, and supports custom tilesets.
Mapbox, etc, and supports custom tilesets.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Conengmo I wonder if we should leave OSM as default and remove everything else in lieu of xyzservices.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we could make xyzservices a required dependency (pure python, no dependencies) and offload all of it, while giving users all available tiles by default.

Copy link
Member Author

@ocefpaf ocefpaf Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is kind of what I was thinking. Making it a mandatory dependency and using it everywhere instead of having the templates for CartoDB, which was the last one to survive the API key revolution ;-p

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we agree :). If we want to do that, we should expose xyzservices via the query_name method as we do in geopandas or contextily, so you don't need to interact with xyzservices directly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think @Conengmo ? Should I start that in this PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really interesting thought! Can you give me a moment? I don’t want to rush my thoughts here. I’ll get back this weekend if that’s okay.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not in a hurry 😄
But b/c this is kind of a breaking change I would like to hold the next release to ship this with it, if we decide to implement it.

PS: the devil is in the details, we have tons of examples and docs that will request some re-writing. However, the disruption on end user won't be too big, I hope.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have tons of examples and docs that will request some re-writing. However, the disruption on end user won't be too big, I hope.

Why? Apart from Stamen maps not being available, which is nothing we can influence, it should be completely backwards compatible. Can you point me to examples that would need re-writing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm on mobile now to check but my guess are the names we use in the tile keywords in the do docstring and examples. Those would change to match XYZ, no? I'd love for us to use the same as geopandas to reduce the cognitive load on users

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If exposed via query_name they should, with the exception of "OpenStreetMap", which needs to be mapped to "OpenStreetMap.Mapnik" but we can sort this one case internally I suppose.

Folium supports both Image, Video, GeoJSON and TopoJSON overlays and has a
number of vector layers built-in.

Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/plugins/heatmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ data = (
import folium
from folium.plugins import HeatMap

m = folium.Map([48.0, 5.0], tiles="stamentoner", zoom_start=6)
m = folium.Map([48.0, 5.0], zoom_start=6)

HeatMap(data).add_to(m)

Expand Down
6 changes: 3 additions & 3 deletions docs/user_guide/plugins/heatmap_with_time.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ for time_entry in data:
```

```{code-cell} ipython3
m = folium.Map([48.0, 5.0], tiles="stamentoner", zoom_start=6)
m = folium.Map([48.0, 5.0], zoom_start=6)

hm = folium.plugins.HeatMapWithTime(data)

Expand All @@ -55,7 +55,7 @@ m

### Options

Now we show that the time index can be specified, allowing a more meaningful representation of what the time steps mean. We also enable the 'auto_play' option and change the maximum opacity. See the docmentation for a full list of options that can be used.
Now we show that the time index can be specified, allowing a more meaningful representation of what the time steps mean. We also enable the 'auto_play' option and change the maximum opacity. See the documentation for a full list of options that can be used.

```{code-cell} ipython3
from datetime import datetime, timedelta
Expand All @@ -66,7 +66,7 @@ time_index = [
```

```{code-cell} ipython3
m = folium.Map([48.0, 5.0], tiles="stamentoner", zoom_start=6)
m = folium.Map([48.0, 5.0], zoom_start=6)

hm = folium.plugins.HeatMapWithTime(data, index=time_index, auto_play=True, max_opacity=0.3)

Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/plugins/mini_map.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ m

```{code-cell} ipython3
m = folium.Map(location=(30, 20), zoom_start=4)
MiniMap(tile_layer="Stamen Toner").add_to(m)
MiniMap().add_to(m)
m
```

Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/plugins/tag_filter_button.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Then, create the `TagFilterButton` object and let it know which tags you want to
from folium.plugins import TagFilterButton

# Create map and add the data with additional parameter tags as the segmentation
m = folium.Map([48., 5.], tiles='stamentoner', zoom_start=7)
m = folium.Map([48., 5.], zoom_start=7)
for i, latlng in enumerate(data):
category = category_column[i]
folium.Marker(
Expand Down
4 changes: 2 additions & 2 deletions docs/user_guide/plugins/timeslider_choropleth.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ import folium
from folium.plugins import TimeSliderChoropleth


m = folium.Map([0, 0], tiles="Stamen Toner", zoom_start=2)
m = folium.Map([0, 0], zoom_start=2)

TimeSliderChoropleth(
gdf.to_json(),
Expand All @@ -170,7 +170,7 @@ m
By default the timeslider starts at the beginning. You can also select another timestamp to begin with using the `init_timestamp` parameter. Note that it expects an index to the list of timestamps. In this example we use `-1` to select the last timestamp.

```{code-cell} ipython3
m = folium.Map([0, 0], tiles="Stamen Toner", zoom_start=2)
m = folium.Map([0, 0], zoom_start=2)

TimeSliderChoropleth(
gdf.to_json(),
Expand Down
4 changes: 2 additions & 2 deletions docs/user_guide/raster_layers/image_overlay.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ If you have a static image file on your disk, you can simply draw it on the map.
import os
import folium

m = folium.Map([37, 0], zoom_start=1, tiles="stamentoner")
m = folium.Map([37, 0], zoom_start=1)
merc = os.path.join("data", "Mercator_projection_SW.png")


Expand Down Expand Up @@ -46,7 +46,7 @@ A few remarks:
You can also provide simply URL. In this case, the image will not be embedded in folium's output.

```{code-cell} ipython3
m = folium.Map([37, 0], zoom_start=1, tiles="stamentoner")
m = folium.Map([37, 0], zoom_start=1)

folium.raster_layers.ImageOverlay(
image="https://upload.wikimedia.org/wikipedia/commons/f/f4/Mercator_projection_SW.jpg",
Expand Down
12 changes: 0 additions & 12 deletions docs/user_guide/raster_layers/tiles.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@ zoom_start = 8
folium.Map(location=[lat, lon], tiles="OpenStreetMap", zoom_start=zoom_start)
```

```{code-cell} ipython3
folium.Map(location=[lat, lon], tiles="Stamen Terrain", zoom_start=zoom_start)
```

```{code-cell} ipython3
folium.Map(location=[lat, lon], tiles="Stamen Toner", zoom_start=zoom_start)
```

```{code-cell} ipython3
folium.Map(location=[lat, lon], tiles="Stamen Watercolor", zoom_start=zoom_start)
```

```{code-cell} ipython3
folium.Map(location=[lat, lon], tiles="Cartodb Positron", zoom_start=zoom_start)
```
Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/ui_elements/icons.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ m
## Custom icon

```{code-cell} ipython3
m = folium.Map(location=[45.3288, -121.6625], zoom_start=12, tiles="Stamen Terrain")
m = folium.Map(location=[45.3288, -121.6625], zoom_start=12)

url = "https://leafletjs.com/examples/custom-icons/{}".format
icon_image = url("leaf-red.png")
Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/ui_elements/layer_control.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Add a control to the map to show or hide layers.
m = folium.Map(tiles=None)

folium.TileLayer("OpenStreetMap").add_to(m)
folium.TileLayer("stamentoner", show=False).add_to(m)
folium.TileLayer(show=False).add_to(m)

folium.LayerControl().add_to(m)

Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/vector_layers/polyline.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ lat = +38.89399
lon = -77.03659
zoom_start = 17

m = folium.Map(location=[lat, lon], tiles="stamen toner", zoom_start=zoom_start)
m = folium.Map(location=[lat, lon], zoom_start=zoom_start)

kw = {"color": "red", "fill": True, "radius": 20}

Expand Down
412 changes: 405 additions & 7 deletions examples/HeatMapWithTime.ipynb

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion folium/folium.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class Map(JSCSSMixin, MacroElement):
- "OpenStreetMap"
- "Mapbox Bright" (Limited levels of zoom for free tiles)
- "Mapbox Control Room" (Limited levels of zoom for free tiles)
- "Stamen" (Terrain, Toner, and Watercolor)
- "Cloudmade" (Must pass API key)
- "Mapbox" (Must pass API key)
- "CartoDB" (positron and dark_matter)
Expand Down
2 changes: 1 addition & 1 deletion folium/plugins/minimap.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MiniMap(JSCSSMixin, MacroElement):

Examples
--------
>>> MiniMap(tile_layer="Stamen WaterColor", position="bottomleft")
>>> MiniMap(position="bottomleft")
"""

_template = Template(
Expand Down
1 change: 0 additions & 1 deletion folium/raster_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class TileLayer(Layer):
tiles: str or :class:`xyzservices.TileProvider`, default 'OpenStreetMap'
Map tileset to use. Can choose from this list of built-in tiles:
- "OpenStreetMap"
- "Stamen Terrain", "Stamen Toner", "Stamen Watercolor"
- "CartoDB positron", "CartoDB dark_matter"

You can pass a custom tileset to Folium by passing a
Expand Down
1 change: 0 additions & 1 deletion folium/templates/tiles/stamenterrain/attr.txt

This file was deleted.

1 change: 0 additions & 1 deletion folium/templates/tiles/stamenterrain/tiles.txt

This file was deleted.

1 change: 0 additions & 1 deletion folium/templates/tiles/stamentoner/attr.txt

This file was deleted.

1 change: 0 additions & 1 deletion folium/templates/tiles/stamentoner/tiles.txt

This file was deleted.

1 change: 0 additions & 1 deletion folium/templates/tiles/stamentonerbackground/attr.txt

This file was deleted.

1 change: 0 additions & 1 deletion folium/templates/tiles/stamentonerbackground/tiles.txt

This file was deleted.

1 change: 0 additions & 1 deletion folium/templates/tiles/stamentonerlabels/attr.txt

This file was deleted.

1 change: 0 additions & 1 deletion folium/templates/tiles/stamentonerlabels/tiles.txt

This file was deleted.

1 change: 0 additions & 1 deletion folium/templates/tiles/stamenwatercolor/attr.txt

This file was deleted.

1 change: 0 additions & 1 deletion folium/templates/tiles/stamenwatercolor/tiles.txt

This file was deleted.

2 changes: 1 addition & 1 deletion tests/plugins/test_heat_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
def test_heat_map():
np.random.seed(3141592)
data = np.random.normal(size=(100, 2)) * np.array([[1, 1]]) + np.array([[48, 5]])
m = folium.Map([48.0, 5.0], tiles="stamentoner", zoom_start=6)
m = folium.Map([48.0, 5.0], zoom_start=6)
hm = HeatMap(data)
m.add_child(hm)
m._repr_html_()
Expand Down
2 changes: 1 addition & 1 deletion tests/plugins/test_heat_map_withtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_heat_map_with_time():
)
move_data = np.random.normal(size=(100, 2)) * 0.01
data = [(initial_data + move_data * i).tolist() for i in range(100)]
m = folium.Map([48.0, 5.0], tiles="stamentoner", zoom_start=6)
m = folium.Map([48.0, 5.0], zoom_start=6)
hm = plugins.HeatMapWithTime(data).add_to(m)

out = normalize(m._parent.render())
Expand Down
4 changes: 2 additions & 2 deletions tests/plugins/test_minimap.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def test_minimap():
assert "new L.Control.MiniMap" in out

m = folium.Map(location=(30, 20), zoom_start=4)
Conengmo marked this conversation as resolved.
Show resolved Hide resolved
minimap = plugins.MiniMap(tile_layer="Stamen Toner")
minimap = plugins.MiniMap()
minimap.add_to(m)

out = normalize(m._parent.render())
# verify that Stamen Toner tiles are being used
assert "https://stamen-tiles" in out
assert r"https://{s}.tile.openstreetmap.org" in out
2 changes: 1 addition & 1 deletion tests/plugins/test_tag_filter_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_tag_filter_button():
categories = [f"category{i + 1}" for i in range(n)]
category_column = [random.choice(categories) for i in range(len(initial_data))]
# Create map and add the data with additional parameter tags as the segmentation
m = folium.Map([48.0, 5.0], tiles="stamentoner", zoom_start=6)
m = folium.Map([48.0, 5.0], zoom_start=6)
for i, latlng in enumerate(initial_data):
category = category_column[i]
folium.Marker(tuple(latlng), tags=[category]).add_to(m)
Expand Down
2 changes: 1 addition & 1 deletion tests/plugins/test_time_slider_choropleth.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def norm(col):
for country, data in styledata.items()
}

m = folium.Map((0, 0), tiles="Stamen Watercolor", zoom_start=2)
m = folium.Map((0, 0), zoom_start=2)

time_slider_choropleth = TimeSliderChoropleth(gdf.to_json(), styledict)
time_slider_choropleth.add_to(m)
Expand Down
2 changes: 0 additions & 2 deletions tests/test_folium.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ def test_builtin_tile(self):

default_tiles = [
"OpenStreetMap",
"Stamen Terrain",
"Stamen Toner",
"CartoDB positron",
"CartoDB dark_matter",
]
Expand Down
12 changes: 7 additions & 5 deletions tests/test_raster_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


def test_tile_layer():
m = folium.Map([48.0, 5.0], tiles="stamentoner", zoom_start=6)
m = folium.Map([48.0, 5.0], zoom_start=6)
layer = "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"

folium.raster_layers.TileLayer(
Expand Down Expand Up @@ -114,22 +114,24 @@ def test_image_overlay():


def test_xyzservices():
m = folium.Map([48.0, 5.0], tiles=xyzservices.providers.Stamen.Toner, zoom_start=6)
m = folium.Map(
[48.0, 5.0], tiles=xyzservices.providers.CartoDB.DarkMatter, zoom_start=6
)

folium.raster_layers.TileLayer(
tiles=xyzservices.providers.Stamen.Terrain,
tiles=xyzservices.providers.CartoDB.Positron,
).add_to(m)
folium.LayerControl().add_to(m)

out = m._parent.render()
assert (
xyzservices.providers.Stamen.Toner.build_url(
xyzservices.providers.CartoDB.DarkMatter.build_url(
fill_subdomain=False, scale_factor="{r}"
)
in out
)
assert (
xyzservices.providers.Stamen.Terrain.build_url(
xyzservices.providers.CartoDB.Positron.build_url(
fill_subdomain=False, scale_factor="{r}"
)
in out
Expand Down