edge-clip
Inputs¶
edge-clipMUST load the input layer and the overlay layer raw, neither coverage-checked nor -cleaned.edge-clipMUST NOT require or read anoverlay_fidcolumn on the input features layer.edge-clipMUST accept exactly one input file and exactly one overlay file per call, a strict 1:1 primitive (seedocs/adr/0080); batching many input files against one shared overlay load isedge-mosaic's job (seedocs/pages/3-edge/reference/edge_mosaic.md).- The output row MUST carry a
source_filecolumn recording the path of the input file it came from.
Assignment¶
edge-clipMUST internally assign every input feature to exactly one overlay feature before clipping, viaassign-one's file-wide majority-vote strategy (seedocs/pages/3-edge/explanation/assign.md): every input feature is forced onto the one overlay feature that wins a majority vote by count, unconditionally, not evaluated per input feature. An input feature with zero individual overlap with the winner is not dropped at this stage; it still gets clipped against the winner and MAY drop later if that clip result is empty (see Clipping).- A whole input file with no overlap against any overlay feature at all MUST be dropped, not clipped against the wrong overlay feature.
Clipping¶
edge-clipMUST clip each row to its ownoverlay_fid's geometry viaST_Intersection, one distinctoverlay_fidat a time, each in its own spawned OS subprocess.- Within one
overlay_fid's subprocess,edge-clipMUST grid-subdivide that overlay feature's boundary into small tiles before intersecting once its vertex count exceeds an adaptive threshold, sizing the tile grid from that overlay feature's own vertex density, and MUST join input features to tiles via bbox comparison, neverST_Intersects. - An input feature 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-clipMUST merge or keep every clip-detached piece in the clipped result, recording each one with an edge neighbour as akind='detached-part'row.edge-clipMUST merge or drop every micro-polygon in the clipped result, recording each as akind='micro-polygon'row.edge-clipMUST raise immediately on the firstoverlay_fidwhose subprocess fails, aborting the whole run rather than skipping just thatoverlay_fid.
Outputs¶
edge-clipMUST NOT run the coverage check on its own output: closing seams between clipped pieces isedge-stitch's job, notedge-clip's.edge-clipMUST raiseRuntimeErrorif the clipped result has zero rows.edge-clipMUST export the clipped layer to the output file.edge-clipMUST export an issues report alongside it, using the same columns as every other tool's issues report, whenever it has at least onekind='clip-empty',kind='detached-part'orkind='micro-polygon'row (or, when a code join is given, onecode-mismatch/code-fallbackrow); 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_clip.clip() / CLI)¶
- The output path MUST default to the input path with a
_clippedsuffix. The issues-report path MUST default to the output path with an_issuessuffix. edge-clipMUST raiseFileExistsErrorif either output path already exists and overwriting wasn't requested.step, if given, MUST be one ofinputs,assign,edge-clip,outputs; any other value MUST raiseValueError.edge-clipMAY acceptmatch_column/overlay_match_column/input_match_columnto override spatial assignment with an exact code join (seedocs/pages/3-edge/explanation/assign.md), addingcode-mismatch/code-fallbackrows to the issues report alongside anyclip-emptyrows.edge-clipMAY acceptcarry_columns(CLI:--carry-column) to copy named overlay columns onto every matched input feature (seedocs/adr/0077).edge-clipMAY acceptoriginal_path(CLI:--original, envORIGINAL_FILE), the input layer's pre-extension original, in any supported format or as a URL. Without it, no clip-detached piece merges.
Examples¶
Example 1: clip an input layer against an overlay layer, explicit output¶
topo-tools edge-clip input.parquet adm1.geojson clipped.parquet
Example 2: custom issues report path¶
topo-tools edge-clip input.parquet adm1.geojson clipped.parquet \
--issues-file clip_report.parquet