GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add two -R shorthands for projected coordinates by PaulWessel · Pull Request #6094 · GenericMappingTools/gmt

Conversation

@PaulWessel

@PaulWessel PaulWessel commented Dec 5, 2021

Copy link
Copy Markdown
Contributor

Description of proposed changes

This PR is in response to #6090 and introduces two short-hand forms of the general projected region set via -Rxmin/xmax/ymin/ymax[+uunit]:

  1. For a square region centered on (0,0) you can use -Rradius+uunit instead of -R-radius/+radius/-radius/+radius[+uunit].
  2. For a rectangular region centered on (0,0) you can use -Rhalfwidth/halfheight+uunit instead of -R-halfwidth/+halfwidth/-halfheight/+halfheight[+uunit].

Note: For these shorthands the +u modifier is required. Below is a short test result added as part of PR:

pscoast_R_shorthand

Closes #6090.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
PaulWessel added 3 commits December 5, 2021 09:27
@PaulWessel
Add two -R shorthands for projected coordinates
10647c0
See feature request #6090.
@PaulWessel
Update docs
6173b99
@PaulWessel
Add test
8349216
@PaulWessel PaulWessel added documentation Improve documentation enhancement Improving an existing feature labels Dec 5, 2021
@PaulWessel PaulWessel added this to the Future release milestone Dec 5, 2021
@PaulWessel
PaulWessel requested review from Esteban82 and maxrjones December 5, 2021 20:06
@PaulWessel PaulWessel self-assigned this Dec 5, 2021
@joa-quim

joa-quim commented Dec 5, 2021

Copy link
Copy Markdown
Member

I don't understand how this works. What if not centered in 0?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Esteban82

Esteban82 commented Dec 5, 2021

Copy link
Copy Markdown
Member

I don't understand how this works. What if not centered in 0?

The "center" of the map is the longitude and latitude indicated in -J.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@maxrjones

maxrjones commented Dec 5, 2021 via email •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member
Radius seems like a misnomer here to me. Why not use -Rhalfwidth[/halfheight][+uunit] where halfheight defaults to halfwidth if not given?
PaulWessel reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel

PaulWessel commented Dec 5, 2021

Copy link
Copy Markdown
Contributor Author

If not entered then you do standard stuff like -R-600/200/-100/300+uk etc.

PaulWessel reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Esteban82
Esteban82 approved these changes Dec 5, 2021
View reviewed changes

@Esteban82 Esteban82 left a comment

Copy link
Copy Markdown
Member

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 approved because I got the maps from the test right. I didn't revise the docs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@PaulWessel

PaulWessel commented Dec 5, 2021

Copy link
Copy Markdown
Contributor Author

I don't know how to unlike my own comment...
I agree with @meghanrjones and will make that change in the docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel
Switch to halfwidth[/halfheight]
a3b09f3
@vercel
vercel Bot temporarily deployed to Preview December 5, 2021 20:42 Inactive
@joa-quim

joa-quim commented Dec 5, 2021

Copy link
Copy Markdown
Member

I find this option confuse. Many projections do not use a latitude parameter (that is lat_0 = 0). So this means the rectangle will always have to be around the equator, no?

In fact I had a similar idea for the Julia wrapper but always gave up because I could never remember what -Rx was supposed to mean.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel

PaulWessel commented Dec 5, 2021

Copy link
Copy Markdown
Contributor Author

I find this option confuse. Many projections do not use a latitude parameter (that is lat_0 = 0). So this means the rectangle will always have to be around the equator, no?

In fact I had a similar idea for the Julia wrapper but always gave up because I could never remember what -Rx was supposed to mean.

I think even Mercator optionally takes that latitude, but it is not universal and for many it would mean Equator. The key use of this is to make lots of maps that all are centered on various locations and have the same dimensions - one would never want to use the Eckert project for this, for example (well, maybe your new Lester would). I do this all the time and this is just a logical simplification. Way more useful than the one we added for Kurt Feigl in 2016...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel
Update gmt_init.c
50568cb
@vercel
vercel Bot temporarily deployed to Preview December 5, 2021 20:50 Inactive
@PaulWessel

