Skip to contents

This function translates point geometries by the specified delta x and delta y values.

Usage

st_translate(dbSpatial, geomName = "geom", dx, dy, ...)

# S4 method for class 'dbSpatial'
st_translate(dbSpatial, geomName = "geom", dx, dy, ...)

Arguments

dbSpatial

dbSpatial object.

geomName

character string. The geometry column name in the dbSpatial object. Default: "geom".

dx

numeric.value to shift x coordinates by

dy

numeric. value to shift y coordinates by

...

additional arguments passed to methods

Value

dbSpatial object

Functions

  • st_translate(dbSpatial): Method for dbSpatial object

Examples

if (interactive() && requireNamespace("duckdb", quietly = TRUE)) {
  con = DBI::dbConnect(duckdb::duckdb(), ":memory:")
  DBI::dbExecute(con, "SET threads = 1")

  coordinates <- data.frame(x = c(100, 200, 300), y = c(500, 600, 700))
  attributes <- data.frame(id = 1:3, name = c("A", "B", "C"))

  # Combine the coordinates and attributes
  dummy_data <- cbind(coordinates, attributes)

  points <- dbSpatial(conn = con,
                      name = "points",
                      value = dummy_data,
                      overwrite = TRUE,
                      x_colName = "x",
                      y_colName = "y")

  points

  points_translated <- st_translate(dbSpatial = points, dx = 100, dy = -20)

  points_translated
  DBI::dbDisconnect(con, shutdown = TRUE)
}