<div dir="ltr">This appears to be a bug in the PostGIS usage of GEOS.  In GEOS, this case works correctly.  (E.g. in your first example, the narrow input polygon is preserved).  We're looking into this now.<div><br></div><div>The ST_CoverageClean documentation and your understanding are correct:</div><div>1. snappingDistance controls vertex snapping, with -1 applying an automatic distance, and 0.0 disabling snapping.<br>2. gapMaximumWidth closes gaps smaller than the specified tolerance.</div><div><br></div><div>Note that "gaps" are narrow closed areas which occur *between* the input polygons (after snapping, if any,  has taken place).  Narrow input polygons are never treated as gaps, but are preserved (as long as they are not snapped to the point of collapse).</div><div><br></div><div>Answers to your questions:</div><div><br></div><div>1. How do these two parameters interact?</div><div><br></div><div>Snapping is the first phase of the cleaning process.  It operates on the vertices and edges of the input.  It accomplishes two things: (a) increasing the robustness of the edge-noding process and (b) removing very narrow slivers and gores from the input.  Generally the snapping tolerance should be small relative to the precision of the input, to avoid unwanted distortion.  It's probably best to simply use the parameter default for most cases.</div><div><br></div><div>Gap merging is done in a subsequent phase, operating on the snapped polygons.  The gap maximum width value is dataset-dependent, but generally at least an order of magnitude larger than the snap tolerance.</div><div><br></div><div>A more detailed description of the process is here: <a href="https://lin-ear-th-inking.blogspot.com/2025/04/coverage-cleaning-in-jts.html">https://lin-ear-th-inking.blogspot.com/2025/04/coverage-cleaning-in-jts.html</a></div><div> <br>2. Best practices or recommended workflows for cleaning polygonal coverages with minimal geometry distortion.</div><div><br></div><div>Use the default snapping tolerance, or a very small one.</div><div><br>3. Any known edge cases or limitations when using ST_CoverageClean.</div><div><br></div><div>- Gaps are merged as-is, without splitting.  This can result in "spikes" being created by gaps which have multiple "arms".  There is work being done on splitting gaps to avoid this problem.</div><div>- Similarly, gaps which contain a wide portion (i.e. wider than the max gap width) and also one or more narrow "arms" will not be merged, due to the wide portion.  Handling these could be improved via a splitting approach, hopefully.</div><div><br>4. Whether gapMaximumWidth also triggers geometry simplification or sliver removal beyond gap closing.</div><div><br></div><div>gapMaximumWidth only determines which gaps are merged to adjacent polygons.  No other simplification is performed.</div><div><br></div><div>HTH - Martin</div><div><br></div><div><br></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Tue, Sep 23, 2025 at 6:00 AM Douglas Fan <<a href="mailto:douglas.mhfan@gmail.com">douglas.mhfan@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Dear PostGIS Developers and Users,<br><br>First of all, thank you for the development of the new ST_CoverageClean function in PostGIS 3.6.0. It’s a fantastic addition that has already helped a lot in my work with polygonal coverages. I really appreciate the effort that went into making this tool available.<br>While testing the function, I’ve encountered some behaviors that I’d like to better understand, particularly regarding the snappingDistance and gapMaximumWidth parameters.<div><br>From the documentation, I understand that:<br>1. snappingDistance controls vertex snapping, with -1 applying an automatic distance, and 0.0 disabling snapping.<br>2. gapMaximumWidth closes gaps smaller than the specified tolerance.<br><br>However, during testing with various combinations (e.g., snappingDistance set to -1, 0.0, 1, 2 and gapMaximumWidth set to 0, 1, 2), I noticed:<br>1. Even when snappingDistance is explicitly set to 0.0, small sliver vertices still appear to be snapped or altered when gapMaximumWidth is greater than 0.<br>2. Slivers that are thinner than the gapMaximumWidth are removed, even when they are not actual gaps or overlaps. <br><br>This behavior seems counterintuitive, as I expected no snapping to occur with snappingDistance = 0.0. Could this be due to internal gap cleaning logic that also affects vertex positions? Or is there an implicit snapping step tied to gapMaximumWidth?<br><br>I’d be grateful for any insights into:<br><br>1. How do these two parameters interact?<br>2. Best practices or recommended workflows for cleaning polygonal coverages with minimal geometry distortion.<br>3. Any known edge cases or limitations when using ST_CoverageClean.<br>4. Whether gapMaximumWidth also triggers geometry simplification or sliver removal beyond gap closing.<br><br>Thanks in advance for your help and for the continued development of PostGIS.<br><br>Best regards,<br>Man Ho Fan</div></div>
</blockquote></div>