Hi all,
I have a map of a large region and I want to create an azimuthal orthogonal projection inset map that outlines the area of the main map. When I try to plot the rectangle of the main map in the inset map, it does not plot it, but it doesn’t throw any errors either. Here is my code and the map it produces:
# Create map and coastlines
reg_box = [38,87,34,54]
proj = 'M40c'
fig = pygmt.Figure()
fig.basemap(region=reg_box, projection=proj, frame=True)
# fig.grdimage(grid=grid, cmap=cpt, dpi=600, transparency=50)
fig.coast(region=reg_box, resolution='f', borders = 'a/1p,black,solid', shorelines='1.', projection=proj, water='lightblue', transparency= 2.0)#,land='lightgrey')
# Inset map
with fig.inset(position="jBR+o5c/-5c", box=False, no_clip=True):
fig.coast(region='g', projection='G62.5/44/15c' , borders ='1/1p,black,solid', water='lightblue', land='lightbrown')
study_area = [[reg_box[0],reg_box[2],reg_box[1],reg_box[3]]]
fig.plot(data=study_area, style="r+s", pen="2p,blue")
fig.show()
Does anyone have an idea why the outline/rectangle is not being plotted on the inset map?
Thank you!
with
fig.plot(region='g', projection='G62.5/44/15c', data=study_area, style="r+s", pen="2p,blue")
the rectangle appears on the inset
no idea why
@mkononets that solved the issue, thank you!
I realized that it happens in inset maps with other projections too. Looks like the region and projection have to be defined within the fig.plot command as well.
Hi @Lbmartinetti,
You should not specific the projection size for the inset directly via coast
or basemap
but there are two ways to set the width:
import pygmt
reg_box = [38, 87, 34, 54]
study_area = [[reg_box[0], reg_box[2], reg_box[1], reg_box[3]]]
proj = "M40c"
# -----------------------------------------------------------------------------
fig = pygmt.Figure()
fig.basemap(region=reg_box, projection=proj, frame=True)
fig.coast(borders="a/1p,black,solid", shorelines=True, water="lightblue")
# Way 1
# See https://www.pygmt.org/dev/gallery/embellishments/inset.html
with fig.inset(position="jBR+o-5c+w15c", box=False): # Give width of inset via +w
# >>> For insets, do not give the width of the projection explicitly but use a ? <<<
# >>> PyGMT will determine to width of the projection automatically <<<
fig.coast(region="g", projection="G62.5/44/?", borders="1/1p,black,solid", water="lightblue", land="lightbrown")
fig.plot(data=study_area, style="r+s", pen="2p,blue")
fig.show()
# -----------------------------------------------------------------------------
fig = pygmt.Figure()
fig.basemap(region=reg_box, projection=proj, frame=True)
fig.coast(borders="a/1p,black,solid", shorelines=True, water="lightblue")
# Way 2
# See https://www.pygmt.org/dev/gallery/embellishments/inset_rectangle_region.html
with fig.inset(position="jBR+o-5c", region="g", projection="G62.5/44/15c", box=False):
fig.coast(borders="1/1p,black,solid", water="lightblue", land="lightbrown")
fig.plot(data=study_area, style="r+s", pen="2p,blue")
fig.show()
2 Likes
Hi @yvonnefroehlich ,
Thanks for your help and solutions!