2018-03-07 RM Hogervorst MIT licence
I wrote this short gist down because this feature is not well documented.
If you have some potentially expensive computation and want to use the results of that selectively. If you precalculate something, but don't want to load the entire thing in memory.
What?
Example: I calculated great circles (lines over curvature of earth) between all countries in the world, this calculation took minutes.
I want to use this in many ways, but the resulting file is rather large (156 Mb). Per session I might only need a subset of that.
write_sf() actually takes care of many things: sets all sorts of information, makes tables, and writes the sqlite file.
This line mutate(geometry = st_as_sfc(GEOMETRY))
sets the type of that column and gives it the name
of geometry. The sf dataframe uses geometry as default column, so this takes care of that.