Contextily 2: Other Image Providers

Overview:

  1. Explore contextily’s add_basemap function

  2. Access a variety of image sources via the contextily providers object

  3. Plot satellite imagery from NASA

Prerequisites

Concepts

Importance

Notes

Contextily 1

  • Time to learn: 20 minutes


Imports

import cartopy.crs as ccrs
import cartopy.feature as cfeature
from metpy.plots import USCOUNTIES
import contextily as ctx
import matplotlib.pyplot as plt

Explore contextily’s add_basemap function

In our previous notebook, we created a plot with contextily’s default basemap source (Openstreetmaps). Here, we will do the same, over a variety of regions.

Create a Python dictionary that pairs three regions with their corresponding lat-lon boundaries.

extents = {'conus':[-125,-63,23,52],'nys':[-80, -72,40.5,45.2], 'alb':[-73.946,-73.735,42.648,42.707]}
extents 
{'conus': [-125, -63, 23, 52],
 'nys': [-80, -72, 40.5, 45.2],
 'alb': [-73.946, -73.735, 42.648, 42.707]}
Note: Python dictionaries are one of the language's core datatypes. Similar to a traditional dictionary, it consists of one or more "words" (termed keys in Python) followed by the corresponding "definitions" (termed values in Python).

Show the keys, followed by the values, of this dictionary.

extents.keys()
dict_keys(['conus', 'nys', 'alb'])
extents.values()
dict_values([[-125, -63, 23, 52], [-80, -72, 40.5, 45.2], [-73.946, -73.735, 42.648, 42.707]])

Display the default Contextily basemap for each region.

We’ll use what’s called a dictionary comprehension to loop over each region.

for key in extents:
    print(key,extents[key])

    fig = plt.figure(figsize=(15,10))
    ax = plt.axes(projection=ccrs.epsg('3857'))

    res='50m'
    plt.title('Default Contextily Basemap: '+ key)
    ax.coastlines(resolution=res)

    ax.add_feature (cfeature.LAKES.with_scale(res), alpha = 0.5)
    ax.add_feature (cfeature.STATES.with_scale(res))
    ax.set_extent(extents[key], ccrs.PlateCarree())
    ctx.add_basemap(ax)
    plt.show()
conus [-125, -63, 23, 52]
../../_images/87e2d52eaeaa2fb4c207f0beea13dc3c1c9973a99165f4964c7431b3191d2779.png
nys [-80, -72, 40.5, 45.2]
../../_images/14ad03357489933be048cd350307ede9d1e875c93690dae413e82a6c0e854f81.png
alb [-73.946, -73.735, 42.648, 42.707]
../../_images/80c22ca95ed901982a3c0574af5e95ea25aa856f263defeeebe78aa22572f3e2.png

We can see that the same basemap (hosted by OpenStreetMap France) appears, at zoom values automatically determined based on the plotted geographical extent. Notice the street-level resolution for the Albany region.

Access a variety of Contextily’s tile providers.

We use Contextily’s providers method. It returns a dictionary. Let’s view that dictionary’s keys:

ctx.providers.keys()
dict_keys(['OpenStreetMap', 'MapTilesAPI', 'OpenSeaMap', 'OPNVKarte', 'OpenTopoMap', 'OpenRailwayMap', 'OpenFireMap', 'SafeCast', 'Stadia', 'Thunderforest', 'CyclOSM', 'Jawg', 'MapBox', 'MapTiler', 'Stamen', 'TomTom', 'Esri', 'OpenWeatherMap', 'HERE', 'HEREv3', 'FreeMapSK', 'MtbMap', 'CartoDB', 'HikeBike', 'BasemapAT', 'nlmaps', 'NASAGIBS', 'NLS', 'JusticeMap', 'GeoportailFrance', 'OneMapSG', 'USGS', 'WaymarkedTrails', 'OpenAIP', 'OpenSnowMap', 'AzureMaps', 'SwissFederalGeoportal', 'Gaode', 'Strava', 'OrdnanceSurvey'])

Let’s look at a couple of these providers in more detail. First, CartoDB:

