Thanks Martin, that confirmation is really helpful. Should be a simple
fix now to amend the help text and avoid the confusion.
Op 11-6-2024 om 22:14 schreef Martin Davis:
Yes, your interpretation is correct. ST_ReducePrecision is only
guaranteed to work on VALID geometries. It will also work on *some*
invalid geometries (such as ones which are invalid due to
containing adjacent - but not overlapping - polygons). So the
safest thing is to use ST_MakeValid if there is doubt about whether
the inputs are valid.
On Tue, Jun 11, 2024 at 1:00 PM Marco Boeringa
<ma...@boeringa.demon.nl> wrote:
Hi,
Currently, the help page of PostGIS's ST_ReducePrecision command
more or less suggests that ST_ReducePrecision can be used as kind
of "drop-in" replacement of ST_MakeValid. The actual text reads:
/"Returns a valid geometry with all points rounded to the provided
grid tolerance, and features below the tolerance removed.
Unlike ST_SnapToGrid the returned geometry will be valid, with no
ring self-intersections or collapsed components./
/Precision reduction can be used to: /
*
/match coordinate precision to the data accuracy /
*
/reduce the number of coordinates needed to represent a geometry /
*
/ensure valid geometry output to formats which use lower
precision (e.g. text formats such as WKT, GeoJSON or KML when
the number of output decimal places is limited). /
*
/export valid geometry to systems which use lower or limited
precision (e.g. SDE, Oracle tolerance value)"/
However, a first test replacing:
ST_CollectionExtract(ST_MakeValid(<SOME OTHER GENERALIZATION CODE>),3)
with:
ST_ReducePrecision(<SOME OTHER GENERALIZATION CODE>),<GRID SIZE>)
failed on some geometries with a processing error.
Replacing the first try with:
ST_ReducePrecision(ST_CollectionExtract(ST_MakeValid(<SOME OTHER
GENERALIZATION CODE>),3),<GRID SIZE>)
did succeed.
This suggest to me that the help page should actually read
something like:
/"Returns a geometry with all points rounded to the provided grid
tolerance, and features below the tolerance removed.
Unlike ST_SnapToGrid the returned geometry is guaranteed to be
valid, with no ring self-intersections or collapsed components, if
the input geometry itself is valid. If the input geometry is
invalid, there is no guarantee the output will be valid. Use
ST_MakeValid to ensure the input is valid before running this
command if the input data may contain invalid geometries."/
Is my interpretation of how//ST_ReducePrecision handles validity
as reflected by this suggested updated help text correct?/
/
Marco/
/