Skip to content

grdimage does not plot subsets of data correctly on a global map #5180

Closed

Description

@PaulWessel

This issue has the same name as one reported to the pygmt issues page, but it is the same problem in the GMT core:

gmt grdmath -R0/220/-30/90 -I1 -fg 0 1 RAND = t.grd
gmt grdimage t.grd -Rg -JW0/8i -B -png bad

which gives

bad

Letting @GenericMappingTools/pygmt-admin know as well.

Activity

  1. added
    bug
    on Apr 29, 2021
  2. self-assigned this
    on Apr 29, 2021
  3. weiji14 commented on Apr 30, 2021

    @weiji14
    Member

    I just ran the code in #5180 (comment) on GMT master (commit 81da2a2) and it's giving me this image:

    bad

    Is this correct? To be honest, I'm not familiar with the Mollweide projection so not sure what the expected output should be, but the gray parts doesn't seem ok. Using -JW180/8i also gives some gray output that wasn't there before in GMT 6.1.1.

    bad

  4. reopened this on May 3, 2021
  5. seisman commented on May 3, 2021

    @seisman
    Member

    @PaulWessel Please double-check it again.

  6. PaulWessel commented on May 3, 2021

    @PaulWessel
    ContributorAuthor

    OK, just did. It works fine for me. The gray is a function of the CPT. Add -Q to not see it or pick a CPT (like vik) that has white.

  7. PaulWessel commented on May 3, 2021

    @PaulWessel
    ContributorAuthor

    To be crystal clear, I just ran

    gmt grdmath -R0/220/-30/90 -I1 -fg 0 1 RAND = t.grd
    gmt grdimage t.grd -Rg -JW180/8i -B -Q -png bad1
    gmt grdimage t.grd -Rg -JW0/8i -B -Q -png bad2
    
  8. seisman commented on May 3, 2021

    @seisman
    Member

    The gray is a function of the CPT. Add -Q to not see it or pick a CPT (like vik) that has white.

    It means the gray region contains NaN values, but the t.grd has no values at the region, so it should be transparent even without -Q, no?

  9. PaulWessel commented on May 3, 2021

    @PaulWessel
    ContributorAuthor

    Well, the projected grid has to be a rectangle, so that is what it looks like. We can discuss if in these situations we should automatically set up a clip path before laying down the rectangle, but that has never been done. it has always been like this.

  10. seisman commented on May 3, 2021

    @seisman
    Member

    the projected grid has to be a rectangle

    I have no idea what a projected grid means.

    The following commands work as I expect, so what's the difference between the above t.grd and the t0.grd here?

    gmt grdcut @earth_relief_01d -R0/220/-30/90 -Gt0.grd
    gmt grdimage t0.grd -Rg -JW180/8i -B -Q -png bad1
    gmt grdimage t0.grd -Rg -JW0/8i -B -Q -png bad2
    
  11. PaulWessel commented on May 3, 2021

    @PaulWessel
    ContributorAuthor

    PostScript image is a rectangle, so any grdimage that is plotted in PostScript is projected and yields a rectangle. What is not within the original lon/lat boundingbox is set to NaN. Usually using -Q is really all you need.

    Diference is the default CPT. For remote grids we use the default CPT listed in the server table. For t.grd we get turbo I think.

  12. PaulWessel commented on May 3, 2021

    @PaulWessel
    ContributorAuthor

    If we had started with letting the -Q behavior be the default long time ago and in fact not have a -Q option then we would not have this discussion. However, grdimage came out before PostScript level 3 introduced colormasking so -Q was added later.

  13. seisman commented on May 3, 2021

    @seisman
    Member

    OK. It makes sense. Closing again.

  14. weiji14 commented on May 3, 2021

    @weiji14
    Member

    What about the white parts on the left and right of the oval? Is it meant to be white or colored by the grid (as with the -JW180/8i example)?

  15. PaulWessel commented on May 3, 2021

    @PaulWessel
    ContributorAuthor

    If you refer to the white parts in the two figs at the far left and far right areas you posted above then I cannot reproduce those - it looks fine when I run those examples.

  16. weiji14 commented on May 3, 2021

    @weiji14
    Member

    Ah ok, I'll try and rebuild GMT master and try again. Thanks!

  17. PaulWessel commented on May 3, 2021

    @PaulWessel
    ContributorAuthor

    Great, it is a recent fix so probably just not updated on your end (I hope!).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions