Reproject and crop Spatial and sf objects to SOmap objects
SOauto_crop(layer, x, sp = TRUE)
Arguments
- layer
: an sf
or Spatial
(SpatialPolygonsDataFrame, SpatialLinesDataFrame, SpatialPointsDataFrame etc) object to reproject and crop
- x
: a SOmap or SOauto_map object
- sp
logical: if TRUE
, return the cropped object in Spatial
form, otherwise sf
Value
If successful, a reprojected and cropped version of layer
. If the reprojection or cropping operations fail, the returned object will be of class try-error
. If the cropping operations return an empty object (i.e. no parts of layer
lie within the bounds of x
) then the returned object will either be NULL
(if sp = TRUE
) or an sf
object with no features if sp = FALSE
.
Examples
if (FALSE) { # \dontrun{
a <- SOmap_auto(c(0, 50), c(-70, -50))
x <- SOauto_crop(SOmap_data$fronts_orsi, a)
plot(a)
plot(x, add = TRUE)
a <- SOmap(trim = -60)
x <- SOauto_crop(SOmap_data$EEZ, a)
plot(a)
plot(x, add = TRUE)
} # }