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)

Arguments

x Spatial-class or Raster-class object. Spatial-class or Raster-class object.

Value

integer indices of the units in x that intersect with y.

Details

The set_number_of_threads can be used to distribute computations among multiple threads and potentially reduce run time.

Examples

# 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") print(intersecting_units(r, r_with_holes))
#>  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") print(intersecting_units(r, ply_with_holes))
#>  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") print(intersecting_units(ply, r_with_holes))
#>  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") print(intersecting_units(ply, ply_with_holes))
#>  2 3 4 6 7 8