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 an example of the use of pygmt.grdgradient #1425

Closed
yohaimagen opened this issue Aug 9, 2021 · 3 comments · Fixed by #1428
Closed

Add an example of the use of pygmt.grdgradient #1425

yohaimagen opened this issue Aug 9, 2021 · 3 comments · Fixed by #1428
Assignees
Labels
documentation Improvements or additions to documentation
Milestone

Comments

@yohaimagen
Copy link
Contributor

yohaimagen commented Aug 9, 2021

I noticed that there are no examples of the usage of pygmt.grdgradient and a function without examples is much harder to utiles by new users.

I suggest adding an example of making an hillshade map using pygmt.grdgradient as so:

grid = pygmt.datasets.load_earth_relief(resolution="01m", region=[-14, 30, 35, 60])
dgrid = pygmt.grdgradient(grid=grid, azimuth='90/10')
fig = pygmt.Figure()
pygmt.makecpt(cmap='gray', series=[-1.5, 1, 0.01])
fig.grdimage(grid=dgrid, projection="M5c", frame="a", cmap=True)
fig.colorbar(frame=["a1000", "x+lElevation", "y+lm"])
fig.show()

europe_hilshade

this example can be an extension to the Earth relief tutorial or as a separate gallery example.

Are you willing to help implement and maintain this feature? Yes

@yohaimagen yohaimagen added the feature request New feature wanted label Aug 9, 2021
@weiji14 weiji14 added documentation Improvements or additions to documentation and removed feature request New feature wanted labels Aug 9, 2021
@weiji14
Copy link
Member

weiji14 commented Aug 9, 2021

Cool, this is a good idea! My only suggestion would be to either 1) use a smaller region rather than the whole of Europe if you want to use a high resolution map or 2) keep things to a low resolution (e.g. 10 arc minutes). Mainly because grdgradient can be a processing intensive task that can take some time to run.

@seisman
Copy link
Member

seisman commented Aug 10, 2021

I suggest adding an example of making an hillshade map using pygmt.grdgradient as so:

grid = pygmt.datasets.load_earth_relief(resolution="01m", region=[-14, 30, 35, 60])
dgrid = pygmt.grdgradient(grid=grid, azimuth='90/10')
fig = pygmt.Figure()
pygmt.makecpt(cmap='gray', series=[-1.5, 1, 0.01])
fig.grdimage(grid=dgrid, projection="M5c", frame="a", cmap=True)
fig.colorbar(frame=["a1000", "x+lElevation", "y+lm"])
fig.show()

If I understand "hillshade" correctly, this script does not produce a hillshade map. Usually, we need to pass the DEM grid to the grid parameter and a gradient/intensity grid to the shading parameter.

this example can be an extension to the Earth relief tutorial or as a separate gallery example.

I agree we should extend the tutorial to show how to add shading to the earth relief map. I think the easiest way is simply adding shading=True to the grdimage call.

@yohaimagen
Copy link
Contributor Author

I can do both, extend the tutorial with an example that uses shading=True which gives nice output and does not overpopulate the tutorial. from this section of the tutorial, we could refer to a gallery example with more specific use of grdgradient(shading=True use grdgradient to produce intensity grid file)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants