I want to select a subset of my map (a SpatialPolygonsDataFrame) to create a new vector map = part of the initial map included inside a given polygon (eventually, inside several polygons).
I have a large study area, under the object "parcel", and would like to select the part of the map inside the polygon "hr_kud". This is basically the part of my study area used by an animal, so I want to compute basic statistics on this new map and used it for new analyses (of habitat selection).
I have to repeat this operation for about 100 animals...
Here are my data :
http://dl.free.fr/vX4TA8nsE
parcel = my study area map. and hr_kud = an example of homerange used to reduce the study area
Here is a part of my R code, used under Rstudio (R version 2.15.2 (2012-10-26)) :
library(rgeos)
load("Data.RData")
class(parcel)
[1] "SpatialPolygonsDataFrame"
attr(,"package")
[1] "sp"
class(hr_kud)
[1] "SpatialPolygonsDataFrame"
attr(,"package")
[1] "sp"
object.size(hr_kud)
9536 bytes
object.size(parcel)
88090144 bytes
plot(parcel, axes=TRUE)
plot(hr_kud, col="red", add=TRUE)
And when I run my final command, it causes Rstudio to crash :
hr_map <- gIntersection(parcel, hr_kud, byid=TRUE)
It is not the first crash reported, but non of the answers find on the net are efficient for me... It's exactly the same using R and all my packages are updated.
So If you have any idea of why it's crashing, or of an alternative method to create my subset map or intersect two SpatialPolygonsDataFrame in R, I will be really appreciated !
thanks in advance,
Sophie