sp_clip | R Documentation |
sp_clip
uses raster::crop
by default if an envelope is used
rather than rgeos::gIntersection
because the crop
method can
keep the data slot in the spatial object intact (at times).
sp_clip(sp, envelope, sp_polygon = NULL, method = "raster")
sp_crop(sp, envelope, sp_polygon = NULL, method = "raster")
ra_crop(sp, envelope, sp_polygon = NULL, method = "raster")
sp |
Spatial object to be clipped. |
envelope |
A vector with the length of 4 containing the extent of the
envelope to be used as a bounding box. The order is: xmin, xmax, ymin, ymax.
Watch out when using latitude and longitude, the order is longitude, longitude,
then latitude, latitude. These coordinates need to be in the same projection
as |
sp_polygon |
A spatial polygon to use to clip |
method |
What method to use? Default is to use |
If a spatial polygon is supplied, the rgeos::gIntersection
method will
be used.
Stuart K. Grange
sp_filter
, sp_intersect
## Not run:
# Clip a spatial lines object which contains roads in Saudi Arabia
# Build envelope
envelope <- c(23.830562, 25.584393, 45.200111, 47.311495)
# Clip spatial lines
sp_road_clip <- sp_clip(sp_roads, envelope)
# Or use a polygon to clip a road network
sp_roads_clipped <- sp_clip(sp_roads_main, sp_gibraltar_peninsula)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.