Reading in Defined GeoRegion Information

In this section, we go through process of extracting information regarding a GeoRegion.

Setup

using GeoRegions
using DelimitedFiles
using CairoMakie

download("https://raw.githubusercontent.com/natgeo-wong/GeoPlottingData/main/coastline_resl.txt","coast.cst")
coast = readdlm("coast.cst",comments=true)
clon  = coast[:,1]
clat  = coast[:,2]
nothing

Retrieving Information about a Previously Defined GeoRegion

We use the function GeoRegion(ID), where ID is the ID of the GeoRegion, in order to extract the information for the GeoRegion.

GeoRegion("AR6_NWN")
The Polygonal Region AR6_NWN has the following properties:
    Region ID    (ID) : AR6_NWN
    Parent ID   (pID) : GLB
    Name       (name) : Northwest North America
    Bounds  (N,S,E,W) : [81.0, 50.0, -105.0, -168.0]
    Shape     (shape) : Point2{Float64}[[-105.0, 50.0], [-130.0, 50.0], [-143.0, 58.0], [-168.0, 52.5], [-168.0, 72.6], [-129.0, 72.6], [-125.0, 77.6], [-105.0, 81.0], [-105.0, 50.0]]
        (is180,is360) : (true, false)
GeoRegions.GeoRegionMethod
GeoRegion(RegID::AbstractString) -> geo::GeoRegion

Extracts information of the GeoRegion with the ID RegID. If no GeoRegion with this ID exists, an error is thrown.

Arguments

  • RegID : The keyword ID that will be used to identify the GeoRegion. If the ID is not valid (i.e. not being used), then an error will be thrown.

Returns

  • geo : A GeoRegion
source

The Difference between Bounds and Shape in a PolyRegion

What is the difference between the fields bound and shape in a PolyRegion? The answer is simple: a bound is a rectilinear-region in the lon-lat coordinate system, while the shape denotes the actual PolyRegion. We retrieve the longitude and latitude coordinates for the bound and shape fields using the function coordGeoRegion().

Bound and Shape in `RectRegion`

There is no field shape in a RectRegion because the shape of a RectRegion is defined by its rectilinear bound.

blon,blat,slon,slat = coordGeoRegion(GeoRegion("AR6_NWN"))
([-168.0, -164.85, -161.7, -158.55, -155.4, -152.25, -149.1, -145.95, -142.8, -139.65  …  -168.0, -168.0, -168.0, -168.0, -168.0, -168.0, -168.0, -168.0, -168.0, -168.0], [81.0, 81.0, 81.0, 81.0, 81.0, 81.0, 81.0, 81.0, 81.0, 81.0  …  67.05, 68.6, 70.15, 71.7, 73.25, 74.8, 76.35, 77.9, 79.45, 81.0], [-105.0, -106.25, -107.5, -108.75, -110.0, -111.25, -112.5, -113.75, -115.0, -116.25  …  -105.0, -105.0, -105.0, -105.0, -105.0, -105.0, -105.0, -105.0, -105.0, -105.0], [50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0, 50.0  …  63.95, 62.4, 60.85, 59.3, 57.75, 56.2, 54.65, 53.1, 51.55, 50.0])

From plotting the bounds (blon,blat) and the shape(slon,slat), we see that the bound is the region defined by the westernmost, easternmost, northernmost and southernmost coordinates of the shape.

aspect = (maximum(slon)-minimum(slon))/(maximum(slat)-minimum(slat))
fig = Figure()
ax = Axis(
    fig[1,1],width=750,height=750/aspect,
    limits=(minimum(slon)-2,maximum(slon)+2,minimum(slat)-2,maximum(slat)+2)
)
lines!(ax,clon,clat,color=:black,linewidth=3)
lines!(ax,slon,slat,linewidth=5)
lines!(ax,blon,blat,linewidth=5)
resize_to_layout!(fig)
fig
Example block output
GeoRegions.coordGeoRegionMethod
coordGeoRegion(geo::RectRegion) -> blon::Vector{<:Real}, blat::Vector{<:Real}

For a given RectRegion, extract the [N,S,E,W] bounds and create a longitude and latitude vector.

Arguments

  • geo : A RectRegion (i.e. a rectilinear GeoRegion)

Returns

  • blon : A vector of longitude points for the bound of the GeoRegion
  • blat : A vector of latitude points for the bound of the GeoRegion
source
GeoRegions.coordGeoRegionMethod
coordGeoRegion(geo::PolyRegion) ->
    blon::Vector{<:Real}, blat::Vector{<:Real},
    slon::Vector{<:Real}, slat::Vector{<:Real},

For a given RectRegion, extract the [N,S,E,W] bounds and create a longitude and latitude vectors for the bound and the shape of the GeoRegion

Arguments

  • geo : A PolyRegion (i.e. a polygonal GeoRegion)

Returns

  • blon : A vector of longitude points for the bound of the GeoRegion
  • blat : A vector of latitude points for the bound of the GeoRegion
  • slon : A vector of longitude points for the shape of the GeoRegion
  • slat : A vector of latitude points for the shape of the GeoRegion
source