# Extract Gridded Information for an ERA5Region

Let's say that we have data on a rectilinear lon-lat grid, as ERA5 data tends to have. How do we extract the data for the relevant region? How do we do this for regions that are non-rectilinear in shape? To solve these problems, we introduce the RegionGrid type, which contains information that:

• allows for the extraction of data for a subregion from a parent, larger region
• is able to use a mask to extract data for a region's shape, if it is not rectilinear
GeoRegions.RegionGridType
RegionGrid

Abstract supertype for geographical regions, with the following subtypes:

RectGrid{FT<:Real} <: RegionGrid
PolyGrid{FT<:Real} <: RegionGrid
RegionMask{FT<:Real} <: RegionGrid

Both RectGrid and PolyGrid types contain the following fields:

• grid - A vector of Ints defining the gridpoint indices of the [N,S,E,W] points respectively
• lon - A vector of Floats defining the latitude vector describing the region
• lat - A vector of Floats defining the latitude vector describing the region
• ilon - A vector of Ints defining indices of the parent longitude vector describing the region
• ilat - A vector of Ints defining indices of the parent latitude vector describing the region

A PolyGrid type will also contain the following field:

• mask - An array of 0s and 1s defining a non-rectlinear shape within a rectilinear grid where data is valid (only available in PolyGrid types)

A RegionMask type will contain the following fields:

• lon - An array of longitude points
• lat - An array of latitude points
• mask - An array of NaNs and 1s defining the region within the original field in which data points are valid
ERA5Reanalysis.ERA5RegionGridMethod
ERA5RegionGrid(
e5geo :: ERA5Region{ST,FT},
lon   :: Vector{<:Real},
lat   :: Vector{<:Real}
) -> GeoRegion.RegionGrid

Creates a RegionGrid containing information and mask information required to extract regional data for the ERA5Region from the raw data.

Arguments

• e5geo : A ERA5Region struct type
• lon : A vector containing the longitude points
• lat : A vector containing the latitude points