-
Notifications
You must be signed in to change notification settings - Fork 224
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
Conversation
/format |
/format |
/format |
Co-authored-by: Yvonne Fröhlich <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one, thanks @michaelgrund for adding this example! Just one comment for now.
Co-authored-by: Wei Ji <[email protected]>
Nice example! Do you think switching the order of the two examples makes more sense? I.e., the first example uses the tile providers available from contextily and the second is a more advanced example for people who wants to use custom tile servers that contextily doesn't provide ( |
Not sure, since contextily needs to be loaded additionally as a separate library, compared to the "direct" link to the custom tile servers. What do others think? |
I have no clear answer here, and I feel I am fine with both orders. Here are some thoughts or ideas, which are maybe helpful regarding a decision: Code example: (comments need definitly some improvement) import contextily
import pygmt
fig = pygmt.Figure()
# Default xyzservices.providers.Stamen.Terrain
fig.tilemap(
region=[-157.84, -157.8, 21.255, 21.285],
projection="M12c",
frame="af+e",
)
fig.shift_origin(xshift="13c")
fig.tilemap(
region=[-157.84, -157.8, 21.255, 21.285],
projection="M12c",
# Instead of Stamen.Terrain web tiles use the Stamen.Watercolor option
# from contextily
source=contextily.providers.Stamen.Watercolor,
frame=["wSne", "af+e"],
)
fig.show()
###############################################################################
# Instead of a web tile provider in the form of a xyzservices.TileProvider
# object use one in the form of a URL
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+e",
)
fig.show() |
Good idea! |
This is starting to sound like a tutorial instead of a gallery example 😅 Let's maybe keep to just 2 maps at a maximum instead of 3 for this gallery example. We can still show one using Note that the latter OpenStreetMap example is actually the same as using |
Why not extend it as a tutorial? |
Co-authored-by: Yvonne Fröhlich <[email protected]>
I think we should have both, gallery example and tutorial. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Approving this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am fine with having both gallery example and tutorial, as suggested by @michaelgrund. In this case, I feel @weiji14 is right, and the gallery example should be short. For the tutorial, I suggest considering also the lonlat
parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, let's open up a separate PR for a longer tutorial.
@michaelgrund do you also plan to add this tutorial, or @weiji14 do you want to work on this? |
Description of proposed changes
So far we don't promote the usage of tilemaps. Here's a gallery example to show its application using two different sources.
Preview: https://pygmt-dev--2585.org.readthedocs.build/en/2585/gallery/maps/tilemaps.html
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.Slash Commands
You can write slash commands (
/command
) in the first line of a comment to performspecific operations. Supported slash commands are:
/format
: automatically format and lint the code/test-gmt-dev
: run full tests on the latest GMT development version