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
.
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.isinERA5Region
— FunctionisinERA5Region(
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 TypePoint2
. PassPoint2(plon,plat)
, whereplon
andplat
are the longitude and latitudes of the point.e5geo
: The ERA5Region struct container
Keyword Arguments
tlon
: Threshold for the longitude boundtlat
: Threshold for the latitude boundthrow
: Iftrue
, then ifPoint
is not withingeo
, 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 bye5geo
e5geo
: An ERA5Region that we postulate to be a "parent", or containing the GeoRegion defined bygeo
Keyword Arguments
throw
: Iftrue
, then ifgeo
is not withine5geo
, an error is thrown and the program stops runningdomask
: Ifthrow
isfalse
anddomask
istrue
, return a mask (with bounds defined by thegeo
GeoRegion) showing the region wheregeo
ande5geo
do not overlap