From 28e07fe271917fec52e017144a9bc7965618e779 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20H=C3=B8xbro=20Hansen?= Date: Mon, 6 Nov 2023 12:03:38 +0100 Subject: [PATCH] Update stamen maps (#5967) --- examples/reference/elements/bokeh/Tiles.ipynb | 6 ++-- .../reference/elements/plotly/Tiles.ipynb | 24 +++++++++++++-- holoviews/element/tiles.py | 29 ++++++++++--------- holoviews/tests/plotting/plotly/test_tiles.py | 2 +- 4 files changed, 41 insertions(+), 20 deletions(-) diff --git a/examples/reference/elements/bokeh/Tiles.ipynb b/examples/reference/elements/bokeh/Tiles.ipynb index 04aa4ea4ed..979e898a0a 100644 --- a/examples/reference/elements/bokeh/Tiles.ipynb +++ b/examples/reference/elements/bokeh/Tiles.ipynb @@ -61,7 +61,9 @@ "> See [`hv.util.transform.lon_lat_to_easting_northing(longitude, latitude)`](https://holoviews.org/reference_manual/holoviews.element.html?highlight=lon_lat_to_easting_northing#holoviews.element.Tiles.lon_lat_to_easting_northing)\n", ">\n", "\n", - "Both HoloViews and GeoViews provides a number of tile sources by default, provided by CartoDB, Stamen, OpenStreetMap, and Esri. These can be imported from the ``holoviews.element.tiles`` module and are provided as callable functions which return a ``Tiles`` element:" + "Both HoloViews and GeoViews provides a number of tile sources by default, provided by CartoDB, OpenStreetMap, and Esri. Stamen tile sources are also available but require a Stadia account when not running locally; see [stadiamaps.com](https://stadiamaps.com/).\n", + "\n", + "Tile sources can be imported from the ``holoviews.element.tiles`` module and are provided as callable functions which return a ``Tiles`` element:" ] }, { @@ -77,7 +79,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "The full set of predefined tile sources can be accessed on the ``holoviews.element.tiles.tile_sources`` dictionary." + "The full set of predefined tile sources can be accessed on the ``holoviews.element.tiles.tile_sources`` and ``holoviews.element.tiles.stamen_sources`` dictionaries." ] }, { diff --git a/examples/reference/elements/plotly/Tiles.ipynb b/examples/reference/elements/plotly/Tiles.ipynb index 6b5dbc7303..28ed2be94d 100644 --- a/examples/reference/elements/plotly/Tiles.ipynb +++ b/examples/reference/elements/plotly/Tiles.ipynb @@ -51,16 +51,34 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "One thing to note about tile sources is that they are always defined in the [pseudo-Mercator projection](https://epsg.io/3857), which means that if you want to overlay any data on top of a tile source the values have to be expressed as eastings and northings. If you have data in another projection, e.g. latitudes and longitudes, it may make sense to use [GeoViews](http://geoviews.org/) for it to handle the projections for you.\n", + "One thing to note about tile sources is that they are always defined in the [pseudo-Mercator projection](https://epsg.io/3857), which means that if you want to overlay any data on top of a tile source the values have to be expressed as eastings and northings. If you have data in another projection, e.g. latitudes and longitudes, it may make sense to use [GeoViews](https://geoviews.org/) for it to handle the projections for you.\n", "\n", - "Both HoloViews and GeoViews provides a number of tile sources by default, provided by CartoDB, Stamen, OpenStreetMap, and Esri. These can be imported from the ``holoviews.element.tiles`` module and are provided as callable functions that return a ``Tiles`` element:" + ">\n", + "> **Note**: \n", + "> \n", + "> Holoviews provides functions to project longitude, latitude into Web Mercator coordinates. \n", + "> See [`hv.util.transform.lon_lat_to_easting_northing(longitude, latitude)`](https://holoviews.org/reference_manual/holoviews.element.html?highlight=lon_lat_to_easting_northing#holoviews.element.Tiles.lon_lat_to_easting_northing)\n", + ">\n", + "\n", + "Both HoloViews and GeoViews provides a number of tile sources by default, provided by CartoDB, OpenStreetMap, and Esri. Stamen tile sources are also available but require a Stadia account when not running locally; see [stadiamaps.com](https://stadiamaps.com/).\n", + "\n", + "Tile sources can be imported from the ``holoviews.element.tiles`` module and are provided as callable functions which return a ``Tiles`` element:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hv.element.tiles.EsriImagery().opts(width=600, height=550)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "The full set of predefined tile sources can be accessed on the ``holoviews.element.tiles.tile_sources`` dictionary:" + "The full set of predefined tile sources can be accessed on the ``holoviews.element.tiles.tile_sources`` and ``holoviews.element.tiles.stamen_sources`` dictionaries." ] }, { diff --git a/holoviews/element/tiles.py b/holoviews/element/tiles.py index 1497ff1ad7..e9c01b61e5 100644 --- a/holoviews/element/tiles.py +++ b/holoviews/element/tiles.py @@ -85,14 +85,14 @@ def easting_northing_to_lon_lat(easting, northing): '© OpenStreetMap contributors, ' '© CartoDB' ), - ('stamen', 'net/t') : ( # to match both 'toner' and 'terrain' - 'Map tiles by Stamen Design, ' + ('stamen', 'png') : ( # to match both 'toner' and 'terrain' + 'Map tiles by Stamen Design / Stadia Maps, ' 'under CC BY 3.0. ' 'Data by OpenStreetMap, ' 'under ODbL.' ), - ('stamen', 'watercolor') : ( - 'Map tiles by Stamen Design, ' + ('stamen', 'jpg') : ( # watercolor + 'Map tiles by Stamen Design / Stadia Maps, ' 'under CC BY 3.0. ' 'Data by OpenStreetMap, ' 'under CC BY SA.' @@ -132,15 +132,15 @@ def easting_northing_to_lon_lat(easting, northing): # Stamen basemaps -StamenTerrain = lambda: Tiles('https://stamen-tiles.a.ssl.fastly.net/terrain/{Z}/{X}/{Y}.png', name="StamenTerrain") -StamenTerrainRetina = lambda: Tiles('https://stamen-tiles.a.ssl.fastly.net/terrain/{Z}/{X}/{Y}@2x.png', name="StamenTerrainRetina") -StamenWatercolor = lambda: Tiles('https://stamen-tiles.a.ssl.fastly.net/watercolor/{Z}/{X}/{Y}.jpg', name="StamenWatercolor") -StamenToner = lambda: Tiles('https://stamen-tiles.a.ssl.fastly.net/toner/{Z}/{X}/{Y}.png', name="StamenToner") -StamenTonerRetina = lambda: Tiles('https://stamen-tiles.a.ssl.fastly.net/toner/{Z}/{X}/{Y}@2x.png', name="StamenTonerRetina") -StamenTonerBackground = lambda: Tiles('https://stamen-tiles.a.ssl.fastly.net/toner-background/{Z}/{X}/{Y}.png', name="StamenTonerBackground") -StamenTonerBackgroundRetina = lambda: Tiles('https://stamen-tiles.a.ssl.fastly.net/toner-background/{Z}/{X}/{Y}@2x.png', name="StamenTonerBackgroundRetina") -StamenLabels = lambda: Tiles('https://stamen-tiles.a.ssl.fastly.net/toner-labels/{Z}/{X}/{Y}.png', name="StamenLabels") -StamenLabelsRetina = lambda: Tiles('https://stamen-tiles.a.ssl.fastly.net/toner-labels/{Z}/{X}/{Y}@2x.png', name="StamenLabelsRetina") +StamenTerrain = lambda: Tiles('https://tiles.stadiamaps.com/tiles/stamen_terrain/{Z}/{X}/{Y}.png', name="StamenTerrain") +StamenTerrainRetina = lambda: Tiles('https://tiles.stadiamaps.com/tiles/stamen_terrain/{Z}/{X}/{Y}@2x.png', name="StamenTerrainRetina") +StamenWatercolor = lambda: Tiles('https://tiles.stadiamaps.com/tiles/stamen_watercolor/{Z}/{X}/{Y}.jpg', name="StamenWatercolor") +StamenToner = lambda: Tiles('https://tiles.stadiamaps.com/tiles/stamen_toner/{Z}/{X}/{Y}.png', name="StamenToner") +StamenTonerRetina = lambda: Tiles('https://tiles.stadiamaps.com/tiles/stamen_toner/{Z}/{X}/{Y}@2x.png', name="StamenTonerRetina") +StamenTonerBackground = lambda: Tiles('https://tiles.stadiamaps.com/tiles/stamen_toner_background/{Z}/{X}/{Y}.png', name="StamenTonerBackground") +StamenTonerBackgroundRetina = lambda: Tiles('https://tiles.stadiamaps.com/tiles/stamen_toner_background/{Z}/{X}/{Y}@2x.png', name="StamenTonerBackgroundRetina") +StamenLabels = lambda: Tiles('https://tiles.stadiamaps.com/tiles/stamen_toner_labels/{Z}/{X}/{Y}.png', name="StamenLabels") +StamenLabelsRetina = lambda: Tiles('https://tiles.stadiamaps.com/tiles/stamen_toner_labels/{Z}/{X}/{Y}@2x.png', name="StamenLabelsRetina") # Esri maps (see https://server.arcgisonline.com/arcgis/rest/services for the full list) EsriImagery = lambda: Tiles('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}.jpg', name="EsriImagery") @@ -160,4 +160,5 @@ def easting_northing_to_lon_lat(easting, northing): ['ESRI', 'lon_lat_to_easting_northing', 'easting_northing_to_lon_lat', 'deprecation_warning', 'wikimedia_replacement']} -tile_sources = {k: v for k, v in _all_tile_sources.items()} +tile_sources = {k: v for k, v in _all_tile_sources.items() if "Stamen" not in k} +stamen_sources = {k: v for k, v in _all_tile_sources.items() if "Stamen" in k} diff --git a/holoviews/tests/plotting/plotly/test_tiles.py b/holoviews/tests/plotting/plotly/test_tiles.py index f6cd41cbd0..8155fc8c79 100644 --- a/holoviews/tests/plotting/plotly/test_tiles.py +++ b/holoviews/tests/plotting/plotly/test_tiles.py @@ -102,7 +102,7 @@ def test_raster_layer(self): self.assertEqual(layer["sourcetype"], "raster") self.assertEqual(layer["minzoom"], 3) self.assertEqual(layer["maxzoom"], 7) - self.assertEqual(layer["sourceattribution"], _ATTRIBUTIONS[('stamen', 'net/t')]) + self.assertEqual(layer["sourceattribution"], _ATTRIBUTIONS[('stamen', 'png')]) # xyzservices input def test_xyzservices_tileprovider(self):