1

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

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.