
Check CRS of a table
ddbs_crs.Rd
Check CRS of a table
Arguments
- conn
a connection object to a DuckDB database
- name
a character string of length one specifying the name of the table, or a character string of length two specifying the schema and table names.
- crs_column
a character string of length one specifying the column storing the CRS (created automatically by
ddbs_write_vector
)
Examples
# \donttest{
## load packages
library(duckdb)
library(duckspatial)
library(sf)
#> Linking to GEOS 3.12.1, GDAL 3.8.4, PROJ 9.4.0; sf_use_s2() is TRUE
## database setup
conn <- dbConnect(duckdb())
ddbs_install(conn)
#> ✔ Spatial extension installed
ddbs_load(conn)
#> ✔ Spatial extension loaded
## read data
countries_sf <- st_read(system.file("spatial/countries.geojson", package = "duckspatial"))
#> Reading layer `countries' from data source
#> `/home/runner/work/_temp/Library/duckspatial/spatial/countries.geojson'
#> using driver `GeoJSON'
#> Simple feature collection with 257 features and 6 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -178.9125 ymin: -89.9 xmax: 180 ymax: 83.65187
#> Geodetic CRS: WGS 84
## store in duckdb
ddbs_write_vector(conn, countries_sf, "countries")
#> ✔ Table countries successfully imported
## check CRS
ddbs_crs(conn, "countries")
#> Coordinate Reference System:
#> User input: EPSG:4326
#> wkt:
#> GEOGCRS["WGS 84",
#> ENSEMBLE["World Geodetic System 1984 ensemble",
#> MEMBER["World Geodetic System 1984 (Transit)"],
#> MEMBER["World Geodetic System 1984 (G730)"],
#> MEMBER["World Geodetic System 1984 (G873)"],
#> MEMBER["World Geodetic System 1984 (G1150)"],
#> MEMBER["World Geodetic System 1984 (G1674)"],
#> MEMBER["World Geodetic System 1984 (G1762)"],
#> MEMBER["World Geodetic System 1984 (G2139)"],
#> ELLIPSOID["WGS 84",6378137,298.257223563,
#> LENGTHUNIT["metre",1]],
#> ENSEMBLEACCURACY[2.0]],
#> PRIMEM["Greenwich",0,
#> ANGLEUNIT["degree",0.0174532925199433]],
#> CS[ellipsoidal,2],
#> AXIS["geodetic latitude (Lat)",north,
#> ORDER[1],
#> ANGLEUNIT["degree",0.0174532925199433]],
#> AXIS["geodetic longitude (Lon)",east,
#> ORDER[2],
#> ANGLEUNIT["degree",0.0174532925199433]],
#> USAGE[
#> SCOPE["Horizontal component of 3D system."],
#> AREA["World."],
#> BBOX[-90,-180,90,180]],
#> ID["EPSG",4326]]
# }