Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gallery example to show usage of tile maps #2585

Merged
merged 16 commits into from
Jul 12, 2023
Merged
36 changes: 36 additions & 0 deletions examples/gallery/maps/tilemaps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""
Tilemaps
--------
michaelgrund marked this conversation as resolved.
Show resolved Hide resolved
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",
zoom=14,
michaelgrund marked this conversation as resolved.
Show resolved Hide resolved
# 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.
michaelgrund marked this conversation as resolved.
Show resolved Hide resolved

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()