Skip to content

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

Closed

Description

@yohaimagen

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

Activity

  1. added
    documentation
    and removed
    feature request
    on Aug 9, 2021
  2. weiji14 commented on Aug 9, 2021

    @weiji14
    Member

    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.

  3. seisman commented on Aug 10, 2021

    @seisman
    Member

    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.

  4. yohaimagen commented on Aug 10, 2021

    @yohaimagen
    ContributorAuthor

    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)

  5. self-assigned this
    on Aug 10, 2021
  6. added this to the 0.5.0 milestone on Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

documentation

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions