Skip to contents

Function to calculate distance and direction of change between centroids

Usage

dd.calc(raster1, raster2)

Arguments

raster1

A binary spatraster.

raster2

A binary spatraster.

Value

A data frame with distance and direction.

Examples

# \donttest{
library(terra)
r1 <- terra::rast(system.file("extdata", "ref.tif",
package = "divraster"))
r2 <- terra::rast(system.file("extdata", "fut.tif",
package = "divraster"))
dd.calc(r1, r2)
#>    Layer Distance_meters Direction
#> 1      A        6844.296 Southeast
#> 2      B        2646.550 Northwest
#> 3      C       13967.055 Northwest
#> 4      D        9453.585 Northwest
#> 5      E        5488.573 Northwest
#> 6      F        3300.834 Northwest
#> 7      G        3895.065 Southwest
#> 8      H        3460.013 Northeast
#> 9      I        7479.346 Northwest
#> 10     J        2390.447 Southwest
# }