TransWikia.com

Creating geopackage layers as output with QGIS batch processing autofill option

Geographic Information Systems Asked by Aquamarine on April 2, 2021

Is it possible to use the Calculate by Expression tool to output geopackage layers. For example, with the batch option for the polygon to line function. With the following expressions I can create individual shapefiles or individual geopackage files but not layers in a geopackage file;

This creates a separate geopackage file for each layer;@project_folder ||'/' || @INPUT || '_line'

enter image description here
This creates a separate shapefile for each layer;
@project_folder ||'/' || @INPUT || '_line.shp'

However, I can’t find a way to output layers to the one Geopackage file. The Polygon to Line function seems to default to individual geopackage files if no extension is given. The following creates output – not individual layers but separate geopackage files;
@project_folder ||'/test.gpkg layername=' || @INPUT ||'_line
The file names end up like this;
enter image description here

One Answer

To save the output of a geoprocessing algorithm into a new layer/table of an existing geopackage, you can use the following syntax:

ogr:dbname='C:/Path/To/Geopackage.gpkg' table="New_Table" (geom)

If you want to use this in Calculate By Expression for the outputs of a batch processing, the expression could look like the following:

'ogr:dbname='' || @project_folder || '/Lines.gpkg' table="' || @INPUT || '_line.shp" (geom)'

This will return the output parameters...

Example for batch processing into separate geopackge layers

... and will create a new geopackage layer for every input:

Batch processing log for separate new geopackage layers

Answered by malbles on April 2, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP