Skip to contents

This function returns whether the specified geometry column in the specified dbSpatial object is valid or not.

Usage

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

# S4 method for class 'dbSpatial'
st_isvalid(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

boolean column vector in database

Functions

  • st_isvalid(dbSpatial): Method for dbSpatial object

See also

Other geom_scalar: st_geometrytype()

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 SpatVector from the data.frame
dummy_spatvector <- terra::vect(dummy_data, geom = c("x", "y"))

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

# Create a duckdb table with spatial points
db_points = dbSpatial(conn = duckdb_conn,
                      name = "spatVector_proxy",
                      value = dummy_spatvector,
                      overwrite = TRUE)

# Check if geometries are valid
st_isvalid(dbSpatial = db_points)
#> # Class:    dbSpatial 
#> # Source:   SQL [3 x 1]
#> # Database: DuckDB v1.0.0 [unknown@Linux 6.5.0-1025-azure:R 4.4.1/:memory:]
#>   geom 
#>   <lgl>
#> 1 TRUE 
#> 2 TRUE 
#> 3 TRUE