ctx.providers.CartoDB
xyzservices.Bunch
10 items
  • xyzservices.TileProvider
    CartoDB.Positron
    url
    https://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}{r}.png
    html_attribution
    © OpenStreetMap contributors © CARTO
    attribution
    (C) OpenStreetMap contributors (C) CARTO
    subdomains
    abcd
    max_zoom
    20
    variant
    light_all
  • xyzservices.TileProvider
    CartoDB.PositronNoLabels
    url
    https://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}{r}.png
    html_attribution
    © OpenStreetMap contributors © CARTO
    attribution
    (C) OpenStreetMap contributors (C) CARTO
    subdomains
    abcd
    max_zoom
    20
    variant
    light_nolabels
  • xyzservices.TileProvider
    CartoDB.PositronOnlyLabels
    url
    https://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}{r}.png
    html_attribution
    © OpenStreetMap contributors © CARTO
    attribution
    (C) OpenStreetMap contributors (C) CARTO
    subdomains
    abcd
    max_zoom
    20
    variant
    light_only_labels
  • xyzservices.TileProvider
    CartoDB.DarkMatter
    url
    https://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}{r}.png
    html_attribution
    © OpenStreetMap contributors © CARTO
    attribution
    (C) OpenStreetMap contributors (C) CARTO
    subdomains
    abcd
    max_zoom
    20
    variant
    dark_all
  • xyzservices.TileProvider
    CartoDB.DarkMatterNoLabels
    url
    https://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}{r}.png
    html_attribution
    © OpenStreetMap contributors © CARTO
    attribution
    (C) OpenStreetMap contributors (C) CARTO
    subdomains
    abcd
    max_zoom
    20
    variant
    dark_nolabels
  • xyzservices.TileProvider
    CartoDB.DarkMatterOnlyLabels
    url
    https://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}{r}.png
    html_attribution
    © OpenStreetMap contributors © CARTO
    attribution
    (C) OpenStreetMap contributors (C) CARTO
    subdomains
    abcd
    max_zoom
    20
    variant
    dark_only_labels
  • xyzservices.TileProvider
    CartoDB.Voyager
    url
    https://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}{r}.png
    html_attribution
    © OpenStreetMap contributors © CARTO
    attribution
    (C) OpenStreetMap contributors (C) CARTO
    subdomains
    abcd
    max_zoom
    20
    variant
    rastertiles/voyager
  • xyzservices.TileProvider
    CartoDB.VoyagerNoLabels
    url
    https://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}{r}.png
    html_attribution
    © OpenStreetMap contributors © CARTO
    attribution
    (C) OpenStreetMap contributors (C) CARTO
    subdomains
    abcd
    max_zoom
    20
    variant
    rastertiles/voyager_nolabels
  • xyzservices.TileProvider
    CartoDB.VoyagerOnlyLabels
    url
    https://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}{r}.png
    html_attribution
    © OpenStreetMap contributors © CARTO
    attribution
    (C) OpenStreetMap contributors (C) CARTO
    subdomains
    abcd
    max_zoom
    20
    variant
    rastertiles/voyager_only_labels
  • xyzservices.TileProvider
    CartoDB.VoyagerLabelsUnder
    url
    https://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}{r}.png
    html_attribution
    © OpenStreetMap contributors © CARTO
    attribution
    (C) OpenStreetMap contributors (C) CARTO
    subdomains
    abcd
    max_zoom
    20
    variant
    rastertiles/voyager_labels_under

We see that CartoDB has several options itself. For each option, there are several default attributes, such as name and max_zoom.

Display two different CartoDB basemaps.

We’ll use the source argument for add_basemap via Contextily’s providers object.

bm = {'CartoDB.Positron': ctx.providers.CartoDB.Positron,
      'CartoDB.DarkMatter': ctx.providers.CartoDB.DarkMatter}
for key in bm:
    print (key,bm[key])
    
    fig = plt.figure(figsize=(15,10))
    ax = plt.axes(projection=ccrs.epsg('3857'))

    res='50m'
    plt.title(key)
    ax.coastlines(resolution=res)

    ax.add_feature (cfeature.LAKES.with_scale(res), alpha = 0.5)
    ax.add_feature (cfeature.STATES.with_scale(res))

    ax.set_extent(extents['conus'], ccrs.PlateCarree())
    ctx.add_basemap(ax,source=bm[key])
    plt.show()
CartoDB.Positron {'url': 'https://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}{r}.png', 'html_attribution': '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors &copy; <a href="https://carto.com/attributions">CARTO</a>', 'attribution': '(C) OpenStreetMap contributors (C) CARTO', 'subdomains': 'abcd', 'max_zoom': 20, 'variant': 'light_all', 'name': 'CartoDB.Positron'}
../../_images/683474d3fcd4387c2a1487ac8e519ba58864b8f3eb37f625ac0110b2160d39b0.png
CartoDB.DarkMatter {'url': 'https://{s}.basemaps.cartocdn.com/{variant}/{z}/{x}/{y}{r}.png', 'html_attribution': '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors &copy; <a href="https://carto.com/attributions">CARTO</a>', 'attribution': '(C) OpenStreetMap contributors (C) CARTO', 'subdomains': 'abcd', 'max_zoom': 20, 'variant': 'dark_all', 'name': 'CartoDB.DarkMatter'}
../../_images/6a272c37dfc2e62416a9aa47c55ac2504734dcf95302ba2396ff7f060496b4f8.png

