[R-sig-Geo] Error reading spatialite table with sf::st_read

DUTRIEUX Loic Lo|c@DUTRIEUX @end|ng |rom ec@europ@@eu
Thu Mar 3 17:47:41 CET 2022


Hi everyone,

When trying to read data contained in a sqlite table with the full spatialite options (see what FORMAT=SPATIALITE implies here --> https://gdal.org/drivers/vector/sqlite.html), I get a 
wkbType: 30078980 Error in inherits(sfc, "try-error") : object 'sfc' not found.

See the example below:

# In bash
ogr2ogr -F SQLITE -dsco SPATIALITE=YES /tmp/olinda1.sqlite ~/R/x86_64-pc-linux-gnu-library/4.0/sf/shape/olinda1.shp

# In R
library(sf)
library(DBI)

con <- dbConnect(RSQLite::SQLite(), '/tmp/olinda1.sqlite')
st_read(con, query='select * from olinda1;')


If I create the database without the SPATIALITE=YES creation option (geometries encoded as WKB), reading with sf partly works (no CRS) but then I lose the spatialite functionalities. Any suggestion?

Kind regards,
Loïc



More information about the R-sig-Geo mailing list