library(qgisprocess) library(dplyr) conf <- ruut::get_config() gpkg_file <- "/data/gpkg/artiklid/artikkel_210127_valga_matsalu_lahemaa/valga.gpkg" # Vaata layer'eid sf::st_layers(gpkg_file) # Vali layer layer <- "epk200t_grid" conf$table <- "aaa_1" conf$schema <- "data" ruut::copy_gpkg_to_db(gpkg = gpkg_file, layer = layer, conf = conf) # ruut::copy_gpkg_to_db(gpkg = gpkg_file, conf = conf) sf::st_layers(gpkg_file) sp <- sf::read_sf(dsn = gpkg_file, layer ) plot(sp) sf::st_geometry(sp) %>% plot() # write to gpkg sf::st_write(sp, dsn = "/data/gpkg/artiklid/artikkel_210127_valga_matsalu_lahemaa/xxxxx.gpkg", layer = "layerThree", driver = "gpkg", layer_options = "OVERWRITE=true") system(sprintf("ogr2ogr -f GPKG -update %s %s -nln layerThree", gpkg_file, sp)) system("ogr2ogr --long-usage") result <- qgis_run_algorithm( "native:buffer", INPUT = gpkg_file, DISTANCE = .0000011, DISSOLVE = TRUE, .quiet = TRUE ) sf::st_geometry( sf::read_sf(qgisprocess::qgis_output(result, 'OUTPUT'))) %>% plot() pg <- ruut::construct_ogr2ogr_PG_connect_str(conf = conf) gpkg_file <- "/data/gpkg/artiklid/artikkel_210127_valga_matsalu_lahemaa/xxxxx.gpkg" system(sprintf("ogr2ogr -f GPKG %s %s %s -nln layerOne", gpkg_file, pg, conf$table)) system(sprintf("ogr2ogr -f GPKG -update %s %s %s -nln layerOne", gpkg_file, pg, conf$table)) # ogr2ogr -f GPKG dst.gpkg src.shp -nln layerOne # ogr2ogr -f GPKG -update dst.gpkg src.shp -nln layerTwo # ## only two features by where clause nc_sql = st_read(system.file("shape/nc.shp", package="sf"), query = "SELECT NAME, SID74, FIPS FROM \"nc\" WHERE BIR74 > 20000")