Problem resolved. I needed to specify 3D region for 3D perspective plotting (reg_plot for 3D and reg for 2D). gmt coast works without having to to track coast onto topography
Here is the complete working example
import pygmt
# Load sample earth relief data
# SFBA
reg = [-123, -121.5, 36.75, 38.25]
reg_plot = [-123, -121.5, 36.75, 38.25, -3000, 3000]
# Resolution 15m, 03m, 01m
res = "15s"
#res = "03s"
# Prespective
perspect = [233, 30]
grid = pygmt.datasets.load_earth_relief(resolution=res, region=reg)
#grid.to_netcdf("sfba_topo.nc")
fig = pygmt.Figure()
fig.grdview(
grid=grid,
perspective=perspect,
#frame=["xa", "yaf", "WSnE"],
projection="M10c",
region=reg_plot,
zsize="1.5c",
plane="0",
surftype="s",
cmap="geo",
)
fig.coast(
region=reg_plot,
perspective=[233, 30, 0],
shorelines="1p,black",
)
# Downtown Oakland: 37.80N 122.27W
fig.plot3d(
x=-122.27,
y=37.80,
z=0,
style="c0.25c",
color='red',
pen="thick",
perspective=perspect,
)
fig.colorbar(
perspective=True,
frame=["a500", "x+lElevation", "y+lm"],
position="JML+o0c/0c+w7c/0.5c",
)
fig.savefig("grdview_map.png")