Manipulating geographic regions#
There are a few operations you can perform on the geographic regions to manipulate them, as demonstrated here.
[1]:
import polartoolkit as ptk
[2]:
import os
# set default to northern hemisphere for this notebook
os.environ["POLARTOOLKIT_HEMISPHERE"] = "south"
Combining regions#
[3]:
# define two regions
RIS = ptk.regions.ross_ice_shelf
MBL = ptk.regions.marie_byrd_land
# get the bounding region of both
combined = ptk.combine_regions(RIS, MBL)
# make a basemap
fig = ptk.plot_grid(
ptk.fetch.bedmap2(layer="bed"),
region=ptk.regions.antarctica,
colorbar=False,
title="Combining regions",
)
# plot the three regions
fig.add_box(combined, pen="6p,red")
fig.add_box(RIS)
fig.add_box(MBL)
fig.show(dpi=200)
Get overlap of two regions#
[4]:
# define two regions
RIS = ptk.regions.ross_ice_shelf
MBL = ptk.regions.marie_byrd_land
# get the intersecting region of both
overlap = ptk.regions_overlap(RIS, MBL)
# make a basemap
fig = ptk.plot_grid(
ptk.fetch.bedmap2(layer="bed"),
region=ptk.regions.antarctica,
colorbar=False,
title="Overlap of regions",
)
# plot the three regions
fig.add_box(overlap, pen="6p,red")
fig.add_box(RIS)
fig.add_box(MBL)
fig.show(dpi=200)
Alter region#
You can use the ptk.alter_region() function to zoom in or out, or shift the region north, south, east or west.
[5]:
# define a starting region
reg = ptk.regions.minna_bluff
# zoom in 20km and shift 25km north and 5km east
new_reg = ptk.alter_region(reg, zoom=20e3, n_shift=25e3, w_shift=-5e3)
# zoom out 15km and shift 12km south
new_reg2 = ptk.alter_region(
reg,
zoom=-15e3,
n_shift=-12e3,
)
# make a basemap
fig = ptk.plot_grid(
ptk.fetch.bedmap2(layer="bed"),
region=ptk.alter_region(reg, zoom=-50e3),
colorbar=False,
title="Altering regions",
)
# plot the three regions
fig.add_box(reg, pen="6p,red")
fig.add_box(new_reg, pen="2p,blue")
fig.add_box(new_reg2, pen="2p,green")
fig.show(dpi=200)
[ ]: