Skip to contents

Adds a small increment to the current offset of one region or label in a d_state(). This is the scripted equivalent of dragging slightly in the browser: existing movement is preserved and the delta is added on top. Unknown ids gain a new row, matching update_region_offset().

Usage

d_nudge(state, id, dx_m = 0, dy_m = 0, target = c("region", "label"))

Arguments

state

A dragmapr_state object.

id

Region id (when target = "region") or label id (when target = "label") to nudge.

dx_m, dy_m

Distances in metres added to the current offset. Each must be a single finite number.

target

One of "region" (default) or "label".

Value

An updated dragmapr_state with a bumped version.

Examples

state <- d_state(
  region_offsets = data.frame(region = "A", dx_m = 10, dy_m = 0)
)
state <- d_nudge(state, "A", dx_m = 5)
state$region_offsets
#>   region dx_m dy_m
#> 1      A   15    0