Reputation: 383
I am currently trying to clip one spatial file to another however the spatial file I get is not the right shape. I know with a raster you have to use a mask, is there a similar command for 2 shape files?
c1 <- crop(spatial1, spatial2)
Upvotes: 0
Views: 132
Reputation: 47591
With the SpatialPolgyonDataFrame objects
library(raster)
p <- shapefile(system.file("external/lux.shp", package="raster"))
b <- as(extent(6, 6.4, 49.75, 50), 'SpatialPolygons')
crs(b) <- crs(r)
You can do
pc <- crop(p, b)
You need to have packages rgdal
and rgeos
installed.
Upvotes: 1