PaulWessel commented Dec 5, 2021

Copy link
Copy Markdown
Contributor Author

BTW @meghanrjones I switched the syntax and docs to your suggestion.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joa-quim

joa-quim commented Dec 5, 2021

Copy link
Copy Markdown
Member

The key use of this is to make lots of maps that all are centered on various locations and have the same dimensions

Ah, a bash-lovers short circuit thing ... still one not working for Mercator (and cousins) in other then around the equator.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel

PaulWessel commented Dec 5, 2021

Copy link
Copy Markdown
Contributor Author

In other words there is room for improvement in our -J settings.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joa-quim

joa-quim commented Dec 5, 2021

Copy link
Copy Markdown
Member

improvement in our -J settings

But not to please this option (ofc there is the proj4 string syntax, etc)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel

PaulWessel commented Dec 5, 2021

Copy link
Copy Markdown
Contributor Author

improvement in our -J settings

But not to please this option (ofc there is the proj4 string syntax, etc)

yes. I am waiting for Leo to respond to my change of refactoring before we schedule a chat focused on C refactoring things, such as pro, but no word yet - busy times. I also do not want to have that chat and then have 3 weeks of holiday delay any actual action. So maybe we have that chat in early January anyway.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel
PaulWessel merged commit 7337385 into master Dec 5, 2021
@PaulWessel
PaulWessel deleted the R-short-hands branch December 5, 2021 21:51
@joa-quim

joa-quim commented Dec 5, 2021

Copy link
Copy Markdown
Member

Sorry but I still think this is not a good solution. If I got it right this is for when one want to make a map with a certain Cartesian width centered in some point. As implemented the center point is the projection center that, as mentioned above, for may projections lies on the equator only. So this option works only sometimes. And why would we force the map center to be on the projection center?

A better way would be to set -Rx[/y]/lon0/lat0+c[u] where user explicitly sets the map center and x is the map width, in km by default but changeable with units

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel

PaulWessel commented Dec 6, 2021

Copy link
Copy Markdown
Contributor Author

Perhaps we can consider a +clon0/lat0 modifier to set a specific center projection point, with the default being the projection origin. That way, the users of projections that has a specific point (azimuthal for instance) can accept the default (as currently encoded) while others can use +c.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joa-quim

joa-quim commented Dec 6, 2021

Copy link
Copy Markdown
Member

Better to leave the +c clean as we do with +r

-Rx[/y]+c => use projection center
-Rx[/y]/lon0/lat0+c => Set the map center

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel

PaulWessel commented Dec 6, 2021

Copy link
Copy Markdown
Contributor Author

Requiring +c breaks backwards compatibility for the cases that have been used forever like this. Also, we do not have modifiers that take its arguments before the modifier, but I understand what you mean "+c means the last two args are center coordinates, not projected distances". I will think more about this. We do not want backwards incompatibilities in -R.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joa-quim

joa-quim commented Dec 6, 2021

Copy link
Copy Markdown
Member

I'm using +c like we use +r. Why would it break compatibility?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel

PaulWessel commented Dec 6, 2021

Copy link
Copy Markdown
Contributor Author

Sorry, it would not. No coffee yet, no breakfast, you expecting me to engage in a technical conversation this early?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joa-quim

joa-quim commented Dec 6, 2021

Copy link
Copy Markdown
Member

Hawaiian chickens are well awaken already and for quite some time now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel

PaulWessel commented Dec 7, 2021

Copy link
Copy Markdown
Contributor Author

