[R-sig-Geo] Write sf object to spatialite database

Loïc Dutrieux loic.dutrieux at conabio.gob.mx
Thu Nov 10 15:47:44 CET 2016


Hi,

Is it possible to write sf objects to spatialite databases? I tried to
adapt the postgis example of the st_write_db function but I get the
following error:

Error in sqliteSendQuery(con, statement, bind.data) :
error in statement: no such function: AddGeometryColumn

Cheers,
Loïc

library(sf)
library(sp)
library(RSQLite)

data(meuse)
sf = st_as_sf(meuse, coords = c("x", "y"), crs = 28992)

# I created the db with QGIS, I don't know how to do otherwise
con <- dbConnect(RSQLite::SQLite(), '~/sandbox/db.sqlite')

st_write_db(con, sf, "meuse_tbl", dropTable = FALSE)



More information about the R-sig-Geo mailing list