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

Improve documentation for +r option in the regions tutorial #1027

Merged
merged 5 commits into from
Mar 10, 2021

Conversation

core-man
Copy link
Member

@core-man core-man commented Mar 9, 2021

Description of proposed changes

The +rincrement option in the tutorial for ISO code may mislead some new GMT users (originally posted in #983 (comment)).


+r option in GMT DOC

Append +r to modify exact bounding box coordinates obtained from the polygon(s): Append inc, xinc/yinc, or winc/einc/sinc/ninc to adjust the final region boundaries to be multiples of these steps [default is no adjustment]. Alternatively, use +R to extend the region outward by adding these increments instead, or +e which is like +r but it ensures that the bounding box extends by at least 0.25 times the increment [no extension]. As an example, -RFR+r1 will select the national bounding box of France rounded to nearest integer degree.

Take JP as an example:

import pygmt
fig = pygmt.Figure()
fig.coast(
    region="JP",
    projection="M12c",
    land="lightgray",
)
print(fig.region)

Output:

[122.938515 145.820877  20.528774  45.523136]

Use [+r|R|e[incs]] option:

  • JP+R1: [121.938515 146.820877 19.528774 46.523136]
  • JP+R2: [120.938515 147.820877 18.528774 47.523136]
  • JP+R3: [119.938515 148.820877 17.528774 48.523136]
  • JP+r1: [122. 146. 20. 46.]
  • JP+r2: [122. 146. 20. 46.]
  • JP+r3: [120. 147. 18. 48.]
  • JP+e1: [122. 147. 20. 46.]
  • JP+e2: [122. 148. 20. 48.]
  • JP+e3: [120. 147. 18. 48.]

We can see:

  • +Rinc extends the region outward by adding these increments (using +R3, 119.938515 = 122.938515 - 3)
  • +rinc adjusts the final region boundaries to be multiples of these steps (using +r3, 120, 147, 18, 48 are multiples of 3)
  • +einc is similar to +rinc (final region boundaries to be multiples of these steps), but it ensures that the bounding box extends by at least 0.25 times the increment. So, +e1 adjusts 145.820877 to be 147 instead of 146 by +r1 since 146-145.820877=0.18 < 0.25*1. +e2 adjusts 145.820877 to be 148, 45.523136 to be 48 for the same reason.

Related to #983 and #996.

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

@core-man core-man changed the title Improve doc for +r option in the regions tutorial Improve documentation for +r option in the regions tutorial Mar 9, 2021
@seisman seisman added the documentation Improvements or additions to documentation label Mar 9, 2021
@seisman seisman added this to the 0.3.1 milestone Mar 9, 2021
@seisman seisman marked this pull request as draft March 9, 2021 19:13
Copy link
Contributor

@willschlitzer willschlitzer left a comment

Choose a reason for hiding this comment

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

Good updates.

@core-man core-man requested a review from a team March 10, 2021 20:10
@seisman seisman marked this pull request as ready for review March 10, 2021 20:19
@seisman seisman added the skip-changelog Skip adding Pull Request to changelog label Mar 10, 2021
@seisman seisman merged commit 88fafa5 into GenericMappingTools:master Mar 10, 2021
@core-man core-man deleted the tutorial-regions branch March 10, 2021 20:24
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
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 skip-changelog Skip adding Pull Request to changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants