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

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

dbSpatial

object

name

string. name of table to add to dbSpatial object.

Value

dbSpatial object

Functions

  • st_translate(dbSpatial): Method for dbSpatial object

Examples

con = DBI::dbConnect(duckdb::duckdb(), ":memory:")

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
#> # Class:    dbSpatial 
#> # Source:   table<points> [3 x 5]
#> # Database: DuckDB v1.0.0 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:]
#>       x     y    id name  geom      
#>   <dbl> <dbl> <int> <chr> <list>    
#> 1   100   500     1 A     <raw [32]>
#> 2   200   600     2 B     <raw [32]>
#> 3   300   700     3 C     <raw [32]>

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

points_translated
#> # Class:    dbSpatial 
#> # Source:   SQL [3 x 5]
#> # Database: DuckDB v1.0.0 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:]
#>       x     y    id name  geom      
#>   <dbl> <dbl> <int> <chr> <list>    
#> 1   100   500     1 A     <raw [32]>
#> 2   200   600     2 B     <raw [32]>
#> 3   300   700     3 C     <raw [32]>