edge-mosaic
See docs/reference/README.md for the MUST/SHOULD/MAY convention, and
docs/reference/shared.md/docs/reference/edge_match.md for rules edge-mosaic shares with other
tools.
Inputs¶
edge-mosaicMUST load the child layer and the parent/clip layer raw, unlikeedge-extend's own inputs stage: neither is coverage-checked or -cleaned before assign/clip. The child layer is expected to already be a finishededge_extend()output, butedge-mosaicdoes not verify this (seedocs/explanation/edge_mosaic.md).- Unlike every other tool here, the child role MAY span multiple files
(e.g. one
edge_extend()output per country), combined internally. The parent/clip layer MUST remain a single file. - The main output MUST NOT carry a
source_filecolumn; it is an internal working column only, used byassign-one's per-file grouping (seedocs/explanation/assign.md), not exported. The issues report MAY carrysource_file, shortened to its parent directory plus filename (e.g.sen/adm2.parquet), never the full input path (seedocs/adr/0087).
Assigning children to parents¶
edge-mosaicMUST assign every child from one input file to a single parent polygon, shared by the whole file: a file's children are one group (e.g. one country's admin2 units), not independently routed to whichever parent each one individually overlaps most.- The file's parent MUST be whichever parent the largest number of that file's children intersect (a majority vote by count of intersecting children, not summed overlap area), so a handful of border-overshooting children cannot misassign a file whose other children overwhelmingly point to their true parent.
- A tie between two candidate parents MUST be broken by the lower parent id.
- Once a file has a winning parent, every child in that file MUST be
assigned to it unconditionally, including a child with zero individual
overlap with the winner; such a child is not dropped at assign time (see
docs/explanation/assign.md). A whole file with no child overlapping any parent at all MUST be dropped, not treated as fatal, andedge-mosaicMUST log a warning naming its children, unlessmergeis set (see Configuration), in which case that file's own already-extended geometry is instead kept unclipped in the output. - A parent matched by zero children MUST be dropped, unless
mergeis set (see Configuration), in which case that parent's own geometry and attributes are kept unclipped in the output instead. Either case MUST also be recorded in the issues report described under Outputs.
Clipping¶
edge-mosaicMUST NOT re-run Voronoi extension on any child; the child layer is assumed already extended.edge-mosaicMUST clip each assigned child to its own assigned parent's geometry viaST_Intersection, one distinct assigned parent fid at a time, each in its own spawned OS subprocess (seedocs/explanation/edge_mosaic.md).- Within one parent fid's subprocess,
edge-mosaicMUST grid-subdivide that parent's boundary into small tiles before intersecting once its vertex count exceeds an adaptive threshold, sizing the tile grid from that parent's own vertex density, and MUST join children to tiles via bbox comparison, neverST_Intersects. - A child whose clipped result is empty MUST be dropped from the output,
not treated as fatal, and MUST be recorded in the issues report as a
kind='clip-empty'row (see Outputs). edge-mosaicMUST raise if zero children were ever assigned to any parent, unlessmergegap-filled at least one parent or kept at least one unmatched child file as passthrough (see Configuration).
Stitching¶
edge-mosaicMUST run one whole-layer coverage-clean pass over the clipped output, perdocs/reference/edge_stitch.md, using the same fixed gap-closing width asedge-extend's own merge stage (seedocs/reference/edge_extend.md), not a per-feature-scoped pass.
Outputs¶
edge-mosaic's final output MUST pass the hard gate indocs/reference/shared.md(no overlap, no gap at or belowSNAP_TOLERANCE) before export. A wider leftover gap does not block export (seedocs/adr/0035).edge-mosaicMUST export the final merged layer.edge-mosaicMUST also export an issues report alongside it, using the shared schema indocs/reference/shared.md, listing every child dropped for an empty clip intersection, every unassigned/passthrough child file, every gap-filled/passthrough parent (whenmergeis set), and every leftover gap wider thanSNAP_TOLERANCE, so a human can audit what didn't make it into the output or what may need review.- Without
merge, a whole unmatched child file MUST appear as anunassignedrow:unit_aMUST hold the child's own fid andsource_fileMUST record its origin file as a parent-directory-plus- filename (not the full path); parent id and reason fields MUST be null. Withmergeset, that file's children MUST instead appear aspassthroughrows (sameunit_a/source_fileshape,reasonnull), and MUST NOT also appear asunassigned. For aclip-emptyrow,unit_aMUST hold the child's fid,parent_fidMUST hold its assigned parent's fid,source_fileMUST record its origin file the same shortened way, andreasonMUST explain that the clip intersection came back empty. For agap-fillrow (mergeset only),parent_fidMUST hold the gap-filled parent's fid andreasonMUST explain that the parent had no matched children and was kept unclipped in the output;unit_aandsource_fileMUST be null, since the row is the parent itself, not a child. For agaprow,area_m2,max_width_m, andthinness_ratioMUST be populated instead. A field that doesn't apply to a row's kind MUST be null. edge-mosaicMUST produce the issues report only when it has at least one row; when it would be empty, no file MUST be written (and a stale file from a previous run at that path MUST be removed).
Configuration (api.edge_mosaic.mosaic() / CLI)¶
edge-mosaicMUST accept one or more child files and exactly one parent/clip file per call. The CLI additionally accepts--input(repeatable and comma-separable) alongside the glob-capableINPUT_FILEpositional, both usable together, matchingedge-clip's own--inputidiom.- With a single child file, the output path MUST default to that input
path with a
_mosaickedsuffix. With multiple child files,output_pathMUST be given explicitly. The issues-report path MUST default to the output path with an_issuessuffix. edge-mosaicMUST raiseFileExistsErrorif either output path already exists and overwriting wasn't requested.step, if given, MUST be one ofinputs,assign,edge-clip,edge-stitch,outputs; any other value MUST raiseValueError.stepMUST beNonewhenever more than oneinput_pathsfile is given; any other value MUST raiseValueError(seedocs/adr/0079).edge-mosaicMAY acceptmatch_column/parent_match_column/child_match_columnto override spatial assignment with an exact code join (seedocs/reference/shared.md,docs/explanation/assign.md).edge-mosaicMAY acceptmerge: bool = False(CLI:--merge, a plain boolean flag):False(default) copies no parent columns and drops both a zero-children parent and a whole unmatched child file;Truecopies every parent column (excludingfid/geom) onto every matched child, keeps a zero-children parent's own geometry unclipped in the output (kind='gap-fill'), and keeps a whole unmatched child file's own geometry unclipped in the output (kind='passthrough'). There is no way to enable one behavior without the other.- With
mergeset,edge-mosaicMAY additionally acceptparent_include/parent_exclude(CLI:--parent-include/--parent-exclude, each a comma-separated column list) to narrow which parent columns get copied onto matched children (default: every parent column exceptfid/geom), andchild_include/child_exclude(CLI:--child-include/--child-exclude) to narrow which of the child's own columns survive in the output (default: every child column;fid/geom/source_fileare always force-kept regardless). Each pair is mutually exclusive with itself; a parent-side flag MAY be combined with a child-side flag. All four MUST raiseValueErrorif given withoutmerge. - With
mergeset,edge-mosaicMAY additionally acceptprefer: "parent" | "child" | None = None(CLI:--prefer) to auto-resolve a real parent/child column-name collision:"parent"keeps the parent's column and drops the child's,"child"does the reverse. Omittingprefer(the default) preserves raisingValueErroron a real collision.preferMUST raiseValueErrorif given withoutmerge, or combined with any ofparent_include/parent_exclude/child_include/child_exclude(seedocs/reference/shared.md,docs/adr/0077,docs/adr/0079,docs/adr/0083,docs/adr/0088; supersedes the child-orphan passthrough ofdocs/adr/0078). edge-mosaicMAY opt into cascading admin-hierarchy columns viafill_schema/--fill-schema, right after stitching and before export (both the single-file step loop and the multi-file combine path).name_field/code_field/--name-field/--code-field(given together or both omitted; omitted falls back to structural auto-detection) anddepth_column/--depth-column(defaultadm_lvl) narrow it; all MUST raiseValueErrorif given withoutfill_schema=True.edge-mosaicMUST raiseValueErrorifdepth_columnalready names an existing column whenfill_schemais set.fill_schemais independent ofmerge: it fills a per-row schema-depth gap left by the input data itself, whilemerge's own gap-fill (fill_unmatched_parents(), seedocs/adr/0083) fills a per-parent geometry-coverage gap left by the mosaic; the two compose freely (seedocs/adr/0095).