Skip to content

Matrix as grid with changing central meridian doesn't work well for gridline grids #3844

@seisman

Description

@seisman

Full script that generated the error

The script generates 4 maps, for pixel or gridline grids passing as grid or matrix:

import pygmt
from pygmt.datasets import load_earth_relief
import xarray as xr

# pixel grid
fig = pygmt.Figure()
fig.grdimage("@earth_relief_01d_p", projection="W120/15c", cmap="geo")
fig.savefig("grid_p.png")

# pixel matrix
grid = load_earth_relief(registration="pixel")
fig = pygmt.Figure()
fig.grdimage(grid, projection="W120/15c", cmap="geo")
fig.savefig("matrix_p.png")


# gridline grid
fig = pygmt.Figure()
fig.grdimage("@earth_relief_01d_g", projection="W120/15c", cmap="geo")
fig.savefig("grid_g.png")

# gridline matrix
grid = load_earth_relief(registration="gridline")
fig = pygmt.Figure()
fig.grdimage(grid, projection="W120/15c", cmap="geo")
fig.savefig("matrix_g.png")

Use the command below to compare the two maps of pixel-registered grid/matrix. The RMS is zero. So passing grid or matrix give the same results:

gm compare -density 200 -highlight-color magenta -highlight-style assign -metric rmse -file diff_p.png matrix_p.png grid_p.png

Use the command below to compare the two maps of pixel-registered grid/matrix.

gm compare -density 200 -highlight-color magenta -highlight-style assign -metric rmse -file diff_g.png matrix_g.png grid_g.png

The RMS is non-zero. Here is the diff image. There are tiny difference along the x=180 line. Perhaps a 0.5 grid offset?

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions