CoordInBounds {lifeR} | R Documentation |
Determine if coordinate is in bounds, and if not, return valid value
CoordInBounds(x, latitude)
x |
numeric four coordinates of bounding box in decimal degrees |
latitude |
logical vector of length four indicating whether each
element in |
A helper function designed to keep map bounds from using invalid coordinates (latitudes outside of -90 and 90; longitudes outside of -180 and 180). Will round values to nearest valid value. A more feature-rich approach could treat longitudes a little more carefully, where values outside the range are updated with the antimeridian in mind. For example, a longitude of 182 would become -178. However, drawing polygons that include the antimeridian are a nightmare, and since that is what will be done with this helper function, it will simply round down to 180.
a copy of the original numeric vector of decimal degrees, x
,
with any invalid values (i.e. a latitude > 90) corrected to their closest
valid value