Skip to contents

Get extent of a geometry column in dbSpatial object

Usage

st_extent(dbSpatial, geomName = "geom", ...)

# S4 method for class 'dbSpatial'
st_extent(dbSpatial, geomName = "geom", ...)

Arguments

geomName

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

...

additional arguments passed to methods

dbSpatial

object

Value

named numeric vector

Functions

  • st_extent(dbSpatial): Method for dbSpatial objects

See also

Other geom_summary: st_xmax(), st_ymax()

Examples

# Create a data.frame with x and y coordinates and attributes
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)

# Create a duckdb connection
con = DBI::dbConnect(duckdb::duckdb(), ":memory:")

# Create a duckdb table with spatial points
db_points = dbSpatial(conn = con,
                      value = dummy_data,
                      x_colName = "x",
                      y_colName = "y",
                      name = "foo",
                      overwrite = TRUE)
                      
# Get extent of the table
st_extent(db_points)
#> Warning: Missing values are always removed in SQL aggregation functions.
#> Use `na.rm = TRUE` to silence this warning
#> This warning is displayed once every 8 hours.
#> xmin xmax ymin ymax 
#>  100  300  500  700