I need to subset a global fishing dataset to just have the fishing in the Pacific. Right now I have a shapefile of the Pacific and I am using the sp method of subsetting (see below)
oceans <- readOGR(dsn = ".", layer = "PacificOcean") gfw = readRDS(filename2) gfw <- SpatialPointsDataFrame(coords = gfwcoords, data = gfwdata, proj4string = CRS(proj4string(oceans))) gfwmask<- gfw[oceans, ]
This works just fine, BUT, I need to do it hundreds of times and it takes several minutes each time. Does anyone have suggestions for a faster method to subset a dataframe by a shapefile?