Skip to content

Creating GeoRegions

In this section, we go through the basic steps of creating a GeoRegion, and removing it once defined so it can be redefined.

Defining a new GeoRegion

We use the functions RectRegion and PolyRegion to define rectilinear and polygonal regions respectively. For example, we construct the sample RectRegion TRC

julia-repl

Defining PolyRegions

When defining PolyRegions, the first and last set of (lon,lat) coordinates must be the same (i.e. a closed polygon must be defined)

The GeoRegions will be automatically added to the following files in joinpath(DEPOT_PATH[1],"files","GeoRegions"):

  • RectRegions will be added to rectlist.txt

  • PolyRegions will be added to polylist.txt

If the GeoRegion ID TRC already exists, however, this will throw an error

julia-repl
# GeoRegions.RectRegionMethod.
julia
RectRegion(
    RegID :: AbstractString,
    ParID :: AbstractString,
    name  :: AbstractString,
    bound :: Vector{<:Real};
    savegeo :: Bool = true,
    verbose :: Bool = true,
    ST = String,
    FT = Float64
) -> RectRegion{ST,FT}

Creates a rectilinear GeoRegion RegID.

Arguments

  • RegID : The keyword ID that will be used to identify the GeoRegion. If the ID is already in use, then an error will be thrown.

  • ParID : The ID of the parent GeoRegion where information can be extracted from

  • name : A name for the GeoRegion (meta information, can be used in Logging)

  • bound : The [N,S,E,W] coordinates defining the region

Keyword Arguments

  • savegeo : Save the GeoRegion into the master list? Default is true

  • verbose : Verbose logging for ease of monitoring? Default is true

source


# GeoRegions.PolyRegionMethod.
julia
PolyRegion(
    RegID :: AbstractString,
    ParID :: AbstractString,
    name  :: AbstractString,
    lonpt :: Vector{<:Real},
    latpt :: Vector{<:Real};
    savegeo :: Bool = true,
    verbose :: Bool = true,
    ST = String,
    FT = Float64
) -> PolyRegion{ST,FT}

Creates a rectilinear GeoRegion RegID.

Arguments

  • RegID : The keyword ID that will be used to identify the GeoRegion. If the ID is already in use, then an error will be thrown.

  • ParID : The ID of the parent GeoRegion where information can be extracted from

  • name : A name for the GeoRegion (meta information, can be used in Logging)

  • lonpt : A vector containing the longitude points

  • latpt : A vector containing the latitude points

Keyword Arguments

  • savegeo : Save the GeoRegion into the master list? Default is true

  • verbose : Verbose logging for ease of monitoring? Default is true

Start and End Points

The 1st and last elements of lonpt and latpt must be equal.

source


Is it already a GeoRegion?

Sometimes we would like to independently check if an ID has already been used. We can use the function isGeoRegion() to perform this checkIf the GeoRegion IDTRC` already exists, however, this will throw an error

# GeoRegions.isGeoRegionFunction.
julia
isGeoRegion(
    RegID :: AbstractString;
    throw :: Bool = true
) -> tf :: Bool

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.

  • throw : If true, then throws an error if RegID is not a valid GeoRegion identifier instead of returning the Boolean tf

Returns

  • tf : True / False

source


julia-repl

Removing an existing GeoRegion

To remove an existing GeoRegion, we can use the function removeGeoRegion

julia-repl

Global GeoRegion

The Global GeoRegion GLB is considered to be an integral part of the GeoRegions.jl package and therefore it cannot be removed.

julia-repl
# GeoRegions.removeGeoRegionMethod.
julia
removeGeoRegion(RegID::AbstractString)

Creates the GeoRegion associated with the ID RegID.

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.

source


Reset the list of GeoRegions

Should one wish to entirely reset the list of GeoRegions, one can call resetGeoRegions(). See Custom GeoRegions for more details.