What is a RegionGrid?

But how do we go from defining a GeoRegion, to extracting data for that GeoRegion? The answer is with the information in the RegionGrid types, which maps gridded lon-lat data to a given GeoRegion as follows:

  • Mapping gridded lon-lat data to a RectRegion gives a RectGrid structure
  • Mapping gridded lon-lat data to a PolyRegion gives a PolyGrid structure
  • Mapping non-rectilinear gridded lon-lat data to a RegionMask gives a RegionMask structure

However, the basic uses of RectGrid and PolyGrid are the same, and as such their differences are largely transparent to the user, except for one field found in PolyGrid, the mask, which will be elaborated upon later.

GeoRegions.RegionGridType
RegionGrid

Abstract supertype for geographical region gridded information, 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-rectilinear 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
source

So basically a RegionGrid contains information on the indices of the gridded data that are part of the GeoRegion, thus helping us extract the relevant data for a given GeoRegion.