Here is the backwards issue I was thinking of. This currently works great (i.e., before we even merged this branch:

gmt pscoast -R-300/300/-300/300+un -JA204/21/14c -Glightgray -B -pdf map

(This is the long-version of the first plot in the test above). As you see, it requires no +c to set the central point to 204/21 since that is set via -J. This has worked for a decade at least, so we do not want toads a +c as a requirement for it to continue to work. So the +c has to be optional I think. I do not think

gmt pscoast -R300/204/21+un+c -JA204/21/14c -Glightgray -B -pdf map

would be a useful syntax as now the savings are gone. I also think the azimuthal projections are the ones where this is most useful but of course that is user-dependent. Hence, I think +c needs to be +clon0/lat0 with default to the projection center. This may be at Equator for many/most projections. So, a Mercator version of the above might be

gmt pscoast -R300+un+c204/21 -JM14c -Glightgray -B -pdf map

I think your suggestion

-Rhalfwidth[/halfheight][/lon0/lat0+c]+uunit

could work but I do think passing those arguments to +c is a better implementation in line with most situations in GMT.

So in summary, the shortcut was introduced because making such a square/rectangle centered on the azimuthal touch point can so easily be done this way, but I agree that for non-azimuthal and non-conic projections there would have to be more. We could accommodate this for those projections via optional latitudes, i.e.

-JH[lon0[/lat0]/]width

where the lat0 has no affect on the projection but lets us compute the (x,y) projected units of the center point and now we can do relative measurements from there. It is mostly those global projections plus some cylindrical that would need this info and then that is the logical way to set the projection center (in -J rather than in -R).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joa-quim

joa-quim commented Dec 7, 2021

Copy link
Copy Markdown
Member

So the +c has to be optional I think. I do not think
gmt pscoast -R300/204/21+un+c -JA204/21/14c -Glightgray -B -pdf map
would be a useful syntax as now the savings are gone.

but it would not be -R300/204/21+un+c, only -R300+un+c because the center is here set by -JA204/21/14c

-JH[lon0[/lat0]/]width

That is the part that I'm against. We should not change the -J syntax (with no parallel in proj4) just to please -R

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel

PaulWessel commented Dec 7, 2021

Copy link
Copy Markdown
Contributor Author

OK, so we would know for -JA,S,G etc that we already have a valid default point so -R300+un+c is understandable. That means the syntax is actually [/lon0/lat0]+c then? What do you do with

-R-300/200/-150/75+un -JA204/21/14c

then? Do we really want to parse that and somehow figure out that -150/75 can't be lon/lat since the halfwidth is negative, etc, etc? I can imagine cases where there is just no way to know.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@joa-quim

joa-quim commented Dec 7, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

-300/200/-150/75+un

without +c the -150/75 would not be the map center, no? I guess there will be many cases where a requested rectangle cannot be obtained

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@PaulWessel

PaulWessel commented Dec 7, 2021

Copy link
Copy Markdown
Contributor Author

Well, the point is that the above (-R-300/200/-150/75+un) works because there is a map center at (0,0) set via -J. Requiring +c means we break backwards compatibility in this case, hence my desire to keep +c optional.
I have not checked, but is there no way in proj to specify a projection center, say, for Mercator? I.e., a latitude? Seems like that is totally a -J thing since a projection origin is always somewhere.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anbj

anbj commented Dec 7, 2021

Copy link
Copy Markdown
Contributor

(Speaking of -R overhaul: #3099)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@maxrjones maxrjones added the add-changelog Add PR to the changelog label Jan 25, 2022
@seisman seisman removed this from the Future release milestone Jan 7, 2024

This branch was previously deployed

1 inactive deployment
Preview — 50568cb7 Deployed Dec 5, 2021 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Esteban82 Esteban82 Esteban82 approved these changes
@maxrjones maxrjones Awaiting requested review from maxrjones

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@PaulWessel PaulWessel

Labels

add-changelog Add PR to the changelog documentation Improve documentation enhancement Improving an existing feature

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Improve -Rxmin/xmax/ymin/ymax+uunit

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@PaulWessel @joa-quim @Esteban82 @maxrjones @anbj @seisman
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.