Computes the positions of the adjusted points by fitting image points to source points.
Note that points generated by the dc_generate_positions_from_durations
function and by the dc_move_from_reference_point
do not need to be adjusted.
Examples
library(sf)
#> Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.4.0; sf_use_s2() is TRUE
# Read source points
source_pts <- st_read(
dsn = system.file("gpkg/data-prefecture.gpkg", package = "distanamo"),
layer = "prefecture", quiet = TRUE
)
# Read non adjusted image points
image_pts_not_adj <- st_read(
dsn = system.file("gpkg/data-prefecture.gpkg", package = "distanamo"),
layer = "image-points-not-adjusted", 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
)
# Adjust image points to source points
adj_result <- dc_adjust(
source_points = source_pts,
image_points = image_pts_not_adj,
"euclidean"
)
# Use adjusted points to create the interpolation grid
igrid <- dc_create(
source_points = source_pts,
image_points = adj_result$image_points,
precision = 2,
bbox = st_bbox(background_layer)
)
# Deform the target layer
background_deformed <- dc_interpolate(
interpolation_grid = igrid,
layer_to_deform = background_layer
)