Reduce (geometry)

Reduce (geometry)#

Returns an approximation of the given geometry instance. The approximation is produced by running an extension of the Douglas-Peucker algorithm on the instance with the given tolerance.


.Reduce ( tolerance )



Is a value of type float. tolerance is the tolerance to input for the approximation algorithm.

Return type#



For collection types, this algorithm operates independently on each geometry contained in the instance.

This algorithm doesn’t modify Point instances.

On LineString, CircularString, and CompoundCurve instances, the approximation algorithm keeps the original start and end points of the instance. The algorithm next iteratively adds back the point from the original instance that most deviates from the result. This process continues until no point deviates more than the given tolerance.

Reduce() returns a LineString, CircularString, or CompoundCurve instance for CircularString instances. Reduce() returns either a CompoundCurve or LineString instance for CompoundCurve instances.

On Polygon instances, the approximation algorithm is applied independently to each ring. The method will produce a FormatException if the returned Polygon instance isn’t valid; for example, a non-valid MultiPolygon instance is created if Reduce() is applied to simplify each ring in the instance and the resulting rings overlap. On CurvePolygon instances with an exterior ring and no interior rings, Reduce() returns a CurvePolygon, LineString, or Point instance. If the CurvePolygon has interior rings then a CurvePolygon or MultiPoint instance is returned.

When a circular arc segment is found, the approximation algorithm checks whether the arc can be approximated by its chord within half the given tolerance. Chords meeting this criteria have the circular arc replaced in the calculations by the chord. If a chord doesn’t meet this criteria, then the circular arc is kept and the approximation algorithm is applied to the remaining segments.


Use Reduce() with varying tolerance levels on a CircularString

DECLARE @g geometry = 'CIRCULARSTRING(0 0, 8 8, 16 0, 20 -4, 24 0)';
 SELECT @g.Reduce(5).ToString();
 -- returns CIRCULARSTRING (0 0, 8 8, 16 0, 20 -4, 24 0)
 SELECT @g.Reduce(15).ToString();
 -- returns COMPOUNDCURVE (CIRCULARSTRING (0 0, 8 8, 16 0), (16 0, 24 0))
 SELECT @g.Reduce(16).ToString();
 -- returns LINESTRING (0 0, 24 0)

See Also#