Pygmt.grdimage not plotting data

Attempting to perform simple gridded image plot using pygmt.grdimage .

I know this is some issue with my understanding so this is not a bug report, and hopefully it is easy enough for a someone to quickly see the solution.

Here is the data:
<xarray.DataArray (y: 185, x: 148)> Size: 110kB
array([[nan, nan, nan, …, nan, nan, nan],
[nan, nan, nan, …, nan, nan, nan],
[nan, nan, nan, …, nan, nan, nan],
…,
[nan, nan, nan, …, nan, nan, nan],
[nan, nan, nan, …, nan, nan, nan],
[nan, nan, nan, …, nan, nan, nan]], dtype=float32)
Coordinates:
lon (y, x) float32 110kB -18.88 -18.62 -18.38 … 17.38 17.62 17.88
lat (y, x) float32 110kB -79.92 -79.92 -79.92 … -60.08 -60.08 -60.08
Dimensions without coordinates: y, x
Attributes:
description: Fast ice thickness
units: m

This is code that I used to create the xarray data array.

        hi_plt = xr.DataArray(data=hi_mask.values,
                              dims=["y", "x"],
                              coords=dict(lon=(["y", "x"], lon_mask.values),
                                          lat=(["y", "x"], lat_mask.values)),
                              attrs=dict(description="Fast ice thickness",
                                         units="m"))

This is code that I’m using to attempt to visualise this data:

        proj = f"B{lonC:.1f}/{latC:.1f}/{ext_plt[2]:.1f}/{ext_plt[3]:.1f}/20c"
        pygmt.makecpt(cmap="cmocean/amp", series=[0,5], output="hi_mask.cpt")
        fig = pygmt.Figure()
        fig.grdimage(grid=hi_plt, cmap="hi_mask.cpt", projection=proj, region=ext_plt, frame="a")
        fig.coast(land="white", water="black")
        fig.colorbar(cmap="hi_mask.cpt",
                     frame="a1f.5+lThickness (m)",
                     position="JBC+w10c/0.4c+mc+h")
        fig.show()

And this is the warning that it results in:

grdimage [WARNING]: Your grid y’s or latitudes appear to be outside the map region and will be skipped.
grdimage [WARNING]: No grid or image inside plot domain

I also attached the xarray simple visualisation of the data that I’m attempting to reprsent geographically with pygmt.

Thanks for your help.


Unknown

Solved my own issue.

        hi_grd = pygmt.nearneighbor(x=np.ravel(lon_mask.values),
                                    y=np.ravel(lat_mask.values),
                                    z=np.ravel(hi_mask.values),
                                    region=ext_plt,
                                    spacing="15m",
                                    search_radius="20m")
        aice_grd = pygmt.nearneighbor(x=np.ravel(lon_mask.values),
                                      y=np.ravel(lat_mask.values),
                                      z=np.ravel(aice_mask.values),
                                      region=ext_plt,
                                      spacing="15m",
                                      search_radius="20m")
        proj = f"B{lonC:.1f}/{latC:.1f}/{ext_plt[2]:.1f}/{ext_plt[3]:.1f}/20c"
        fig = pygmt.Figure()
        fig.coast(projection=proj, region=ext_plt, land="white", water="black", frame="a")
        pygmt.makecpt(cmap="cmocean/ice", series=[0,1])
        fig.grdimage(grid=aice_grd, cmap=True, nan_transparent=True)#, projection=proj, region=ext_plt)
        fig.colorbar(frame=["x+lPack ice concentration", "y+l1/100"], position="JMR+o0.5c/0c+w10c")
        pygmt.makecpt(cmap="cmocean/amp", series=[0,5])
        fig.grdimage(grid=hi_grd, cmap=True, nan_transparent=True)#, projection=proj, region=ext_plt)
        fig.colorbar(frame="a1f.5+lFast ice thickness (m)", position="JBC+w10c/0.5c+mc+h")
        fig.show()
        fig.savefig(P_save)