The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Spatial Operations

library(dbSpatial)
library(sf)
library(dplyr)

Setup

con <- DBI::dbConnect(duckdb::duckdb(), ":memory:")
DBI::dbExecute(con, "SET threads = 1")

# Sample points
df <- data.frame(id = 1:3, x = c(0, 10, 20), y = c(0, 10, 20))
pts <- dbSpatial(
  conn = con, name = "pts", value = df,
  x_colName = "x", y_colName = "y", overwrite = TRUE
)
pts

Geometry Operations

# Buffer
st_buffer(pts, dist = 5)

# Centroid
st_centroid(pts)

# Simplify
st_simplify(pts, dTolerance = 1)

Measurements

# Bounding box
st_bbox(pts)

# Check validity
st_is_valid(pts)

Spatial Joins

Use st_join() to perform spatial joins with various predicates:

# Self-join using intersection predicate (returns joined table)
st_join(pts, pts, join = st_intersects)

Convert to sf

sf_pts <- st_as_sf(pts)
sf_pts

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.