Date: 2018-04-11 15:41 Sender: Colin CaineThis one keeps the crs of `rasta`
# Crop a Simple Features Data Frame to the extent of a raster
crop.sf3 <- function(sfdf, rasta) {
# Get extent and crs
ext.sp <- as(extent(rasta), "SpatialPolygons")
crs(ext.sp) <- crs(rasta)
# crop
st_intersection(sfdf, st_as_sf(ext.sp))
} |