I am plotting a shapefile using fig.plot (after reading it with Geopandas) and then adding gridded data using fig.grdimage. Below is my code:
df1=pd.read_csv("/home/jairovs/CMAQ/nox_max_mean.csv")
gdf = gpd.read_file(filename="./ZMVM municipios.shp")
gdf.head()
grid = pygmt.xyz2grd(x=df1.LON, y=df1.LAT, z=df1.nox_base, spacing=0.01, region=[-99.5,-98.5,19,20])
region=[-99.5,-98.5,19,20]
fig = pygmt.Figure()
fig.coast(land="white", water="cornflowerblue",
shorelines="1/0.3p", borders=["1/0.1p", '2/0.9p'], region=[-99.5,-98.5,19,20], projection="M8i", frame=["afg"])
fig.plot(data=gdf, pen="1p,black")
pygmt.makecpt(cmap="berlin", series=[0, 150, 15])
fig.grdimage(grid=grid, region=[-99.5,-98.5,19,20], projection="M8i", shading= False, cmap=True, transparency= 35)
fig.colorbar(position="JBC+w15h", frame=["af", "y+lNO@-x@- [ppb]"])
fig.show()
If I add only fig.plot and fig.gridimage, the shape file is correctly added to the figure. However, the shapefile disappears when adding fig.coast for showing shorelines, water, etc. I have also tried using fig.basemap instead, but the shapefile does not show. Do you have any idea about what the problem might be and how to solve it?
Thank you very much for creating PyGMT, such a useful tool.