if (FALSE) {
data("volcano")
dem <- terra::rast(volcano)
dem <- dem * 10
terra::ext(dem) <- terra::ext(dem) * 10
terra::ext(dem) <-terra::ext(dem) + c(510, 510, 510, 510)
## define example stations
stations <- cbind(c(200, 700), c(220, 700))
## plot example data
terra::plot(dem)
points(stations[,1], stations[,2])
## calculate distance matrices and stations distances
D <- spatial_distance(stations = stations,
dem = dem)
terra::plot(D$maps[[1]])
## show station distance matrix
print(D$matrix)
## calculate with AOI and in verbose mode
D <- spatial_distance(stations = stations,
dem = dem,
verbose = TRUE,
aoi = c(0, 200, 0, 200))
## plot distance map for station 2
terra::plot(D$maps[[1]])
}
Run the code above in your browser using DataLab