Are Points / GeoRegions in an ERA5Region?

When dealing with geographic data, we often wish to check if a point or region is inside another region. In ERA5Reanalysis, we build upon the functionality of GeoRegions.jl with the wrapper isinERA5Region(), so you can perform this check easily without needing to perform and extra step and extract the GeoRegion from the ERA5Region.

Point Type

We use the Point2 Type from the package GeometryBasics.jl, which is reexported by ERA5Reanalysis.jl, as an easy way to denote points. This also allows us to use the package PolygonOps.jl to determine if a point is inside a region.

ERA5Reanalysis.isinERA5RegionFunction
isinERA5Region(
    point :: Point2{<:Real},
    e5geo :: ERA5Region;
    tlon  :: Real = 0,
    tlat  :: Real = 0,
    throw :: Bool = true
) -> Bool

Check if a geographical point Point is within an ERA5Region defined by e5geo.

Arguments

  • point : A geographical point of Type Point2. Pass Point2(plon,plat), where plon and plat are the longitude and latitudes of the point.
  • e5geo : The ERA5Region struct container

Keyword Arguments

  • tlon : Threshold for the longitude bound
  • tlat : Threshold for the latitude bound
  • throw : If true, then if Point is not within geo, an error is thrown and the program stops running.
isinERA5Region(
    geo    :: GeoRegion,
    e5geo  :: ERA5Region;
    domask :: Bool = false,
    throw  :: Bool = true
) -> Bool

Check if a child GeoRegion defined by geo is within a ERA5Region e5geo.

Arguments

  • geo : A GeoRegion that we postulate to be a "child", or a subset of the ERA5Region defined by e5geo
  • e5geo : An ERA5Region that we postulate to be a "parent", or containing the GeoRegion defined by geo

Keyword Arguments

  • throw : If true, then if geo is not within e5geo, an error is thrown and the program stops running
  • domask : If throw is false and domask is true, return a mask (with bounds defined by the geo GeoRegion) showing the region where geo and e5geo do not overlap