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 for grdgradient #1428

Merged

Conversation

yohaimagen
Copy link
Contributor

@yohaimagen yohaimagen commented Aug 10, 2021

adding a gallery example of producing a hillshade map out of a Data Elevation Model with pygmt.grdgradient

Preview at https://pygmt-git-fork-yohaimagen-grdgradientgalleryexample-gmt.vercel.app/gallery/images/grdgradient.html

grdgradient gallery example

Fixes #1425

@yohaimagen yohaimagen self-assigned this Aug 10, 2021
@yohaimagen yohaimagen added the documentation Improvements or additions to documentation label Aug 10, 2021
@yohaimagen
Copy link
Contributor Author

At #1425 I suggest also extending the Plotting Earth relief tutorial to include a section that uses shading=True in grdimage which use grdgradient in order of making a hillshade map, and from there reference to this gallery example for more specific usage of grdgradient, do you think it necessary? and if yes should I do it over here or on a different pull request?

@seisman seisman added this to the 0.5.0 milestone Aug 10, 2021
@weiji14 weiji14 requested a review from a team August 30, 2021 04:28
examples/gallery/images/grdgradient.py Outdated Show resolved Hide resolved
examples/gallery/images/grdgradient.py Outdated Show resolved Hide resolved
examples/gallery/images/grdgradient.py Outdated Show resolved Hide resolved
examples/gallery/images/grdgradient.py Outdated Show resolved Hide resolved
# Load sample grid (3 arc second global relief) in target area
grid = pygmt.datasets.load_earth_relief(resolution="03s", region=region)

# calculate the reflection of a light source projecting from west to east(azimuth 270)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# calculate the reflection of a light source projecting from west to east(azimuth 270)
# calculate the reflection of a light source projecting from west to east (azimuth 270 degrees)

# --------------- plotting the hillshade map -----------
pygmt.makecpt(cmap="gray", series=[-1.5, 0.3, 0.01])
fig.grdimage(
grid=dgrid,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can anyone confirm the definition of a hillshaded map? Based on my own understanding, hillshading means plotting the elevation data grid, and also apply the (-1,1) intensity grid dgrid for each point. Thus a hillshaded map should be like this (the CPT range should also be changed to reflect the elevation range):

Suggested change
grid=dgrid,
grid=grid,
shading=dgrid,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no one answer to this. I think what is plotted in this gallery example could be considered a 'hillshade map' (showing only the hillshade component) but not a 'hillshaded map' implying that the hillshade component alters the appearance of other data (e.g., elevation) that are shown on the map.

My opinion is that it would be better to plot a slope map for the simple grdgradient gallery example and that hillshading should be covered in a different tutorial that can go into different strategies (e.g., multi-directional, mixing slope and hillshade for illumination, transparent overlays versus grdgradient's shading parameter, etc). Sorry for not commenting about this earlier. It will be a great addition to have an example for grdgradient.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no one answer to this. I think what is plotted in this gallery example could be considered a 'hillshade map' (showing only the hillshade component) but not a 'hillshaded map' implying that the hillshade component alters the appearance of other data (e.g., elevation) that are shown on the map.

Agree with @meghanrjones regarding this point! I think the example itself is good as is in the current form but would also suggest to add another example/tutorial on this topic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ill agree that a slops map is more intuitive when you think on the gradient of a DEM. On the other hand, at least in my experience, shade maps are more intuitive to use(you are seeing the topography directly).

Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
yohaimagen and others added 6 commits September 4, 2021 08:34
Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
examples/gallery/images/grdgradient.py Outdated Show resolved Hide resolved
examples/gallery/images/grdgradient.py Outdated Show resolved Hide resolved
examples/gallery/images/grdgradient.py Outdated Show resolved Hide resolved
examples/gallery/images/grdgradient.py Outdated Show resolved Hide resolved
examples/gallery/images/grdgradient.py Outdated Show resolved Hide resolved
examples/gallery/images/grdgradient.py Outdated Show resolved Hide resolved
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
@seisman seisman added the final review call This PR requires final review and approval from a second reviewer label Sep 16, 2021
Copy link
Member

@seisman seisman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yohaimagen Nice work. The example now looks good to me.

@yohaimagen
Copy link
Contributor Author

Thanks!
We still have one problem when looking in the deployment the title of the example is getting outside of the respective white box.
Screen Shot 2021-09-16 at 9 37 09
Can we decrease the font size in that case? or we should change the title?

@seisman
Copy link
Member

seisman commented Sep 16, 2021

Maybe we can change the title to "Calculating grid gradient and radiance".

examples/gallery/images/grdgradient.py Outdated Show resolved Hide resolved
examples/gallery/images/grdgradient.py Outdated Show resolved Hide resolved
yohaimagen and others added 2 commits September 16, 2021 10:49
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Copy link
Member

@michaelgrund michaelgrund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except the minor changes I suggested this PR looks good to me.

examples/gallery/images/grdgradient.py Outdated Show resolved Hide resolved
Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
@seisman seisman merged commit 0327262 into GenericMappingTools:main Sep 17, 2021
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Sep 17, 2021
@yohaimagen yohaimagen deleted the grdgradient_gallery_example branch September 17, 2021 05:48
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
Co-authored-by: Will Schlitzer <schlitzer90@gmail.com>
Co-authored-by: Meghan Jones <meghanj@alum.mit.edu>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
This pull request was closed.
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 this pull request may close these issues.

Add an example of the use of pygmt.grdgradient
6 participants