Clips an area from a larger shapefile provided in sf or sp formats.
clip_shapefile(
x,
limits,
proj.limits = 4326,
simplify = FALSE,
tol = 60,
return.boundary = FALSE,
extra.validate = FALSE
)
Clipped spatial object. If return.boundary = TRUE
, a list containing the shapefile together with the clip boundary.
Original shapefile to be clipped as a an sf or sp
polygons object. Required. Must contain CRS
information.
The constraining area used to clip x
. Required. Either a numeric vector of length 4 or a spatial object from the sf or sp packages. The first element of the numeric vector defines the minimum longitude, second element the maximum longitude, third element the minimum latitude and fourth element the maximum latitude of the bounding box. If a spatial object, it must contain CRS
information. See details.
The CRS
projection attributes for limits
. Hence format accepted by st_crs
will suffice but integers are the easiest. Defaults to decimal degrees.
Should the x
geometry be simplified before clipping? Useful to make the function faster for large shape files. Uses st_simplify
function.
Numerical tolerance value to be used for simplification. See ?sf::st_simplfy
.
Logical. If TRUE
returns the clip boundary together with the shapefile.
Logical indicating whether x
should be run through extra validation. Slows down the function but is necessary in some cases involving anti-meridian.
Mikko Vihtakari
The function uses the st_intersection
function to clip smaller polygons from larger ones. The clip area is constrained by either a numeric vector or a spatial object in the limits
argument. Defining limits
by a sf
object gives greater freedom for the clip area as the area does not have to be rectangular.
Other create shapefiles:
geonorge_bathymetry()
,
raster_bathymetry()
,
vector_bathymetry()