Custom projection

Hi!

Is there a way to tweak the projection of fig.grdimage or even fig.coast so that the data and coastlines align?

Here’s an example of what I wish to fix in the future

Thanks

Hi,

You could “cheat” using -X -Y option to manually shift one plot relative to the other.

The offset is too big to be ignored … or put under the carpet. Better try to find the reason.

The GSSHG coastline from fig.coast isn’t very accurate. You may want to look at the example at https://docs.generic-mapping-tools.org/6.2/gallery/ex51.html on how to use OpenStreetMap coastlines instead (though it is done in GMT).

Datum differences explain offsets up to at most 300-400 m. Not 70 km like in present case.

But different -R used in the grdimage and the coast commands could explain the observed.

fig.grdimage(
    grid=ds[1:800,1:1001])
fig.coast(
    shorelines = True,
    frame=True)

This is what I used to plot. I can certainly try to shift the plots relative to the other.

I reckon the issue stems from using xarray.interp as per suggestion to solve the issue of uneavenly spaced data grid. This data set is created using a 0.05 step. I’ve tried using multiple interpolations with gradually decreasing step to rectify this, but the offset still looks the same.

If there is another way to work around this, perhaps using something other than fig.grdimage?

This reminds me, it might also be a pixel vs gridline node registration issue? Could you report the output of ds.gmt.registration and ds.gmt.gtype? The outputs (0/1) are documented at https://www.pygmt.org/v0.4.0/api/generated/pygmt.GMTDataArrayAccessor.html. I’m assuming that your data is from an optical satellite which would usually mean that it is pixel registered, but if your grid is gridline registered, there could be some offset involved.

If you’re interested, see also https://github.com/GenericMappingTools/pygmt/issues/487 and https://github.com/GenericMappingTools/pygmt/pull/476 for a lengthy discussion.