Creates a tessellation on the extent of a dbSpatial object with specified parameters.
Other input types are forwarded to GiottoClass::tessellate().
Usage
tessellate(x, extent, ...)
# S4 method for class 'dbSpatial,missing'
tessellate(
x,
extent,
geomName = "geom",
name = "tessellation",
shape = c("hexagon", "square"),
shape_size = NULL,
gap = 0,
radius = NULL,
overwrite = FALSE,
...
)Arguments
- x
dbSpatialobject, or a positional extent-like object supported byGiottoClass::tessellate().- extent
Optional named extent-like object supported by
GiottoClass::tessellate().- ...
Additional arguments passed to methods.
- geomName
character string. The geometry column name in thedbSpatialobject. Default:"geom".- name
character stringname of table to add todbSpatialobject. Default: "tessellation".- shape
character string. A character string indicating the shape of the tessellation. Options are "hexagon" or "square".- shape_size
numeric. the size of the shape in the tessellation. IfNULL, a default size is calculated. SeeGiottoClass::tessellatefor details.- gap
numeric. Value indicating the gap between tessellation shapes. Defaults to 0.- radius
numeric. Value specifying the radius for hexagonal tessellation. This parameter is ignored for square tessellations.- overwrite
logical. Boolean value indicating whether to overwrite an existing tessellation with the same name. Default:FALSE.
Value
dbSpatial object for dbSpatial input, otherwise the result of GiottoClass::tessellate().
Details
tessellate(x = dbSpatial, ...) creates a tessellation over the bounding box of the
dbSpatial geometry column and stores the result as a dbSpatial table.
tessellate(extent = extent, ...) and tessellate(extent, ...) preserve the
GiottoClass::tessellate() extent-based behavior. Supply either x or
extent, but not both.
Examples
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:")
#> duckdb is keeping downloaded extensions in a temporary directory:
#> ℹ /tmp/RtmpIms262/duckdb/extensions
#> This is removed when the R session ends, so extensions are re-downloaded each session.
#> ℹ To keep them, point `options(duckdb.extension_directory =)` or the `DUCKDB_EXTENSION_DIRECTORY` environment variable at a permanent path.
# Create a duckdb table with spatial points
db_points = dbSpatial::dbSpatial(conn = con,
value = dummy_data,
x_colName = "x",
y_colName = "y",
name = "foo",
overwrite = TRUE)
tessellate(db_points, name = "my_tessellation", shape = "hexagon", shape_size = 60)
#> 7 polygons generated
#> # Class: dbSpatial
#> # A query: ?? x 2
#> # Database: DuckDB 1.5.4 [unknown@Linux 6.17.0-1020-azure:R 4.6.1/:memory:]
#> poly_ID geom
#> <chr> <chr>
#> 1 ID_1 POLYGON ((160 564.641, 190 547...
#> 2 ID_2 POLYGON ((220 564.641, 250 547...
#> 3 ID_3 POLYGON ((130 616.6025, 160 59...
#> 4 ID_4 POLYGON ((190 616.6025, 220 59...
#> 5 ID_5 POLYGON ((250 616.6025, 280 59...
#> 6 ID_6 POLYGON ((160 668.5641, 190 65...
#> 7 ID_7 POLYGON ((220 668.5641, 250 65...
