pygmt.clib.Session.extract_region
- Session.extract_region()[source]
- Extract the region of the currently active figure. - Retrieves the information from the PostScript file, so it works for country codes as well. - Return type:
- Returns:
- region – A numpy 1-D array with the west, east, south, and north dimensions of the current figure. 
 - Examples - >>> import pygmt >>> fig = pygmt.Figure() >>> fig.coast( ... region=[0, 10, -20, -10], projection="M12c", frame=True, land="black" ... ) >>> with Session() as lib: ... region = lib.extract_region() >>> print(", ".join([f"{x:.2f}" for x in region])) 0.00, 10.00, -20.00, -10.00 - Using ISO country codes for the regions (for example - "US.HI"for Hawaiʻi):- >>> fig = pygmt.Figure() >>> fig.coast(region="US.HI", projection="M12c", frame=True, land="black") >>> with Session() as lib: ... region = lib.extract_region() >>> print(", ".join([f"{x:.2f}" for x in region])) -164.71, -154.81, 18.91, 23.58 - The country codes can have an extra argument that rounds the region to multiples of the argument (for example, - "US.HI+r5"will round the region to multiples of 5):- >>> fig = pygmt.Figure() >>> fig.coast(region="US.HI+r5", projection="M12c", frame=True, land="black") >>> with Session() as lib: ... region = lib.extract_region() >>> print(", ".join([f"{x:.2f}" for x in region])) -165.00, -150.00, 15.00, 25.00