Skip to content
Prev 25070 / 29559 Next

Write sf object to spatialite database

On 10/11/2016 17:15, Edzer Pebesma wrote:
I thought I did, but I'm no expert in databases, when I run

dplyr::src_sqlite('~/sandbox/db.sqlite')

rc:  sqlite 3.8.6 [~/sandbox/db.sqlite]
tbls: ElementaryGeometries, geom_cols_ref_sys, geometry_columns,
geometry_columns_auth,
geometry_columns_field_infos, geometry_columns_statistics,
geometry_columns_time, meuse_tbl,
SpatialIndex, spatialite_history, spatial_ref_sys, spatial_ref_sys_all,
spatial_ref_sys_aux,
sqlite_sequence, sql_statements_log, vector_layers, vector_layers_auth,
vector_layers_field_infos, vector_layers_statistics, views_geometry_columns,
views_geometry_columns_auth, views_geometry_columns_field_infos,
views_geometry_columns_statistics, virts_geometry_columns,
virts_geometry_columns_auth,
virts_geometry_columns_field_infos, virts_geometry_columns_statistics

Doesn't it mean that all the spatial extensions of sqlite are loaded?
yes it does.
That way I managed to write to the database (created on the fly if it
doesn't exist). I did not manage to add several tables to the same
database though.


st_write(sf, dsn = '/home/loic/sandbox/db2.sqlite', layer = 'meuse1',
driver = 'SQLite')
st_write(sf, dsn = '/home/loic/sandbox/db2.sqlite', layer = 'meuse2',
driver = 'SQLite')
ogrListLayers('/home/loic/sandbox/db2.sqlite')

[1] "meuse2"
attr(,"driver")
[1] "SQLite"
attr(,"nlayers")
[1] 1

I remember a similar issue/limitation with writeOGR
http://r-sig-geo.2731867.n2.nabble.com/Adding-spatial-tables-to-existing-SpatiaLite-DBs-td7589137.html

Cheers,
Lo?c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://stat.ethz.ch/pipermail/r-sig-geo/attachments/20161110/b90bbd87/attachment.bin>