Next, let’s check out NASAGIBS.

Display the 2012 Earth at Night basemap.

ctx.providers.NASAGIBS
xyzservices.Bunch
15 items
  • xyzservices.TileProvider
    NASAGIBS.ModisTerraTrueColorCR
    url
    https://map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{max_zoom}/{z}/{y}/{x}.{format}
    html_attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    bounds
    [[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]]
    min_zoom
    1
    max_zoom
    9
    format
    jpg
    time
    tilematrixset
    GoogleMapsCompatible_Level
    variant
    MODIS_Terra_CorrectedReflectance_TrueColor
  • xyzservices.TileProvider
    NASAGIBS.ModisTerraBands367CR
    url
    https://map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{max_zoom}/{z}/{y}/{x}.{format}
    html_attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    bounds
    [[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]]
    min_zoom
    1
    max_zoom
    9
    format
    jpg
    time
    tilematrixset
    GoogleMapsCompatible_Level
    variant
    MODIS_Terra_CorrectedReflectance_Bands367
  • xyzservices.TileProvider
    NASAGIBS.ViirsEarthAtNight2012
    url
    https://map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{max_zoom}/{z}/{y}/{x}.{format}
    html_attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    bounds
    [[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]]
    min_zoom
    1
    max_zoom
    8
    format
    jpg
    time
    tilematrixset
    GoogleMapsCompatible_Level
    variant
    VIIRS_CityLights_2012
  • xyzservices.TileProvider
    NASAGIBS.ModisTerraLSTDay
    url
    https://map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{max_zoom}/{z}/{y}/{x}.{format}
    html_attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    bounds
    [[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]]
    min_zoom
    1
    max_zoom
    7
    format
    png
    time
    tilematrixset
    GoogleMapsCompatible_Level
    variant
    MODIS_Terra_Land_Surface_Temp_Day
    opacity
    0.75
  • xyzservices.TileProvider
    NASAGIBS.ModisTerraSnowCover
    url
    https://map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{max_zoom}/{z}/{y}/{x}.{format}
    html_attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    bounds
    [[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]]
    min_zoom
    1
    max_zoom
    8
    format
    png
    time
    tilematrixset
    GoogleMapsCompatible_Level
    variant
    MODIS_Terra_NDSI_Snow_Cover
    opacity
    0.75
  • xyzservices.TileProvider
    NASAGIBS.ModisTerraAOD
    url
    https://map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{max_zoom}/{z}/{y}/{x}.{format}
    html_attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    bounds
    [[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]]
    min_zoom
    1
    max_zoom
    6
    format
    png
    time
    tilematrixset
    GoogleMapsCompatible_Level
    variant
    MODIS_Terra_Aerosol
    opacity
    0.75
  • xyzservices.TileProvider
    NASAGIBS.ModisTerraChlorophyll
    url
    https://map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{max_zoom}/{z}/{y}/{x}.{format}
    html_attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    bounds
    [[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]]
    min_zoom
    1
    max_zoom
    7
    format
    png
    time
    tilematrixset
    GoogleMapsCompatible_Level
    variant
    MODIS_Terra_Chlorophyll_A
    opacity
    0.75
  • xyzservices.TileProvider
    NASAGIBS.ModisTerraBands721CR
    url
    https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/MODIS_Terra_CorrectedReflectance_Bands721/default/{time}/GoogleMapsCompatible_Level9/{z}/{y}/{x}.jpg
    max_zoom
    9
    attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    html_attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    time
  • xyzservices.TileProvider
    NASAGIBS.ModisAquaTrueColorCR
    url
    https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/MODIS_Aqua_CorrectedReflectance_TrueColor/default/{time}/GoogleMapsCompatible_Level9/{z}/{y}/{x}.jpg
    max_zoom
    9
    attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    html_attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    time
  • xyzservices.TileProvider
    NASAGIBS.ModisAquaBands721CR
    url
    https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/MODIS_Aqua_CorrectedReflectance_Bands721/default/{time}/GoogleMapsCompatible_Level9/{z}/{y}/{x}.jpg
    max_zoom
    9
    attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    html_attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    time
  • xyzservices.TileProvider
    NASAGIBS.ViirsTrueColorCR
    url
    https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/VIIRS_SNPP_CorrectedReflectance_TrueColor/default/{time}/GoogleMapsCompatible_Level9/{z}/{y}/{x}.jpg
    max_zoom
    9
    attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    html_attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    time
  • xyzservices.TileProvider
    NASAGIBS.BlueMarble3413
    url
    https://gibs.earthdata.nasa.gov/wmts/epsg3413/best/BlueMarble_NextGeneration/default/EPSG3413_500m/{z}/{y}/{x}.jpeg
    max_zoom
    5
    attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    html_attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    crs
    EPSG:3413
  • xyzservices.TileProvider
    NASAGIBS.BlueMarble3031
    url
    https://gibs.earthdata.nasa.gov/wmts/epsg3031/best/BlueMarble_NextGeneration/default/EPSG3031_500m/{z}/{y}/{x}.jpeg
    max_zoom
    5
    attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    html_attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    crs
    EPSG:3031
  • xyzservices.TileProvider
    NASAGIBS.BlueMarble
    url
    https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/BlueMarble_NextGeneration/default/EPSG3857_500m/{z}/{y}/{x}.jpeg
    max_zoom
    8
    attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    html_attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
  • xyzservices.TileProvider
    NASAGIBS.ASTER_GDEM_Greyscale_Shaded_Relief
    url
    https://gibs.earthdata.nasa.gov/wmts/epsg3857/best/ASTER_GDEM_Greyscale_Shaded_Relief/default/GoogleMapsCompatible_Level12/{z}/{y}/{x}.jpg
    max_zoom
    12
    attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
    html_attribution
    Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
