Skip to content
Merged
Changes from all commits
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
42 changes: 42 additions & 0 deletions examples/gallery/maps/tilemaps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
"""
Tile maps
---------
The :meth:`pygmt.Figure.tilemap` method allows to plot
tiles from a tile server or local file as a basemap or overlay.
"""
import contextily
import pygmt

fig = pygmt.Figure()
fig.tilemap(
region=[-157.84, -157.8, 21.255, 21.285],
projection="M12c",
# Set level of details (0-22)
# Higher levels mean a zoom level closer to the Earth's
# surface with more tiles covering a smaller
# geographic area and thus more details and vice versa
# Please note, not all zoom levels are always available
zoom=14,
# Use tiles from OpenStreetMap tile server
source="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
frame="afg",
)

fig.show()

###############################################################################
# It's also possible to use tiles provided via the
# `contextily <https://github.com/geopandas/contextily>`__
# library. See :doc:`Contextily providers <contextily:providers_deepdive>`
# for a list of possible tilemap options.

fig = pygmt.Figure()
fig.tilemap(
region=[-157.84, -157.8, 21.255, 21.285],
projection="M12c",
# Use the Stamen.Watercolor option from contextily
source=contextily.providers.Stamen.Watercolor,
frame="afg",
)

fig.show()