You can configure global Lets-Plot options using the LestPlot.set(dictionary)
method.
Where the dictionary
can contain all sorts of Lets-Plot options, including basemap tiles configuration options.
Lets-Plot provides a variety of constantas and functions which make configuring of basemap tiles simple:
from lets_plot import tilesets
LetsPlot.set(tilesets.LETS_PLOT_DARK)
Use tiles
parameter in the geom_livemap()
function:
from lets_plot import tilesets
ggplot() + geom_livemap(tiles=tilesets.LETS_PLOT_DARK)
In this demo we will be using the tiles
parameter because each plot here is using different map-tile service.
from lets_plot import *
from lets_plot import tilesets
LetsPlot.setup_html()
def show_map(text, tiles=None):
(ggplot() + geom_livemap(location=[13.3, 37.6], zoom=3, tiles=tiles) +
ggsize(500, 450) +
ggtitle(text)).show()
Lets-Plot provides its own vector basemap tiles available in four variants:
By default Lets-Plot uses its "color" tiles.
show_map("Lets-Plot vector tiles (default).")
show_map("Lets-Plot vector tiles (dark).", tilesets.LETS_PLOT_DARK)
show_map("Lets-Plot vector tiles (light).", tilesets.LETS_PLOT_LIGHT)
show_map("Lets-Plot vector tiles (bw).", tilesets.LETS_PLOT_BW)
You can use ZXY
raster tiles provided by 3rd party maptile services.
Some services provide free of charge raster tilesets.
The tilesets
module in Lets-Plot contains many such tilesets pre-cofigured.
show_map("OpenStreetMap's Standard tile layer", tilesets.OSM)
Map data: © OpenStreetMap contributors, SRTM | map style: © OpenTopoMap (CC-BY-SA)
show_map("OpenTopoMap", tilesets.OPEN_TOPO_MAP)
© OpenStreetMap contributors © CARTO, © CARTO
Free for none-commercial services only (see Limitations, License).
show_map("CARTO Positron", tilesets.CARTO_POSITRON_HIRES)
show_map("CARTO Positron (no labels)", tilesets.CARTO_POSITRON_NO_LABELS_HIRES)
show_map("CARTO Dark Matter (no labels)", tilesets.CARTO_DARK_MATTER_NO_LABELS_HIRES)
show_map("CARTO Voyager", tilesets.CARTO_VOYAGER_HIRES)
show_map("CARTO Flat Blue", tilesets.CARTO_FLAT_BLUE)
show_map("CARTO Midnight commander", tilesets.CARTO_MIDNIGHT_COMMANDER)
show_map("CARTO Antique", tilesets.CARTO_ANTIQUE_HIRES)
Imagery provided by services from NASA's Global Imagery Browse Services (GIBS), part of NASA's Earth Observing System Data and Information System (EOSDIS).
NASA's Global Imagery Browse Services (GIBS).
Global Imagery Browse Services (GIBS) - API for Developers.
Global Imagery Browse Services (GIBS) API - Generic XYZ Tile Access.
show_map("NASA GIBS: CityLights 2012", tilesets.NASA_CITYLIGHTS_2012)
show_map("NASA GIBS: Greyscale Shaded Relief (30m)", tilesets.NASA_GREYSCALE_SHADED_RELIEF_30M)
show_map("NASA GIBS: Color Shaded Relief (30m)", tilesets.NASA_COLOR_SHADED_RELIEF_30M)
show_map("NASA GIBS: Terra TrueColor", tilesets.NASA_TERRA_TRUECOLOR)
In addition to pre-configured tilesets you can configure and use almost any other raster tilesets provided in ZXY
format.
You can do it with the help of the LetsPlot.maptiles_zxy()
function.
The following code will configure 'NASA, CityLights 2012' tiles:
settings = dict(
url = "https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/VIIRS_CityLights_2012/default/GoogleMapsCompatible_Level8/{z}/{y}/{x}.jpg",
attribution = '<a href="https://earthdata.nasa.gov/eosdis/science-system-description/eosdis-components/gibs">© NASA Global Imagery Browse Services (GIBS)</a>',
max_zoom=8
)
show_map("NASA, CityLights 2012", maptiles_zxy(**settings))