Move points from a reference point
Source:R/dc_move_from_reference_point.R
dc_move_from_reference_point.Rd
Move points from a reference point using durations between the reference point and all the other points.
Value
A list object with the source points and the image points, ready to be used with the dc_create function
Examples
library(sf)
# Read source points
source_pts <- st_read(
dsn = system.file("gpkg/data-prefecture.gpkg", package = "distanamo"),
layer = "prefecture", quiet = TRUE
)
# Read the background layer to deform
background_layer <- st_read(
dsn = system.file("gpkg/data-prefecture.gpkg", package = "distanamo"),
layer = "departement", quiet = TRUE
)
durations_mat <- read.csv(system.file("csv/mat.csv", package = "distanamo"), row.names = 1)
dur <- durations_mat["CAEN", ]
source_pts$durations <- as.double(dur)
ref_point <- subset(source_pts, source_pts$NOM_COM == "CAEN")
other_points <- subset(source_pts, !source_pts$NOM_COM == "CAEN")
# Generate position from durations between the reference point
# and the other points
positioning_result <- dc_move_from_reference_point(
reference_point = ref_point,
other_points = other_points,
duration_col_name = "durations",
factor = 1
)
# Display and plot useful information about the positioning step
plot(positioning_result)
summary(positioning_result)
#> Summary of the unipolar displacement result:
#> Min displacement: 821.2748 [m]
#> Mean displacement: 17560.79 [m]
#> Max displacement: 58014.19 [m]
# Create the interpolation grid
igrid <- dc_create(
source_points = positioning_result$source_points,
image_points = positioning_result$image_points,
precision = 2.0,
bbox = st_bbox(background_layer)
)
# Deform the background layer
background_deformed <- dc_interpolate(
interpolation_grid = igrid,
layer_to_deform = background_layer
)