Packaging algorithm
The plugin registers a single Processing algorithm, stratified_packager:package
(Package project). It partitions the open project’s layers against a stratification
layer and writes one zipped GeoPackage per stratum into an output directory.
Features are matched to strata either by attribute (following chains of the project’s
QgsRelations) or spatially (a predicate, including a raw DE-9IM pattern), chosen per
layer. Outputs are zip-only: a .gpkg exists on disk only transiently while it is built and
then inside its zip.
Running it
From the QGIS GUI
Open Processing ▸ Toolbox ▸ Stratified Packager ▸ Package project. The dialog’s defaults are pre-filled from the active project (see Defaults & precedence); the Layers field is pre-checked with the eligible layers.
Headless, with qgis_process
qgis_process only loads provider plugins that have been enabled for it (separately from
the desktop). Enable it once per user profile:
qgis_process plugins enable stratified_packager
Then run the algorithm:
qgis_process run "stratified_packager:package" \
--project_path=/path/to/project.qgz \
--OUTPUT_DIRECTORY=/path/to/out \
--STRATIFICATION_LAYER=districts
--project_path is required — the algorithm declares
Qgis.ProcessingAlgorithmFlag.RequiresProject. The Processing framework re-instantiates the
algorithm after the project loads, so project-variable and plugin-setting defaults resolve
correctly without a GUI. QgsSettings is per-profile, so qgis_process uses the default
profile unless you override it.
Parameters
Advanced parameters are collapsed in the GUI by default.
Parameter |
Meaning |
|---|---|
|
Layers to package; empty = every eligible layer not marked |
|
The partition source — one stratum per feature. |
|
How each stratum is named (empty = feature id). |
|
GeoPackage / zip paths (advanced). |
|
Where the zips are published (atomic |
|
Zip Deflate level 0–9 (0 stores uncompressed). |
|
|
|
|
|
Only the stratification layer’s selected features become strata (fails when nothing is selected). |
|
Build in a temporary folder and publish finished zips (off: build inside the output directory). |
|
Embed layer styles / metadata. |
|
Which style categories the QML copies (none checked = all). |
|
Keep zero-feature layers as empty tables. |
|
Write layers sharing a source as one table. |
|
Stage every layer of these data providers into a fast local copy first (see the |
|
Also emit the unpartitioned dataset. |
|
Run report output: an in-memory table layer when no path is given, else a file. |
|
Also write a |
|
Extra files copied into every zip root. |
|
The warm cache: |
|
Write a |
|
Validate and report without writing packages. |
The expression contexts for the naming and path expressions expose @stratum_name,
@stratum_name_sanitized, @gpkg_path and @gpkg_name.
Per-layer variables
Each layer carries QGIS layer variables that tune its participation. Edit them under Layer Properties ▸ Variables, on the plugin’s per-layer page, or in the all-layers Configure layers for packaging dialog (plugin menu).
Variable |
Type |
Default |
Meaning |
|---|---|---|---|
|
bool |
|
Skip this layer when |
|
enum |
|
|
|
list |
|
Comma-separated named predicates and/or 9-char DE-9IM patterns, combined with OR (invalid patterns are rejected at run-start). |
|
JSON list |
unset |
Pin an ambiguous attribute chain. |
|
JSON list |
|
Fields dropped from the export. |
|
bool |
|
Force ( |
|
bool |
|
Layer belongs to the warm cache. |
|
expression |
unset |
Custom display name inside each embedded per-stratum project (may use |
|
bool |
|
Write a virtual layer’s features into the GeoPackage instead of keeping the layer live in the embedded project. |
With matching_method = auto: if a relation path to the stratification layer exists the layer
matches by attribute; otherwise, if both the layer and the stratification layer have
geometry, it matches spatially; otherwise the run aborts naming the layer and the remedies.
auto never resolves to whole_export — whole export is always an explicit choice.
For spatial matching, spatial_predicate accepts several predicates at once — a comma-separated
list of named predicates (intersects, contains, within, overlaps, crosses, touches)
and/or raw DE-9IM patterns — that combine additively (a feature matches if any of them holds).
With spatial_predicate = auto, a polygon stratum paired with a line layer (or the reverse)
defaults to “interiors intersect, or the line runs along the polygon boundary”, a point on either
side to intersects, and otherwise to “interiors intersect”.
Defaults & precedence
Every omitted parameter resolves through a four-tier chain:
explicit input → project variable (
stratified_packager_<param>) → plugin setting → builtin default
Project- and layer-scope values are editable from three places, each showing the inherited effective value as a placeholder:
the plugin Options page (plugin-wide settings, with a note when a project shadows one);
the Project Properties page (project-scoped defaults);
the per-layer page and the Configure layers for packaging dialog (layer variables).
In a GUI session the dialog defaults refresh automatically when you load a project or edit the relevant variables. The same chain is re-applied at run start, so headless runs and stale instances resolve identically.
Warm cache
When a warm-cache directory is set, WARM_START_MODE=use begins each stratum GeoPackage from
a cached copy and appends only the layers that are not warm-marked; WARM_START_MODE=update
first writes every stratum’s cache file and only then builds the deliverables, seeded from
that fresh cache — an interrupted run still leaves a complete, reusable cache. If a cached
file no longer matches its warm-marked tables, that stratum falls back to a cold build
(reported as cold-fallback).
Output layout
Each published zip mirrors this structure (optional members depend on the parameters):
<output_directory>/
├── <zip_path>.zip
│ ├── <gpkg_path>.gpkg # the stratum GeoPackage: one table per layer,
│ │ # plus layer_styles / gpkg_metadata when embedded
│ ├── <gpkg_basename>.qgz # embedded project (PROJECT_INCLUSION = qgz)
│ ├── data/ # whole-export & non-vector sources, with sidecars
│ │ └── <table>/…
│ ├── resources/ # style assets (SVGs, images) referenced by the QML
│ │ └── …
│ └── report.csv # per-zip report (GENERATE_REPORT)
├── <zip_path>.zip.sha256 # checksum sidecar (WRITE_CHECKSUMS)
└── report.csv # run report, only when REPORT is given a path here
With PROJECT_INCLUSION = gpkg the per-stratum project is stored inside the GeoPackage (via
QgsProjectStorage) instead of as a sibling .qgz.
Reports
The algorithm always produces a run-level report as the REPORT output: with no
destination it is loaded as an in-memory table layer; given a path it is written there (CSV,
GeoPackage, …). Independently, GENERATE_REPORT (on by default) adds a per-zip report.csv
to each published zip. Both are UTF-8 without BOM and are data, not translated. Rows record each
layer’s per-stratum status (written, empty, skipped, cold-fallback, …), unmatched features
(<unmatched>), and — under DRY_RUN — what would be written.