Skip to content

Commit

Permalink
Update stamen maps (#5967)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Nov 6, 2023
1 parent 0ca2aac commit 28e07fe
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 20 deletions.
6 changes: 4 additions & 2 deletions examples/reference/elements/bokeh/Tiles.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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:"
]
},
{
Expand All @@ -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."
]
},
{
Expand Down
24 changes: 21 additions & 3 deletions examples/reference/elements/plotly/Tiles.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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."
]
},
{
Expand Down
29 changes: 15 additions & 14 deletions holoviews/element/tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ def easting_northing_to_lon_lat(easting, northing):
'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, '
'&copy; <a href="https://cartodb.com/attributions">CartoDB</a>'
),
('stamen', 'net/t') : ( # to match both 'toner' and 'terrain'
'Map tiles by <a href="https://stamen.com">Stamen Design</a>, '
('stamen', 'png') : ( # to match both 'toner' and 'terrain'
'Map tiles by <a href="https://stamen.com">Stamen Design</a> / <a href="https://stadiamaps.com">Stadia Maps</a>, '
'under <a href="https://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. '
'Data by <a href="https://openstreetmap.org">OpenStreetMap</a>, '
'under <a href="https://www.openstreetmap.org/copyright">ODbL</a>.'
),
('stamen', 'watercolor') : (
'Map tiles by <a href="https://stamen.com">Stamen Design</a>, '
('stamen', 'jpg') : ( # watercolor
'Map tiles by <a href="https://stamen.com">Stamen Design</a> / <a href="https://stadiamaps.com">Stadia Maps</a>, '
'under <a href="https://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>. '
'Data by <a href="https://openstreetmap.org">OpenStreetMap</a>, '
'under <a href="https://creativecommons.org/licenses/by-sa/3.0">CC BY SA</a>.'
Expand Down Expand Up @@ -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")
Expand All @@ -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}
2 changes: 1 addition & 1 deletion holoviews/tests/plotting/plotly/test_tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 28e07fe

Please sign in to comment.