prov = ctx.providers.NASAGIBS.ViirsEarthAtNight2012
fig = plt.figure(figsize=(15,10))
ax = plt.axes(projection=ccrs.epsg('3857'))

res='50m'
plt.title(prov.name)
ax.coastlines(resolution=res)

ax.add_feature (cfeature.LAKES.with_scale(res), alpha = 0.5)
ax.add_feature (cfeature.STATES.with_scale(res))

ax.set_extent(extents['conus'], ccrs.PlateCarree())
ctx.add_basemap(ax,source=prov)
../../_images/a0b8161d0915603fd0cbd765d2032725ed90da6354a0153d9c88cefe849b436f.png

Cool! Now let’s plot the MODIS True Color satellite mosaic.

Plot satellite imagery from NASA’s Modis and Terra satellites.

prov = ctx.providers.NASAGIBS.ModisTerraTrueColorCR
fig = plt.figure(figsize=(15,10))
ax = plt.axes(projection=ccrs.epsg('3857'))

res='50m'
plt.title(prov.name)
ax.coastlines(resolution=res)

ax.add_feature (cfeature.LAKES.with_scale(res), alpha = 0.5)
ax.add_feature (cfeature.STATES.with_scale(res))

ax.set_extent(extents['conus'], ccrs.PlateCarree())
ctx.add_basemap(ax,source=prov)
../../_images/24a072ede078b9307c05a66ac47708b54516139bc8a1ffd2e5b1de6c2b100dd3.png

You might see a satellite image, but you might not … and if you do, it might not be current. What’s up with that?

Let’s look specifically at the dictionary corresponding to this satellite product.

ctx.providers.NASAGIBS.ModisTerraTrueColorCR
xyzservices.TileProvider
NASAGIBS.ModisTerraTrueColorCR
url
https://map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{max_zoom}/{z}/{y}/{x}.{format}
html_attribution
Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
attribution
Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.
bounds
[[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]]
min_zoom
1
max_zoom
9
format
jpg
time
tilematrixset
GoogleMapsCompatible_Level
variant
MODIS_Terra_CorrectedReflectance_TrueColor

The time attribute is blank. This product is actually updated once a day, so let’s pick a particular day.

prov = ctx.providers.NASAGIBS.ModisTerraTrueColorCR
fig = plt.figure(figsize=(15,10))
ax = plt.axes(projection=ccrs.epsg('3857'))

time = '2023-10-15'
res='50m'
plt.title(prov.name + ' ' + time)
ax.coastlines(resolution=res)

ax.add_feature (cfeature.LAKES.with_scale(res), alpha = 0.5)
ax.add_feature (cfeature.STATES.with_scale(res))

ax.set_extent(extents['conus'], ccrs.PlateCarree())
ctx.add_basemap(ax,source=prov(time=time))
../../_images/fd464674bbbb643e84ad45f1deca1fbb50b362ba1ae6492b36fe118978dffb97.png
Oct 2022 Terra outage: Daily imagery will be unavailable from 10 Oct through at least 19 Oct 2022: see this NASA link

On your own, explore some of the other providers. Some, such as OpenWeatherMap and Mapbox, require you to register for an API key, but have free access plans.


Summary

  • Contextily provides a number of attractive, tiled basemap images.

What’s Next?

We’ll add interactivity to our visualizations, starting with the ipyleaflet package.