Find which of the units in a spatial data object intersect with the units in another spatial data object.
# S4 method for Raster,Raster intersecting_units(x, y) # S4 method for Spatial,Spatial intersecting_units(x, y) # S4 method for Raster,Spatial intersecting_units(x, y) # S4 method for Spatial,Raster intersecting_units(x, y) # S4 method for data.frame,ANY intersecting_units(x, y)
x 


y 

integer
indices of the units in x
that intersect with
y
.
The set_number_of_threads
can be used to distribute
computations among multiple threads and potentially reduce run time.
# create data r < raster(matrix(1:9, byrow = TRUE, ncol=3)) r_with_holes < r r_with_holes[c(1, 5, 9)] < NA ply < rasterToPolygons(r) ply_with_holes < rasterToPolygons(r_with_holes) # intersect raster with raster par(mfrow = c(1, 2)) plot(r, main = "x=Raster") plot(r_with_holes, main = "y=Raster")#> [1] 2 3 4 6 7 8# intersect raster with polygons par(mfrow = c(1, 2)) plot(r, main = "x=Raster") plot(ply_with_holes, main = "y=Spatial")#> [1] 2 3 4 6 7 8# intersect polygons with raster par(mfrow = c(1, 2)) plot(ply, main = "x=Spatial") plot(r_with_holes, main = "y=Raster")#> [1] 2 3 4 6 7 8# intersect polygons with polygons par(mfrow = c(1, 2)) plot(ply, main = "x=Spatial") plot(ply_with_holes, main = "y=Spatial")#> [1] 2 3 4 6 7 8