package-lines
See docs/reference/README.md for the MUST/SHOULD/MAY convention, and
docs/reference/shared.md for rules package-lines shares with other
tools.
Inputs¶
package-linesMUST read the input and reproject it to EPSG:4326.package-linesMUST detect every admin level present, either structurally (core.schema_map's cardinality/containment matcher, no naming convention assumed, the default whenname_field/code_fieldare omitted) or via an explicitname_field/code_fieldpair, raisingValueErrorif no level is found.
Boundary extraction¶
package-linesMUST dissolve the input once, at the finest detected level only; every coarser boundary is already contained in that level's own adjacency, so no per-level repeat dissolve is needed.package-linesMUST derive each pair of touching units' shared boundary fromST_BoundaryandST_Intersection, never a PostGIS-style shared-paths function (not available in this DuckDB spatial build), and MUST merge the result withST_LineMergebefore dumping to atomic rows: an unmerged intersection returns one fragment per matching edge segment, not one line, even where both sides' vertices exactly coincide.- A shared-boundary row MUST be produced exactly once per touching pair
(
left_fid < right_fid), never twice. A pair whose polygons only touch at a point (corner touch) MUST produce zero shared rows. package-linesMUST dump every multi-part shared or exterior geometry into atomicLineStringrows; a unit with multiple disjoint exterior segments MUST produce one row per segment, never a singleMultiLineString.- Every output row MUST carry each side's own finest-level identity under
single-letter-prefixed generic columns,
a_*for one side andb_*for the other (e.g.a_pcode/b_pcode,a_name/b_name), one pair of columns per identity kind the finest level's own naming family detects (group_families_by_level()/level_family_names(), or an explicit schema's fixedcode/name), never a rawfid. Single-letter prefixes keep every generated field name within a Shapefile DBF field's 10-character limit. There is noboundary_typecolumn: a row is exterior exactly when everyb_*column isNULL, never shared. package-linesMUST classify every shared row by the coarsest detected level at which its two sides' code columns first differ, and every exterior row one level coarser than the coarsest detected level (min(levels) - 1), into a depth column (adm_lvlby default, overridable viadepth_column).package-linesMUST raiseValueErrorif any finest-level unit is absent from every output row (matched internally byfid, dropped from the output once thea_*/b_*columns resolve each side's identity).package-linesMUST raiseValueErrorifdepth_columncollides with one of its own fixed output column names (left_fid,right_fid,geom).
Outputs¶
package-linesperforms no topology hard gate; it is a derived cartographic layer, not a coverage layer.package-linesMUST combine shared and exterior rows from every level into one output file, deduplicated so no boundary segment repeats across levels.
Configuration (api.package_lines.package_lines() / CLI)¶
package-linesMUST process exactly one input file per call.- The output path MUST default to the input path with a
_linessuffix. package-linesMUST raiseFileExistsErrorif the output path already exists and overwriting wasn't requested.step, if given, MUST be one ofinputs,boundaries,outputs; any other value MUST raiseValueError.name_field/code_fieldMUST be given together, or both omitted; when both are omitted,package-linesMUST fall back to full structural auto-detection of every level.