intersecting_units: Find intersecting units

Description Usage Arguments Details Value See Also Examples

Description

Determine the units in a given spatial data object that intersect with any of the units in another spatial data object.

Usage

1
2
3
4
5
6
7
8
9
intersecting_units(x, y, ...) # x=Raster, y=Raster

intersecting_units(x, y, ...) # x=Spatial, y=Spatial

intersecting_units(x, y, ...) # x=Raster, y=Spatial

intersecting_units(x, y, ...) # x=Spatial, y=Raster

intersecting_units(x, y, ...) # x=data.frame, y=ANY

Arguments

x

Spatial-class or Raster-class object.

y

Spatial-class or Raster-class object.

...

not used.

Details

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

Value

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

See Also

fast_extract, set_number_of_threads, get_number_of_threads.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## 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))

## 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))

## 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))

## 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))

prioritizr/prioritizrutils documentation built on May 25, 2019, 12:20 p.m.