<!-- Converted by db4-upgrade version 1.1 -->
<section xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" version="5.0" xml:id="Geometry_Processing">
    <title>Geometry Processing</title><info>
        <abstract>
        <para>These functions compute geometric constructions,
        or alter geometry size or shape.
        </para>
        </abstract>
    </info>



        <refentry xml:id="ST_Buffer">
            <refnamediv>
                <refname>ST_Buffer</refname>

                <refpurpose>
Computes a geometry covering all points within a given distance from a geometry.
            </refpurpose>
            </refnamediv>

            <refsynopsisdiv>
                <funcsynopsis>

                  <funcprototype>
                    <funcdef>geometry <function>ST_Buffer</function></funcdef>
                    <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
                    <paramdef><type>float </type> <parameter>radius_of_buffer</parameter></paramdef>
                    <paramdef choice="opt"><type>text </type> <parameter>buffer_style_parameters = ''</parameter></paramdef>
                  </funcprototype>

                  <funcprototype>
                    <funcdef>geometry <function>ST_Buffer</function></funcdef>
                    <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
                    <paramdef><type>float </type> <parameter>radius_of_buffer</parameter></paramdef>
                    <paramdef><type>integer </type> <parameter>num_seg_quarter_circle</parameter></paramdef>
                  </funcprototype>

                  <funcprototype>
                    <funcdef>geography <function>ST_Buffer</function></funcdef>
                    <paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
                    <paramdef><type>float </type> <parameter>radius_of_buffer</parameter></paramdef>
                    <paramdef choice="opt"><type>text </type> <parameter>buffer_style_parameters</parameter></paramdef>
                  </funcprototype>

                  <funcprototype>
                    <funcdef>geography <function>ST_Buffer</function></funcdef>
                    <paramdef><type>geography </type> <parameter>g1</parameter></paramdef>
                    <paramdef><type>float </type> <parameter>radius_of_buffer</parameter></paramdef>
                    <paramdef><type>integer </type> <parameter>num_seg_quarter_circle</parameter></paramdef>
                  </funcprototype>

                </funcsynopsis>
            </refsynopsisdiv>

              <refsection>
                <title>Description</title>

                <para>Computes a POLYGON or MULTIPOLYGON that represents all points whose distance
            from a geometry/geography is less than or equal to a given distance.
            A negative distance shrinks the geometry rather than expanding it.
            A negative distance may shrink a polygon completely, in which case POLYGON EMPTY is returned.
            For points and lines negative distances always return empty results.
            </para>
            <para>For geometry, the distance is specified in the units of the
            Spatial Reference System of the geometry.
            For geography, the distance is specified in meters.</para>

            <para>The optional third parameter controls the buffer accuracy and style.
The accuracy of circular arcs in the buffer is specified as the number of line segments
used to approximate a quarter circle (default is 8).
The buffer style can be specified by
providing a list of blank-separated key=value pairs as follows:
<itemizedlist>
<listitem>
<para>'quad_segs=#' : number of line segments used to approximate a quarter circle (default is 8).</para>
</listitem>
<listitem>
<para>'endcap=round|flat|square' : endcap style (defaults to "round"). 'butt' is accepted as a synonym for 'flat'.</para>
</listitem>
<listitem>
<para>'join=round|mitre|bevel' : join style (defaults to "round"). 'miter' is accepted as a synonym for 'mitre'.</para>
</listitem>
<listitem>
<para>'mitre_limit=#.#' : mitre ratio limit (only affects mitered join style). 'miter_limit' is accepted as a synonym for 'mitre_limit'.</para>
</listitem>
<listitem>
<para>'side=both|left|right' : defaults to 'both'. 'left' or 'right' performs a single-sided buffer on the geometry, with the buffered side relative to the direction of the line.
This is only applicable to LINESTRING geometry and does not affect POINT or POLYGON geometries. By default end caps are square when 'left' or 'right' are specified.</para>
</listitem>
</itemizedlist>
                </para>

            <note><para>&geography_transform;
            It determines a planar spatial reference system that best fits the bounding box of the geography object
            (trying UTM, Lambert Azimuthal Equal Area (LAEA) North/South pole, and finally Mercator ).
            The buffer is computed in the planar space, and then transformed back to WGS84.
            This may not produce the desired behavior if the input object is much larger than a UTM zone or crosses the dateline
            </para></note>

            <note><para>Buffer can handle invalid inputs and the output is always a valid polygonal geometry.
            Buffering by distance 0 is sometimes used as a way of repairing invalid polygons.
            <xref linkend="ST_MakeValid"/> is more suitable for this process as it can handle multi-polygons.
            </para></note>

            <note><para>Buffering is sometimes used to perform a within-distance search.
            For this use case it is more efficient to use <xref linkend="ST_DWithin"/>.</para></note>

            <note><para>This function ignores the Z dimension.
It always gives a 2D result even when used on a 3D geometry.</para></note>

                <para role="enhanced" conformance="2.5.0">Enhanced: 2.5.0 - ST_Buffer geometry support was enhanced to allow for side buffering specification <code>side=both|left|right</code>.</para>
                <para role="availability" conformance="1.5">Availability: 1.5 - ST_Buffer was enhanced to support different endcaps and join types. These are useful for example to convert road linestrings
                    into polygon roads with flat or square edges instead of rounded edges. Thin wrapper for geography was added.
                </para>

                <para>Performed by the GEOS module.</para>
                <para>&sfs_compliant; s2.1.1.3</para>
                <para>&sqlmm_compliant; SQL-MM IEC 13249-3: 5.1.30</para>
            </refsection>

              <refsection>
                <title>Examples</title>

                <para>The textual results are rounded to whole coordinate units for readability.
                Each result remains available as text, while the manual initially favors the
                shared input/output figure.</para>

                <informaltable xml:id="postgis-example-grid" role="postgis-example-grid">
                  <tgroup cols="2">
                    <tbody>
                      <row>
                        <entry>
                          <para><emphasis>quad_segs=8 (default)</emphasis></para>
<programlisting>SELECT ST_Buffer(
  ST_GeomFromText('POINT(100 90)'),
  50, 'quad_segs=8');</programlisting>
<screen xml:id="st-buffer-example-01" role="visual-primary text-primary">POLYGON((150 90,149 80,146 71,142 62,135 55,128 48,119 44,110 41,100 40,90 41,81 44,72 48,65 55,58 62,54 71,51 80,50 90,51 100,54 109,58 118,65 125,72 132,81 136,90 139,100 140,110 139,119 136,128 132,135 125,142 118,146 109,149 100,150 90))</screen>
                        </entry>
                        <entry>
                          <para><emphasis>quad_segs=2</emphasis></para>
<programlisting>SELECT ST_Buffer(
  ST_GeomFromText('POINT(100 90)'),
  50, 'quad_segs=2');</programlisting>
<screen xml:id="st-buffer-example-02" role="visual-primary text-primary">POLYGON((150 90,135 55,100 40,65 55,50 90,65 125,100 140,135 125,150 90))</screen>
                        </entry>
                      </row>
                      <row>
                        <entry>
                          <para><emphasis>endcap=round join=round (default)</emphasis></para>
<programlisting>SELECT ST_Buffer(
  ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'),
  10, 'endcap=round join=round');</programlisting>
<screen xml:id="st-buffer-example-03" role="visual-primary text-primary">POLYGON((143 157,144 158,146 159,148 160,150 160,152 160,154 159,156 158,157 157,158 156,159 154,160 152,160 150,160 50,160 48,159 46,158 44,157 43,156 42,154 41,152 40,150 40,148 40,146 41,144 42,143 43,142 44,141 46,140 48,140 50,140 126,57 43,56 42,54 41,52 40,50 40,48 40,46 41,44 42,43 43,42 44,41 46,40 48,40 50,40 52,41 54,42 56,43 57,143 157))</screen>
                        </entry>
                        <entry>
                          <para><emphasis>endcap=square</emphasis></para>
<programlisting>SELECT ST_Buffer(
  ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'),
  10, 'endcap=square join=round');</programlisting>
<screen xml:id="st-buffer-example-04" role="visual-primary text-primary">POLYGON((143 157,144 158,146 159,148 160,150 160,152 160,154 159,156 158,157 157,158 156,159 154,160 152,160 150,160 50,160 40,140 40,140 126,57 43,50 36,36 50,143 157))</screen>
                        </entry>
                      </row>
                      <row>
                        <entry>
                          <para><emphasis>endcap=flat</emphasis></para>
<programlisting>SELECT ST_Buffer(
  ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'),
  10, 'endcap=flat join=round');</programlisting>
<screen xml:id="st-buffer-example-05" role="visual-primary text-primary">POLYGON((143 157,144 158,146 159,148 160,150 160,152 160,154 159,156 158,157 157,158 156,159 154,160 152,160 150,160 50,140 50,140 126,57 43,43 57,143 157))</screen>
                        </entry>
                        <entry>
                          <para><emphasis>join=bevel</emphasis></para>
<programlisting>SELECT ST_Buffer(
  ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'),
  10, 'join=bevel');</programlisting>
<screen xml:id="st-buffer-example-06" role="visual-primary text-primary">POLYGON((143 157,160 150,160 50,160 48,159 46,158 44,157 43,156 42,154 41,152 40,150 40,148 40,146 41,144 42,143 43,142 44,141 46,140 48,140 50,140 126,57 43,56 42,54 41,52 40,50 40,48 40,46 41,44 42,43 43,42 44,41 46,40 48,40 50,40 52,41 54,42 56,43 57,143 157))</screen>
                        </entry>
                      </row>
                      <row>
                        <entry>
                          <para><emphasis>join=mitre mitre_limit=5.0 (default mitre limit)</emphasis></para>
<programlisting>SELECT ST_Buffer(
  ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'),
  10, 'join=mitre mitre_limit=5.0');</programlisting>
<screen xml:id="st-buffer-example-07" role="visual-primary text-primary">POLYGON((160 174,160 50,160 48,159 46,158 44,157 43,156 42,154 41,152 40,150 40,148 40,146 41,144 42,143 43,142 44,141 46,140 48,140 50,140 126,57 43,56 42,54 41,52 40,50 40,48 40,46 41,44 42,43 43,42 44,41 46,40 48,40 50,40 52,41 54,42 56,43 57,160 174))</screen>
                        </entry>
                        <entry>
                          <para><emphasis>join=mitre mitre_limit=1</emphasis></para>
<programlisting>SELECT ST_Buffer(
  ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'),
  10, 'join=mitre mitre_limit=1.0');</programlisting>
<screen xml:id="st-buffer-example-08" role="visual-primary text-primary">POLYGON((148 162,160 157,160 50,160 48,159 46,158 44,157 43,156 42,154 41,152 40,150 40,148 40,146 41,144 42,143 43,142 44,141 46,140 48,140 50,140 126,57 43,56 42,54 41,52 40,50 40,48 40,46 41,44 42,43 43,42 44,41 46,40 48,40 50,40 52,41 54,42 56,43 57,148 162))</screen>
                        </entry>
                      </row>
                      <row>
                        <entry>
                          <para><emphasis>side=left</emphasis></para>
<programlisting>SELECT ST_Buffer(
  ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'),
  10, 'side=left');</programlisting>
<screen xml:id="st-buffer-example-09" role="visual-primary text-primary">POLYGON((150 50,150 150,50 50,43 57,143 157,144 158,146 159,148 160,150 160,152 160,154 159,156 158,157 157,158 156,159 154,160 152,160 150,160 50,150 50))</screen>
                        </entry>
                        <entry>
                          <para><emphasis>side=right</emphasis></para>
<programlisting>SELECT ST_Buffer(
  ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'),
  10, 'side=right');</programlisting>
<screen xml:id="st-buffer-example-10" role="visual-primary text-primary">POLYGON((50 50,150 150,150 50,140 50,140 126,57 43,50 50))</screen>
                        </entry>
                      </row>
                      <row>
                        <entry>
                          <para><emphasis>side=left join=mitre</emphasis></para>
<programlisting>SELECT ST_Buffer(
  ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'),
  10, 'side=left join=mitre');</programlisting>
<screen xml:id="st-buffer-example-11" role="visual-primary text-primary">POLYGON((150 50,150 150,50 50,43 57,160 174,160 50,150 50))</screen>
                        </entry>
                        <entry>
                          <para><emphasis>right-hand winding, polygon boundary side=left</emphasis></para>
<programlisting role="documented-output">SELECT ST_Buffer(
  ST_ForceRHR(ST_Boundary(ST_GeomFromText(
    'POLYGON ((50 50,50 150,150 150,150 50,50 50))'))),
  20, 'side=left');</programlisting>
<screen xml:id="st-buffer-example-12" role="visual-primary text-primary">POLYGON((50 50,50 150,150 150,150 50,50 50))</screen>
                        </entry>
                      </row>
                      <row>
                        <entry>
                          <para><emphasis>right-hand winding, polygon boundary side=right</emphasis></para>
<programlisting role="documented-output">SELECT ST_Buffer(
  ST_ForceRHR(ST_Boundary(ST_GeomFromText(
    'POLYGON ((50 50,50 150,150 150,150 50,50 50))'))),
  20, 'side=right');</programlisting>
<screen xml:id="st-buffer-example-13" role="visual-primary text-primary">POLYGON((50 50,50 70,50 150,150 150,150 50,70 50,50 50),(70 70,130 70,130 130,70 130,70 70))</screen>
                        </entry>
                      </row>
                    </tbody>
                  </tgroup>
                </informaltable>

<para>A buffered point approximates a circle. A buffered point forcing approximation of (see diagram) 2 points per quarter circle is poly with 8 sides (see diagram)</para>
<programlisting>SELECT ST_NPoints(ST_Buffer('POINT(100 90)'::geometry, 50)) As promisingcircle_pcount,
ST_NPoints(ST_Buffer('POINT(100 90)'::geometry, 50, 2)) As lamecircle_pcount;
</programlisting>
<screen>
promisingcircle_pcount | lamecircle_pcount
------------------------+-------------------
             33 |                9
</screen>

<para>A lighter, less smooth circle using only 2 points per quarter circle is an octagon.</para>
<para>The following example creates a 100 meter octagon in NAD83 longitude/latitude by transforming to the Massachusetts state plane meter projection and then buffering. The figure shows the input and output in separate panels because the coordinates are in different SRIDs.</para>
<programlisting language="sql">WITH input AS (
  SELECT ST_SetSRID(ST_Point(-71.063526, 42.35785), 4269) AS point_4269
), projected AS (
  SELECT point_4269,
         ST_Transform(point_4269, 26986) AS point_26986
  FROM input
)
SELECT point_4269 AS input_point_4269,
       ST_Buffer(point_26986, 100, 2) AS octagon_26986
FROM projected;</programlisting>
<screen role="visual-primary text-primary visual-separate-output docbook-qa-ignore-wide-lines">SRID=4269;POINT(-71.063526 42.35785) | SRID=26986;POLYGON((236057.5905746494 900908.7599186979,236028.30125276805 900838.0492405792,235957.5905746494 900808.7599186979,235886.87989653074 900838.0492405792,235857.5905746494 900908.7599186979,235886.87989653074 900979.4705968165,235957.5905746494 901008.7599186979,236028.30125276805 900979.4705968165,236057.5905746494 900908.7599186979))</screen>

                <para>Buffering a polygon by a positive distance and then by the same negative
                distance is a morphological closing operation. It can be useful for smoothing
                noisy boundaries, such as simplifying a coastline by removing narrow inlets and
                bays. The result intentionally changes the shape and area of the input, and the
                distance must be chosen in the units of the input SRS. For data in a geographic
                SRS, transform to a projected SRS suited to the operation first; for cartographic
                visualization in Web Mercator, using that display SRS can be appropriate.</para>

<para>Smooth a coastline using a 1 km closing operation, then simplify the result. The example uses Massachusetts State Plane meter units for the operation.</para>
<programlisting language="sql">WITH projected AS (
  SELECT id, ST_Transform(geom, 26986) AS geom
  FROM coast
),
closed AS (
  SELECT id, ST_Buffer(ST_Buffer(geom, 1000), -1000) AS geom
  FROM projected
)
SELECT id, ST_Transform(ST_SimplifyPreserveTopology(geom, 50), 4326) AS geom
FROM closed;</programlisting>

	                <para>The same technique is described in Paul Ramsey's
	                <link xlink:href="https://blog.cleverelephant.ca/2010/11/removing-complexities.html">Removing Complexities</link>.
	                The final simplification step is optional; use
	                <xref linkend="ST_SimplifyPreserveTopology"/> when polygonal validity matters,
	                and check the result against the cartographic or analytical tolerance required by
	                the application.</para>

                <para>A small negative buffer can also be used as a heuristic to
                find narrow polygon spikes. The query below compares how much
                area and perimeter remain after erosion. A large
                <varname>erosion_index</varname> indicates that the perimeter
                dropped proportionally more than the area. This is only a
                preselection aid; the threshold and buffer distance must be
                chosen for the data units and the kind of spike being checked.</para>

<programlisting>WITH sample(id, geom) AS (
  VALUES
    ('plain', 'POLYGON((0 0,10 0,10 10,0 10,0 0))'::geometry),
    ('spike', 'POLYGON((0 0,10 0,10 10,5.2 10,5 16,4.8 10,0 10,0 0))'::geometry)
),
eroded AS (
  SELECT id, geom, ST_Buffer(geom, -0.5) AS eroded_geom
  FROM sample
),
scored AS (
  SELECT id,
         round((
           ST_Area(eroded_geom) / ST_Area(geom) /
           NULLIF(ST_Perimeter(eroded_geom) / ST_Perimeter(geom), 0)
         )::numeric, 3) AS erosion_index
  FROM eroded
  WHERE NOT ST_IsEmpty(eroded_geom)
)
SELECT id, erosion_index, erosion_index &gt; 1.1 AS possible_spike
FROM scored
ORDER BY id;</programlisting>
<screen>  id   | erosion_index | possible_spike
-------+---------------+----------------
 plain |         0.900 | f
 spike |         1.147 | t</screen>

	                <para>A variable-distance buffer can be approximated by buffering
	                each vertex of a line by a distance interpolated along the line, building
	                the convex hull for each consecutive pair of vertex buffers, and unioning
	                the segment hulls. As with any geometry buffer, distances are in the units
	                of the input SRS.</para>

		<para>Taper a line buffer from 5 to 25 units along the line.</para>
			<programlisting language="sql" role="documented-output">WITH line AS (
  SELECT 'LINESTRING(0 0, 100 0, 160 40)'::geometry AS geom
),
vertices AS (
  SELECT (dump).path[1] AS n,
         (dump).geom AS geom,
         line.geom AS line_geom
  FROM line
  CROSS JOIN LATERAL ST_DumpPoints(line.geom) AS dump
),
radii AS (
  SELECT n,
         geom,
         5 + (25 - 5) * ST_LineLocatePoint(line_geom, geom) AS radius
  FROM vertices
),
segments AS (
  SELECT n,
         geom,
         radius,
         lead(geom) OVER (ORDER BY n) AS next_geom,
         lead(radius) OVER (ORDER BY n) AS next_radius
  FROM radii
)
SELECT ST_Union(
         ST_ConvexHull(
           ST_Collect(
             ST_Buffer(geom, radius),
             ST_Buffer(next_geom, next_radius)
           )
         )
       ) AS tapered_buffer
FROM segments
WHERE next_geom IS NOT NULL;</programlisting>
<screen role="visual-primary">POLYGON((96.758 -16.301,-0.975 -4.904,-1.913 -4.619,-2.778 -4.157,-3.536 -3.536,-4.157 -2.778,-4.619 -1.913,-4.904 -0.975,-5 0,-4.904 0.975,-4.619 1.913,-4.157 2.778,-3.536 3.536,-2.778 4.157,-1.913 4.619,-0.975 4.904,93.101 15.875,142.322 57.678,146.111 60.787,150.433 63.097,155.123 64.52,160 65,164.877 64.52,169.567 63.097,173.889 60.787,177.678 57.678,180.787 53.889,183.097 49.567,184.52 44.877,185 40,184.52 35.123,183.097 30.433,180.787 26.111,177.678 22.322,173.889 19.213,169.567 16.903,106.36 -15.355,103.242 -16.301,100 -16.62,96.758 -16.301))</screen>
	              </refsection>

	              <refsection>
	                <title>See Also</title>

	                <para><xref linkend="ST_Collect"/>, <xref linkend="ST_ConvexHull"/>, <xref linkend="ST_DWithin"/>, <xref linkend="ST_DumpPoints"/>, <xref linkend="ST_LineLocatePoint"/>, <xref linkend="ST_SetSRID"/>, <xref linkend="ST_SimplifyPreserveTopology"/>, <xref linkend="ST_Transform"/>, <xref linkend="ST_Union"/>, <xref linkend="ST_MakeValid"/></para>
	              </refsection>
        </refentry>

        <refentry xml:id="ST_BuildArea">
          <refnamediv>
            <refname>ST_BuildArea</refname>

            <refpurpose>Creates a polygonal geometry formed by the linework of a geometry.</refpurpose>
          </refnamediv>

          <refsynopsisdiv>
            <funcsynopsis>
              <funcprototype>
                <funcdef>geometry <function>ST_BuildArea</function></funcdef>
                <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
              </funcprototype>
            </funcsynopsis>
          </refsynopsisdiv>

          <refsection>
            <title>Description</title>

            <para>Creates an areal geometry formed by the constituent linework
            of the input geometry.
            The input can be a LineString, MultiLineString, Polygon, MultiPolygon or a GeometryCollection.
            The result is a Polygon or MultiPolygon, depending on input.
            If the input linework does not form polygons, NULL is returned.
            </para>
            <para>Unlike <xref linkend="ST_MakePolygon"/>,
            this function accepts rings formed by multiple lines, and can form any number of polygons.
            </para>
            <para>This function converts inner rings into holes.
            To turn inner rings into polygons as well, use <xref linkend="ST_Polygonize"/>.
            </para>

            <note>
                <para>Input linework must be correctly noded for this function to work properly.
                <xref linkend="ST_Node"/> can be used to node lines.
                </para>
                <para>If the input linework crosses, this function will produce invalid polygons.
                <xref linkend="ST_MakeValid"/> can be used to ensure the output is valid.
                </para>
            </note>

            <para role="availability" conformance="1.1.0">Availability: 1.1.0</para>
          </refsection>

          <refsection>
            <title>Examples</title>

            <para>Building an area from five input lines.</para>

<programlisting>WITH data(geom) AS (VALUES
   ('LINESTRING (180 40,30 20,20 90)'::geometry),
  ('LINESTRING (180 40,160 160)'::geometry),
  ('LINESTRING (160 160,80 190,80 120,20 90)'::geometry),
  ('LINESTRING (80 60,120 130,150 80)'::geometry),
  ('LINESTRING (80 60,150 80)'::geometry)
)
SELECT ST_BuildArea(ST_Collect(geom )) AS wkt
    FROM data;</programlisting>
<screen role="visual-primary text-primary">POLYGON((180 40,30 20,20 90,80 120,80 190,160 160,180 40),(150 80,120 130,80 60,150 80))</screen>

<para>Create a donut from two circular polygons.</para>
<programlisting language="sql">WITH input AS (
  SELECT 'POINT(100 90)'::geometry AS geom
),
rings AS (
  SELECT ST_Buffer(geom, 25, 'quad_segs=1') AS inring,
         ST_Buffer(geom, 50, 'quad_segs=1') AS outring
  FROM input
)
SELECT inring AS inner_ring,
       outring AS outer_ring,
       ST_BuildArea(ST_Collect(inring, outring)) AS area
FROM rings;</programlisting>
<screen>-[ RECORD 1 ]-----
inner_ring | POLYGON((125 90,100 65,75 90,100 115,125 90))
outer_ring | POLYGON((150 90,100 40,50 90,100 140,150 90))
area       | POLYGON((150 90,100 40,50 90,100 140,150 90),(125 90,100 115,75 90,100 65,125 90))</screen>
<para>Input linework that crosses at non-endpoint intersections must be noded before building areas:</para>
<programlisting>WITH lines(geom) AS (VALUES
  ('LINESTRING(36 35,45 307)'::geometry),
  ('LINESTRING(30 290,390 280)'::geometry),
  ('LINESTRING(320 60,300 310)'::geometry),
  ('LINESTRING(20 60,320 60)'::geometry),
  ('LINESTRING(120 140,168 225)'::geometry),
  ('LINESTRING(140 220,220 150,120 170)'::geometry)
),
noded AS (
  SELECT ST_Node(ST_UnaryUnion(ST_Collect(geom))) AS geom FROM lines
)
SELECT ST_BuildArea(geom) AS area
FROM noded;
</programlisting>
<screen role="visual-primary text-primary">POLYGON((320 60,36.8 60,44.4 289.6,302.2 282.4,320 60),(156.9 205.3,135.2 167,220 150,156.9 205.3))</screen>

          </refsection>

          <refsection>
            <title>See Also</title>

            <para>
            <xref linkend="ST_Collect"/>,
            <xref linkend="ST_MakePolygon"/>,
            <xref linkend="ST_MakeValid"/>,
            <xref linkend="ST_Node"/>,
            <xref linkend="ST_Polygonize"/>,
            <xref linkend="ST_BdPolyFromText"/>,
            <xref linkend="ST_BdMPolyFromText"/> (wrappers to
            this function with standard OGC interface)</para>
          </refsection>
    </refentry>

  <refentry xml:id="ST_Centroid">
    <refnamediv>
      <refname>ST_Centroid</refname>

      <refpurpose>Returns the geometric center of a geometry.</refpurpose>
    </refnamediv>

    <refsynopsisdiv>
      <funcsynopsis>
          <funcprototype>
          <funcdef>geometry <function>ST_Centroid</function></funcdef>

          <paramdef><type>geometry </type>
          <parameter>g1</parameter></paramdef>
        </funcprototype>
            <funcprototype>
                <funcdef>geography <function>ST_Centroid</function></funcdef>

                <paramdef><type>geography </type>
                <parameter>g1</parameter></paramdef>
                <paramdef choice="opt"><type>boolean </type>
                <parameter>use_spheroid = true</parameter></paramdef>
    </funcprototype>

      </funcsynopsis>
    </refsynopsisdiv>

    <refsection>
      <title>Description</title>

      <para>Computes a point which is the geometric center of mass of a geometry.
      For [<varname>MULTI</varname>]<varname>POINT</varname>s,
      the centroid is the arithmetic mean of the input coordinates.
      For [<varname>MULTI</varname>]<varname>LINESTRING</varname>s,
      the centroid is computed using the weighted length of each line segment.
      For [<varname>MULTI</varname>]<varname>POLYGON</varname>s,
      the centroid is computed in terms of area.
      If an empty geometry is supplied, an empty <varname>GEOMETRYCOLLECTION</varname> is returned.
      If <varname>NULL</varname> is supplied, <varname>NULL</varname> is returned.
      If <varname>CIRCULARSTRING</varname> or <varname>COMPOUNDCURVE</varname>
      are supplied, they are converted to linestring with CurveToLine first,
      then same than for  <varname>LINESTRING</varname>
      </para>
      <para>For mixed-dimension input, the result is equal to the centroid of the component
      Geometries of highest dimension (since the lower-dimension geometries
      contribute zero "weight" to the centroid).</para>
      <para>Note that for polygonal geometries the centroid does not necessarily
      lie in the interior of the polygon.  For example, see the diagram below
      of the centroid of a C-shaped polygon.
      To construct a point guaranteed to lie in the interior
      of a polygon use <xref linkend="ST_PointOnSurface"/>.
      </para>

      <para>New in 2.3.0 : supports <varname>CIRCULARSTRING</varname> and <varname>COMPOUNDCURVE</varname> (using CurveToLine)</para>

      <para role="availability" conformance="2.4.0">Availability: 2.4.0 support for geography was introduced.</para>

      <para>&sfs_compliant;</para>
      <para>&sqlmm_compliant; SQL-MM 3: 8.1.4, 9.5.5</para>
    </refsection>

    <refsection>
      <title>Examples</title>

		<para>Centroid of a MultiPoint.</para>
<programlisting>SELECT ST_Centroid(
  'MULTIPOINT (8 24,10 92,12 154,17 68,28 10,29 52,29 84,55 50,56 24,131 14,160 180,189 180)');</programlisting>
<screen xml:id="st-centroid-multipoint" role="visual-primary text-primary">POINT(60.333 77.667)</screen>

		<para>Centroid of a LineString.</para>
<programlisting>SELECT ST_Centroid(
  'LINESTRING (190 160,10 190,40 90,20 70,10 10,30 40,30 10,110 40,70 10,110 10,140 40,140 10,160 30,180 10)');</programlisting>
<screen role="visual-primary text-primary">POINT(76.191 79.876)</screen>

		<para>Centroid of a Polygon.</para>
<programlisting>SELECT ST_Centroid(
  'POLYGON ((190 190,10 190,10 10,190 10,190 20,160 30,60 30,60 130,190 140,190 190))');</programlisting>
<screen role="visual-primary text-primary">POINT(80.251 113.405)</screen>

		<para>Centroid of the highest-dimension components of a GeometryCollection.</para>
<programlisting>SELECT ST_Centroid(
  'GEOMETRYCOLLECTION (POLYGON ((190 170,180 100,80 140,80 160,130 160,110 180,110 190,180 180,190 170)),
    LINESTRING (80 120,120 20,140 70,150 30,180 50,190 10),
    MULTIPOINT (19 150,22 49,30 13,32 101,45 35,67 88,75 16))');</programlisting>
<screen role="visual-primary text-primary">POINT(143.361 148.263)</screen>

      <programlisting>SELECT ST_Centroid(g)
FROM  ST_GeomFromText('CIRCULARSTRING(0 2,-1 1,0 0,0.5 0,1 0,2 1,1 2,0.5 2,0 2)')  AS g ;</programlisting>
<screen>  st_astext
-------------
 POINT(0.5 1)
(1 row)</screen>

      <programlisting>SELECT ST_Centroid(g)
FROM  ST_GeomFromText('COMPOUNDCURVE(CIRCULARSTRING(0 2,-1 1,0 0),(0 0,0.5 0,1 0), CIRCULARSTRING( 1 0,2 1,1 2),(1 2,0.5 2,0 2))' ) AS g;</programlisting>
<screen>  st_astext
-------------
 POINT(0.5 1)
(1 row)</screen>

	<para>Centroids of the parts of a MultiPolygon.</para>
<programlisting language="sql">SELECT ST_Collect(ST_Centroid(geom) ORDER BY path)
FROM ST_Dump('MULTIPOLYGON (
    ((0 0,0 1,1 1,1 0,0 0)),
    ((2 2,2 3,3 3,3 2,2 2))
  )'::geometry);
</programlisting>
<screen role="visual-primary text-primary">MULTIPOINT((0.5 0.5),(2.5 2.5))</screen>
    </refsection>

    <refsection>
      <title>See Also</title>

      <para><xref linkend="ST_Collect"/>, <xref linkend="ST_Dump"/>, <xref linkend="ST_PointOnSurface"/>, <xref linkend="ST_GeometricMedian"/></para>
    </refsection>
  </refentry>

    <refentry xml:id="ST_ChaikinSmoothing">
      <refnamediv>
        <refname>ST_ChaikinSmoothing</refname>
        <refpurpose>Returns a smoothed version of a geometry, using the Chaikin algorithm</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_ChaikinSmoothing</function></funcdef>
            <paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
            <paramdef choice="opt"><type>integer</type> <parameter>nIterations = 1</parameter></paramdef>
            <paramdef choice="opt"><type>boolean</type> <parameter>preserveEndPoints = false</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>
        <para>Smoothes a linear or polygonal geometry using
        <link xlink:href="http://www.idav.ucdavis.edu/education/CAGDNotes/Chaikins-Algorithm/Chaikins-Algorithm.html">Chaikin's algorithm</link>.
        The degree of smoothing is controlled by the <varname>nIterations</varname> parameter.
        On each iteration, each interior vertex is replaced
        by two vertices located at 1/4 of the length of the line segments before and after the vertex.
        A reasonable degree of smoothing is provided by 3 iterations; the maximum is limited to 5.
        </para>

        <para>If <varname>preserveEndPoints</varname> is true, the endpoints of Polygon rings are not smoothed.
        The endpoints of LineStrings are always preserved.
        </para>

        <note><para>The number of vertices doubles with each iteration,
            so the result geometry may have many more points than the input.
            To reduce the number of points use a simplification function on the result
            (see <xref linkend="ST_Simplify"/>, <xref linkend="ST_SimplifyPreserveTopology"/>
            and <xref linkend="ST_SimplifyVW"/>).
        </para></note>


        <para>The result has interpolated values for the Z and M dimensions when present.</para>

        <para>&Z_support;</para>
        <para role="availability" conformance="2.5.0">Availability: 2.5.0</para>
      </refsection>

          <refsection>
            <title>Examples</title>
    <para>Smoothing a Polygon using 1, 2 and 3 iterations.</para>
    <programlisting language="sql">SELECT n AS iterations, ST_ChaikinSmoothing(
    'POLYGON ((20 20,60 90,10 150,100 190,190 160,130 120,190 50,140 70,120 10,90 60,20 20))', n
  ) AS smoothed
FROM generate_series(1, 3) AS n;</programlisting>
    <screen role="visual-primary visual-overlay text-primary">1 | POLYGON((30 37.5,50 72.5,47.5 105,22.5 135,32.5 160,77.5 180,122.5 182.5,167.5 167.5,175 150,145 130,145 102.5,175 67.5,177.5 55,152.5 65,135 55,125 25,112.5 22.5,97.5 47.5,72.5 50,37.5 30,30 37.5))
2 | POLYGON((35 46.25,45 63.75,49.375 80.625,48.125 96.875,41.25 112.5,28.75 127.5,25 141.25,30 153.75,43.75 165,66.25 175,88.75 180.625,111.25 181.875,133.75 178.75,156.25 171.25,169.375 163.125,173.125 154.375,167.5 145,152.5 135,145 123.125,145 109.375,152.5 93.75,167.5 76.25,175.625 64.375,176.875 58.125,171.25 57.5,158.75 62.5,148.125 62.5,139.375 57.5,132.5 47.5,127.5 32.5,121.875 24.375,115.625 23.125,108.75 28.75,101.25 41.25,91.25 48.125,78.75 49.375,63.75 45,46.25 35,35.625 31.875,31.875 35.625,35 46.25))
3 | POLYGON((37.5 50.625,42.5 59.375,46.09375 67.96875,48.28125 76.40625,49.0625 84.6875,48.4375 92.8125,46.40625 100.78125,42.96875 108.59375,38.125 116.25,31.875 123.75,27.8125 130.9375,25.9375 137.8125,26.25 144.375,28.75 150.625,33.4375 156.5625,40.3125 162.1875,49.375 167.5,60.625 172.5,71.875 176.40625,83.125 179.21875,94.375 180.9375,105.625 181.5625,116.875 181.09375,128.125 179.53125,139.375 176.875,150.625 173.125,159.53125 169.21875,166.09375 165.15625,170.3125 160.9375,172.1875 156.5625,171.71875 152.03125,168.90625 147.34375,163.75 142.5,156.25 137.5,150.625 132.03125,146.875 126.09375,145 119.6875,145 112.8125,146.875 105.46875,150.625 97.65625,156.25 89.375,163.75 80.625,169.53125 73.28125,173.59375 67.34375,175.9375 62.8125,176.5625 59.6875,175.46875 57.96875,172.65625 57.65625,168.125 58.75,161.875 61.25,156.09375 62.5,150.78125 62.5,145.9375 61.25,141.5625 58.75,137.65625 55,134.21875 50,131.25 43.75,128.75 36.25,126.09375 30.46875,123.28125 26.40625,120.3125 24.0625,117.1875 23.4375,113.90625 24.53125,110.46875 27.34375,106.875 31.875,103.125 38.125,98.75 42.96875,93.75 46.40625,88.125 48.4375,81.875 49.0625,75 48.28125,67.5 46.09375,59.375 42.5,50.625 37.5,43.59375 34.21875,38.28125 32.65625,34.6875 32.8125,32.8125 34.6875,32.65625 38.28125,34.21875 43.59375,37.5 50.625))</screen>

    <para>Smoothing a LineString using 1, 2 and 3 iterations.</para>
    <programlisting language="sql">SELECT n AS iterations, ST_ChaikinSmoothing(
    'LINESTRING (10 140,80 130,100 190,190 150,140 20,120 120,50 30,30 100)', n
  ) AS smoothed
FROM generate_series(1, 3) AS n;</programlisting>
    <screen role="visual-primary visual-overlay text-primary">1 | LINESTRING(10 140,62.5 132.5,85 145,95 175,122.5 180,167.5 160,177.5 117.5,152.5 52.5,135 45,125 95,102.5 97.5,67.5 52.5,45 47.5,30 100)
2 | LINESTRING(10 140,49.375 134.375,68.125 135.625,79.375 141.875,87.5 152.5,92.5 167.5,101.875 176.25,115.625 178.75,133.75 175,156.25 165,170 149.375,175 128.125,171.25 101.25,158.75 68.75,148.125 50.625,139.375 46.875,132.5 57.5,127.5 82.5,119.375 95.625,108.125 96.875,93.75 86.25,76.25 63.75,61.875 51.25,50.625 48.75,41.25 60.625,30 100)
3 | LINESTRING(10 140,39.53125 135.78125,54.0625 134.6875,63.4375 135.3125,70.9375 137.1875,76.5625 140.3125,81.40625 144.53125,85.46875 149.84375,88.75 156.25,91.25 163.75,94.84375 169.6875,99.53125 174.0625,105.3125 176.875,112.1875 178.125,120.15625 177.8125,129.21875 175.9375,139.375 172.5,150.625 167.5,159.6875 161.09375,166.5625 153.28125,171.25 144.0625,173.75 133.4375,174.0625 121.40625,172.1875 107.96875,168.125 93.125,161.875 76.875,156.09375 64.21875,150.78125 55.15625,145.9375 49.6875,141.5625 47.8125,137.65625 49.53125,134.21875 54.84375,131.25 63.75,128.75 76.25,125.46875 85.78125,121.40625 92.34375,116.5625 95.9375,110.9375 96.5625,104.53125 94.21875,97.34375 88.90625,89.375 80.625,80.625 69.375,72.65625 60.625,65.46875 54.375,59.0625 50.625,53.4375 49.375,48.28125 51.71875,43.59375 57.65625,38.4375 70.46875,30 100)</screen>

            <para>Smoothing a triangle shows the weakest visual change, so it is kept last.</para>
                <programlisting language="sql">
SELECT ST_ChaikinSmoothing(geom) smoothed
FROM (SELECT  'POLYGON((0 0,8 8,0 16,0 0))'::geometry geom) AS foo;</programlisting>
<screen role="visual-primary text-primary">POLYGON((2 2,6 6,6 10,2 14,0 12,0 4,2 2))</screen>

          </refsection>
          <refsection>
            <title>See Also</title>
            <para><xref linkend="ST_Simplify"/>, <xref linkend="ST_SimplifyPreserveTopology"/>, <xref linkend="ST_SimplifyVW"/></para>
          </refsection>
    </refentry>


    <refentry xml:id="ST_CatmullRomSmoothing">
      <refnamediv>
        <refname>ST_CatmullRomSmoothing</refname>
        <refpurpose>Returns a smoothed version of a geometry, using the Catmull-Rom spline algorithm</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_CatmullRomSmoothing</function></funcdef>
            <paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
            <paramdef choice="opt"><type>integer</type> <parameter>nSegments = 5</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>
        <para>Smoothes a linear or polygonal geometry using the
        <link xlink:href="https://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline">Catmull-Rom spline</link>
        algorithm. Unlike <xref linkend="ST_ChaikinSmoothing"/>, this is an <emphasis>interpolating</emphasis>
        spline: the output curve passes through every original vertex. Between each pair of
        consecutive original vertices, <varname>nSegments</varname> - 1 new intermediate
        points are inserted.
        </para>

        <para>The <varname>nSegments</varname> parameter controls the density of the output.
        With <varname>nSegments</varname> = 5 (the default), each original span is
        divided into 5 sub-segments (inserting 4 new points per span). The minimum value is 2.
        </para>

        <para>At least 4 input vertices are required to apply smoothing;
        geometries with fewer vertices are returned unchanged.
        Points and multipoints are always returned unchanged.
        </para>

        <note><para>The output vertex count grows as
        <literal>1 + (N-1) * nSegments</literal> for open lines,
        and <literal>1 + N * nSegments</literal> for closed rings,
        where N is the number of input vertices.
        For large geometries, use a simplification function on the result
        to reduce the number of points
        (see <xref linkend="ST_Simplify"/>, <xref linkend="ST_SimplifyPreserveTopology"/>
        and <xref linkend="ST_SimplifyVW"/>).
        </para></note>

        <para>The result has interpolated values for the Z and M dimensions when present.</para>

        <para>&Z_support;</para>
        <para role="availability" conformance="3.6.0">Availability: 3.6.0</para>
      </refsection>

      <refsection>
        <title>Examples</title>
    <para>Smoothing a LineString using nSegments = 5 and 10.</para>
    <programlisting language="sql">WITH input(geom) AS (VALUES
  ('LINESTRING (10 140,80 130,100 190,190 150,140 20,120 120,50 30,30 100)'::geometry)
)
SELECT ST_CatmullRomSmoothing(geom, 5) AS segments_5,
  ST_CatmullRomSmoothing(geom, 10) AS segments_10
FROM input;</programlisting>
    <screen role="visual-primary visual-overlay">LINESTRING(10 140,24.8 136.88,40.4 132.64,55.6 128.96,69.2 127.52,80 130,86.08 139.12,88.24 153.76,89.36 169.84,92.32 183.28,100 190,115.76 189.84,137.68 185.52,160.72 177.28,179.84 165.36,190 150,188.48 126.08,178.64 93.44,164.56 59.76,150.32 32.72,140 20,134.88 28.32,132.24 52.56,130.16 82.64,126.72 108.48,120 120,108.4 111.6,93.2 90,76.8 63.6,61.6 40.8,50 30,42.8 33.76,38.4 46.48,35.6 64.32,33.2 83.44,30 100) | LINESTRING(10 140,17.225 138.685,24.8 136.88,32.575 134.795,40.4 132.64,48.125 130.625,55.6 128.96,62.675 127.855,69.2 127.52,75.025 128.165,80 130,83.71 133.615,86.08 139.12,87.47 146.005,88.24 153.76,88.75 161.875,89.36 169.84,90.43 177.145,92.32 183.28,95.39 187.735,100 190,106.795 190.455,115.76 189.84,126.265 188.185,137.68 185.52,149.375 181.875,160.72 177.28,171.085 171.765,179.84 165.36,186.355 158.095,190 150,190.535 139.61,188.48 126.08,184.345 110.37,178.64 93.44,171.875 76.25,164.56 59.76,157.205 44.93,150.32 32.72,144.415 24.09,140 20,137.01 21.54,134.88 28.32,133.37 39.08,132.24 52.56,131.25 67.5,130.16 82.64,128.73 96.72,126.72 108.48,123.89 116.66,120 120,114.8 117.975,108.4 111.6,101.1 101.925,93.2 90,85 76.875,76.8 63.6,68.9 51.225,61.6 40.8,55.2 33.375,50 30,45.975 30.52,42.8 33.76,40.325 39.24,38.4 46.48,36.875 55,35.6 64.32,34.425 73.96,33.2 83.44,31.775 92.28,30 100)</screen>

        <para>Smoothing a 4-point collinear line with default nSegments=5 shows the minimal change case.</para>
        <programlisting language="sql">SELECT ST_CatmullRomSmoothing('LINESTRING(0 0,5 0,10 0,15 0)');</programlisting>
<screen role="visual-primary text-primary">LINESTRING(0 0,1 0,2 0,3 0,4 0,5 0,6 0,7 0,8 0,9 0,10 0,11 0,12 0,13 0,14 0,15 0)</screen>
    <para>Smoothing a Polygon using nSegments = 5 and 10. This larger example is kept last.</para>
    <programlisting language="sql">WITH input(geom) AS (VALUES
  ('POLYGON ((20 20,60 90,10 150,100 190,190 160,130 120,190 50,140 70,120 10,90 60,20 20))'::geometry)
)
SELECT ST_CatmullRomSmoothing(geom, 5) AS segments_5,
  ST_CatmullRomSmoothing(geom, 10) AS segments_10
FROM input;</programlisting>
    <screen role="visual-primary visual-overlay">POLYGON((20 20,22.4 27.12,32.4 40.56,45.2 57.44,56 74.88,60 90,53.52 102.96,39.76 115.68,24.24 127.92,12.48 139.44,10 150,19.04 160.4,35.92 170.8,57.28 180,79.76 186.8,100 190,120.4 188.64,143.2 183.52,164.8 176.08,181.6 167.76,190 160,185.68 153.12,171.04 146.16,152.56 138.64,136.72 130.08,130 120,136.08 106.48,150.64 89.84,168.16 72.96,183.12 58.72,190 50,186.56 49.52,176.48 55.36,163.12 63.44,149.84 69.68,140 70,134.24 61.36,130.32 46.48,127.28 29.92,124.16 16.24,120 10,115.28 14.4,110.64 26.4,105.36 41.2,98.72 54,90 60,76.8 56,59.6 45.2,42 32.4,27.6 22.4,20 20)) | POLYGON((20 20,19.95 22.59,22.4 27.12,26.75 33.23,32.4 40.56,38.75 48.75,45.2 57.44,51.15 66.27,56 74.88,59.15 82.91,60 90,58.015 96.495,53.52 102.96,47.205 109.365,39.76 115.68,31.875 121.875,24.24 127.92,17.545 133.785,12.48 139.44,9.735 144.855,10 150,13.33 155.125,19.04 160.4,26.71 165.675,35.92 170.8,46.25 175.625,57.28 180,68.59 183.775,79.76 186.8,90.37 188.925,100 190,109.675 189.88,120.4 188.64,131.725 186.46,143.2 183.52,154.375 180,164.8 176.08,174.025 171.94,181.6 167.76,187.075 163.72,190 160,189.535 156.54,185.68 153.12,179.245 149.68,171.04 146.16,161.875 142.5,152.56 138.64,143.905 134.52,136.72 130.08,131.815 125.26,130 120,131.635 113.81,136.08 106.48,142.645 98.37,150.64 89.84,159.375 81.25,168.16 72.96,176.305 65.33,183.12 58.72,187.915 53.49,190 50,189.32 48.715,186.56 49.52,182.14 51.905,176.48 55.36,170 59.375,163.12 63.44,156.26 67.045,149.84 69.68,144.28 70.835,140 70,136.83 66.745,134.24 61.36,132.11 54.415,130.32 46.48,128.75 38.125,127.28 29.92,125.79 22.435,124.16 16.24,122.27 11.905,120 10,117.585 10.95,115.28 14.4,112.995 19.75,110.64 26.4,108.125 33.75,105.36 41.2,102.255 48.15,98.72 54,94.665 58.15,90 60,84.125 59.15,76.8 56,68.475 51.15,59.6 45.2,50.625 38.75,42 32.4,34.175 26.75,27.6 22.4,22.725 19.95,20 20))</screen>

      </refsection>

      <refsection>
        <title>See Also</title>
        <para><xref linkend="ST_ChaikinSmoothing"/>, <xref linkend="ST_Simplify"/>,
        <xref linkend="ST_SimplifyPreserveTopology"/>, <xref linkend="ST_SimplifyVW"/></para>
      </refsection>
    </refentry>


    <refentry xml:id="ST_ConcaveHull">
      <refnamediv>
        <refname>ST_ConcaveHull</refname>
        <refpurpose>Computes a possibly concave geometry that contains all input geometry vertices</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
         <funcprototype>
            <funcdef>geometry <function>ST_ConcaveHull</function></funcdef>
            <paramdef><type>geometry </type> <parameter>param_geom</parameter></paramdef>
            <paramdef><type>float </type> <parameter>param_pctconvex</parameter></paramdef>
            <paramdef choice="opt"><type>boolean </type> <parameter>param_allow_holes = false</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>

        <para>A concave hull is a (usually) concave geometry which contains the input,
        and whose vertices are a subset of the input vertices.
        In the general case the concave hull is a Polygon.
        The concave hull of two or more collinear points is a two-point LineString.
        The concave hull of one or more identical points is a Point.
        The polygon will not contain holes unless the optional <varname>param_allow_holes</varname>
        argument is specified as true.
        </para>

        <para>One can think of a concave hull as "shrink-wrapping" a set of points.
        This is different to the <link linkend="ST_ConvexHull">convex hull</link>,
        which is more like wrapping a rubber band around the points.
        A concave hull generally has a smaller area
        and represents a more natural boundary for the input points.
        </para>

        <para>The <varname>param_pctconvex</varname> controls the concaveness of the computed hull.
        A value of 1 produces the convex hull.
        Values between 1 and 0 produce hulls of increasing concaveness.
        A value of 0 produces a hull with maximum concaveness (but still a single polygon).
        Choosing a suitable value depends on the nature of the input data,
        but often values between 0.3 and 0.1 produce reasonable results.
        </para>

        <note><para>
        Technically, the <varname>param_pctconvex</varname> determines a length as a fraction of the difference between
        the longest and shortest edges in the Delaunay Triangulation of the input points.
        Edges longer than this length are "eroded" from the triangulation.
        The triangles remaining form the concave hull.
        </para></note>

        <para>For point and linear inputs, the hull will enclose all the points of the inputs.
        For polygonal inputs, the hull will enclose all the points of the input <emphasis>and also</emphasis> all the areas covered by the input.
        If you want a point-wise hull of a polygonal input, convert it to points first using <xref linkend="ST_Points"/>.</para>

       <para>This is not an aggregate function.
        To compute the concave hull of a set of geometries use <xref linkend="ST_Collect"/>
        (e.g. <code>ST_ConcaveHull(ST_Collect(geom ), 0.80)</code>.</para>

        <para role="availability" conformance="2.0.0">Availability: 2.0.0</para>
        <para role="enhanced" conformance="3.3.0">Enhanced: 3.3.0, GEOS native implementation enabled for GEOS 3.11+</para>
      </refsection>

      <refsection>
        <title>Examples</title>

<para>Concave hull of a MultiPoint.</para>
    <programlisting language="sql" role="documented-output">SELECT ST_ConcaveHull('MULTIPOINT ((10 72),(53 76),(56 66),(63 58),(71 51),(81 48),(91 46),(101 45),(111 46),(121 47),(131 50),(140 55),(145 64),(144 74),(135 80),(125 83),(115 85),(105 87),(95 89),(85 91),(75 93),(65 95),(55 98),(45 102),(37 107),(29 114),(22 122),(19 132),(18 142),(21 151),(27 160),(35 167),(44 172),(54 175),(64 178),(74 180),(84 181),(94 181),(104 181),(114 181),(124 181),(134 179),(144 177),(153 173),(162 168),(171 162),(177 154),(182 145),(184 135),(139 132),(136 142),(128 149),(119 153),(109 155),(99 155),(89 155),(79 153),(69 150),(61 144),(63 134),(72 128),(82 125),(92 123),(102 121),(112 119),(122 118),(132 116),(142 113),(151 110),(161 106),(170 102),(178 96),(185 88),(189 78),(190 68),(189 58),(185 49),(179 41),(171 34),(162 29),(153 25),(143 23),(133 21),(123 19),(113 19),(102 19),(92 19),(82 19),(72 21),(62 22),(52 25),(43 29),(33 34),(25 41),(19 49),(14 58),(21 73),(31 74),(42 74),(173 134),(161 134),(150 133),(97 104),(52 117),(157 156),(94 171),(112 106),(169 73),(58 165),(149 40),(70 33),(147 157),(48 153),(140 96),(47 129),(173 55),(144 86),(159 67),(150 146),(38 136),(111 170),(124 94),(26 59),(60 41),(71 162),(41 64),(88 110),(122 34),(151 97),(157 56),(39 146),(88 33),(159 45),(47 56),(138 40),(129 165),(33 48),(106 31),(169 147),(37 122),(71 109),(163 89),(37 156),(82 170),(180 72),(29 142),(46 41),(59 155),(124 106),(157 80),(175 82),(56 50),(62 116),(113 95),(144 167))',
         0.1 );</programlisting>
<screen> st_astext
-----------
POLYGON ((18 142, 21 151, 27 160, 35 167, 44 172, 54 175, 64 178, 74 180, 84 181, 94 181, 104 181, 114 181, 124 181, 134 179, 144 177, 153 173, 162 168, 171 162, 177 154, 182 145, 184 135, 173 134, 161 134, 150 133, 139 132, 136 142, 128 149, 119 153, 109 155, 99 155, 89 155, 79 153, 69 150, 61 144, 63 134, 72 128, 82 125, 92 123, 102 121, 112 119, 122 118, 132 116, 142 113, 151 110, 161 106, 170 102, 178 96, 185 88, 189 78, 190 68, 189 58, 185 49, 179 41, 171 34, 162 29, 153 25, 143 23, 133 21, 123 19, 113 19, 102 19, 92 19, 82 19, 72 21, 62 22, 52 25, 43 29, 33 34, 25 41, 19 49, 14 58, 10 72, 21 73, 31 74, 42 74, 53 76, 56 66, 63 58, 71 51, 81 48, 91 46, 101 45, 111 46, 121 47, 131 50, 140 55, 145 64, 144 74, 135 80, 125 83, 115 85, 105 87, 95 89, 85 91, 75 93, 65 95, 55 98, 45 102, 37 107, 29 114, 22 122, 19 132, 18 142))
(1 row)</screen>

<para>Concave hull of a MultiPoint, allowing holes.</para>
    <programlisting language="sql" role="documented-output">SELECT ST_ConcaveHull('MULTIPOINT ((132 64),(114 64),(99 64),(81 64),(63 64),(57 49),(52 36),(46 20),(37 20),(26 20),(32 36),(39 55),(43 69),(50 84),(57 100),(63 118),(68 133),(74 149),(81 164),(88 180),(101 180),(112 180),(119 164),(126 149),(132 131),(139 113),(143 100),(150 84),(157 69),(163 51),(168 36),(174 20),(163 20),(150 20),(143 36),(139 49),(132 64),(99 151),(92 138),(88 124),(81 109),(74 93),(70 82),(83 82),(99 82),(112 82),(126 82),(121 96),(114 109),(110 122),(103 138),(99 151),(34 27),(43 31),(48 44),(46 58),(52 73),(63 73),(61 84),(72 71),(90 69),(101 76),(123 71),(141 62),(166 27),(150 33),(159 36),(146 44),(154 53),(152 62),(146 73),(134 76),(143 82),(141 91),(130 98),(126 104),(132 113),(128 127),(117 122),(112 133),(119 144),(108 147),(119 153),(110 171),(103 164),(92 171),(86 160),(88 142),(79 140),(72 124),(83 131),(79 118),(68 113),(63 102),(68 93),(35 45))',
         0.15, true );</programlisting>
<screen> st_astext
-----------
POLYGON ((43 69, 50 84, 57 100, 63 118, 68 133, 74 149, 81 164, 88 180, 101 180, 112 180, 119 164, 126 149, 132 131, 139 113, 143 100, 150 84, 157 69, 163 51, 168 36, 174 20, 163 20, 150 20, 143 36, 139 49, 132 64, 114 64, 99 64, 81 64, 63 64, 57 49, 52 36, 46 20, 37 20, 26 20, 32 36, 35 45, 39 55, 43 69), (88 124, 81 109, 74 93, 83 82, 99 82, 112 82, 121 96, 114 109, 110 122, 103 138, 92 138, 88 124))
(1 row)</screen>

<para>Comparing a concave hull of a Polygon to the concave hull of the constituent points.
The hull respects the boundary of the polygon, whereas the points-based hull does not.
</para>

<programlisting language="sql" role="documented-output">
WITH data(geom) AS (VALUES
   ('POLYGON ((10 90,39 85,61 79,50 90,80 80,95 55,25 60,90 45,70 16,63 38,60 10,50 30,43 27,30 10,20 20,10 90))'::geometry)
)
SELECT ST_ConcaveHull(geom, 0.1) AS polygon_hull,
       ST_ConcaveHull(ST_Points(geom), 0.1) AS points_hull
    FROM data;
</programlisting>
<screen role="visual-primary text-primary">POLYGON((60 10,50 30,43 27,30 10,20 20,10 90,39 85,50 90,80 80,95 55,90 45,70 16,60 10)) | POLYGON((25 60,10 90,39 85,50 90,80 80,95 55,90 45,70 16,60 10,30 10,20 20,43 27,50 30,63 38,61 79,25 60))</screen>

<para>Using with ST_Collect to compute the concave hull of a geometry set.</para>

<para>This example estimates an infected area from point observations.</para>
<programlisting>
SELECT disease_type,
    ST_ConcaveHull(ST_Collect(obs_pnt), 0.3 ) AS geom
  FROM disease_obs
  GROUP BY disease_type;
</programlisting>
      </refsection>

      <refsection>
        <title>See Also</title>
        <para><xref linkend="ST_ConvexHull"/>, <xref linkend="ST_Collect"/>, <xref linkend="CG_AlphaShape"/>, <xref linkend="CG_OptimalAlphaShape"/></para>
      </refsection>
    </refentry>

    <refentry xml:id="ST_ConvexHull">
      <refnamediv>
        <refname>ST_ConvexHull</refname>
        <refpurpose>Computes the convex hull of a geometry.</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_ConvexHull</function></funcdef>
            <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>
            <para>Computes the convex hull of a geometry.
        The convex hull is the smallest convex
        geometry that encloses all geometries in the input.</para>

        <para>One can think of the convex hull as the geometry obtained by wrapping an rubber
            band around a set of geometries.  This is different from a
            <link linkend="ST_ConcaveHull">concave hull</link>
            which is analogous to "shrink-wrapping" the geometries.
            A convex hull is often used to
            determine an affected area based on a set of point observations.</para>

        <para>In the general case the convex hull is a Polygon.
        The convex hull of two or more collinear points is a two-point LineString.
        The convex hull of one or more identical points is a Point.</para>

        <para>This is not an aggregate function.
        To compute the convex hull of a set of geometries, use <xref linkend="ST_Collect"/>
        to aggregate them into a geometry collection
        (e.g. <code>ST_ConvexHull(ST_Collect(geom))</code>.</para>

        <para>Performed by the GEOS module</para>

        <para>&sfs_compliant; s2.1.1.3</para>
        <para>&sqlmm_compliant; SQL-MM IEC 13249-3: 5.1.16</para>
        <para>&Z_support;</para>
      </refsection>

      <refsection>
        <title>Examples</title>

<para>Compute the convex hull of a MultiLineString and a MultiPoint.</para>
    <programlisting>SELECT ST_ConvexHull(ST_Collect(ST_GeomFromText('MULTILINESTRING((100 190,10 8),(150 10,20 30))'),
            ST_GeomFromText('MULTIPOINT(50 5,150 30,50 10,10 10)')
            ));</programlisting>
<screen> st_astext
-----------
POLYGON((50 5,10 8,10 10,100 190,150 30,150 10,50 5))
(1 row)</screen>

<para>Using with ST_Collect to compute the convex hulls of geometry sets.</para>

<para>This example returns an estimated infected area from point observations.</para>
<programlisting>
SELECT d.disease_type,
    ST_ConvexHull(ST_Collect(d.geom)) As geom
    FROM disease_obs As d
    GROUP BY d.disease_type;
</programlisting>

      </refsection>
      <refsection>
        <title>See Also</title>
        <para><xref linkend="ST_Collect"/>, <xref linkend="ST_ConcaveHull"/>, <xref linkend="ST_MinimumBoundingCircle"/></para>
      </refsection>
    </refentry>

    <refentry xml:id="ST_DelaunayTriangles">
        <refnamediv>
            <refname>ST_DelaunayTriangles</refname>

            <refpurpose>
Returns the Delaunay triangulation of the vertices of a geometry.
            </refpurpose>
        </refnamediv>

        <refsynopsisdiv>
            <funcsynopsis>
              <funcprototype>
                <funcdef>geometry <function>ST_DelaunayTriangles</function></funcdef>
                <paramdef><type>geometry </type> <parameter>g1</parameter></paramdef>
                <paramdef choice="opt"><type>float </type> <parameter>tolerance = 0.0</parameter></paramdef>
                <paramdef choice="opt"><type>int4 </type> <parameter>flags = 0</parameter></paramdef>
              </funcprototype>
            </funcsynopsis>
        </refsynopsisdiv>

          <refsection>
            <title>Description</title>

            <para>
Computes the <link xlink:href="http://en.wikipedia.org/wiki/Delaunay_triangulation">Delaunay triangulation</link>
of the vertices of the input geometry.
The optional <varname>tolerance</varname> can be used to snap nearby input vertices together,
which improves robustness in some situations.
The result geometry is bounded by the convex hull of the input vertices.
The result geometry representation is determined by the <varname>flags</varname> code:
</para>
        <itemizedlist>
            <listitem><para> <code>0</code> - a GEOMETRYCOLLECTION of triangular POLYGONs (default) </para></listitem>
            <listitem><para> <code>1</code> - a MULTILINESTRING of the edges of the triangulation </para></listitem>
            <listitem><para> <code>2</code> - A TIN of the triangulation </para></listitem>
        </itemizedlist>

            <para>Performed by the GEOS module.</para>
            <para role="availability" conformance="2.1.0">Availability: 2.1.0</para>
            <para>&Z_support;</para>
            <para>&T_support;</para>

        </refsection>
              <refsection>
        <title>Examples</title>
        <para>Triangulation of the vertices of a polygon and a buffered point.</para>
        <programlisting language="sql">WITH data AS (
  SELECT polygon, ST_Buffer(center, 20) AS point_buffer
  FROM (SELECT
    'POLYGON((175 150,20 40,50 60,125 100,175 150))'::geometry AS polygon,
    'POINT(110 170)'::geometry AS center
  ) AS input
)
SELECT ST_DelaunayTriangles(ST_Union(polygon, point_buffer)) AS triangles
FROM data;</programlisting>
        <screen role="visual-primary geometry-output-precision-0">GEOMETRYCOLLECTION(POLYGON((96 184,93 181,96 156,96 184)), POLYGON((96 184,96 156,102 188,96 184)), POLYGON((96 184,102 188,99 187,96 184)), POLYGON((102 188,96 156,99 153,102 188)), POLYGON((102 188,99 153,102 152,102 188)), POLYGON((102 188,102 152,106 190,102 188)), POLYGON((106 190,102 152,106 150,106 190)), POLYGON((106 190,106 150,110 190,106 190)), POLYGON((110 190,106 150,110 150,110 190)), POLYGON((110 190,110 150,118 188,110 190)), POLYGON((110 190,118 188,114 190,110 190)), POLYGON((118 188,110 150,121 153,118 188)), POLYGON((118 188,121 153,121 187,118 188)), POLYGON((121 187,121 153,124 156,121 187)), POLYGON((121 187,124 156,124 184,121 187)), POLYGON((121 187,124 184,175 150,121 187)), POLYGON((175 150,124 184,127 181,175 150)), POLYGON((175 150,127 181,128 178,175 150)), POLYGON((175 150,128 178,130 174,175 150)), POLYGON((175 150,130 174,130 170,175 150)), POLYGON((175 150,130 170,130 166,175 150)), POLYGON((175 150,130 166,128 162,175 150)), POLYGON((175 150,128 162,127 159,175 150)), POLYGON((175 150,127 159,124 156,175 150)), POLYGON((175 150,124 156,125 100,175 150)), POLYGON((125 100,124 156,121 153,125 100)), POLYGON((125 100,121 153,118 152,125 100)), POLYGON((125 100,118 152,114 150,125 100)), POLYGON((125 100,114 150,110 150,125 100)), POLYGON((125 100,110 150,106 150,125 100)), POLYGON((125 100,106 150,102 152,125 100)), POLYGON((125 100,102 152,99 153,125 100)), POLYGON((125 100,99 153,50 60,125 100)), POLYGON((125 100,50 60,20 40,125 100)), POLYGON((20 40,50 60,90 166,20 40)), POLYGON((20 40,90 166,90 170,20 40)), POLYGON((20 40,90 170,90 174,20 40)), POLYGON((20 40,90 174,92 178,20 40)), POLYGON((92 178,90 174,90 170,92 178)), POLYGON((92 178,90 170,92 162,92 178)), POLYGON((92 178,92 162,93 159,92 178)), POLYGON((92 178,93 159,93 181,92 178)), POLYGON((93 181,93 159,96 156,93 181)), POLYGON((96 156,93 159,50 60,96 156)), POLYGON((96 156,50 60,99 153,96 156)), POLYGON((50 60,93 159,92 162,50 60)), POLYGON((50 60,92 162,90 166,50 60)), POLYGON((90 166,92 162,90 170,90 166)), POLYGON((110 150,114 150,121 153,110 150)), POLYGON((121 153,114 150,118 152,121 153)), POLYGON((124 156,127 159,130 166,124 156)), POLYGON((124 156,130 166,128 178,124 156)), POLYGON((124 156,128 178,124 184,124 156)), POLYGON((124 184,128 178,127 181,124 184)), POLYGON((128 178,130 166,130 170,128 178)), POLYGON((128 178,130 170,130 174,128 178)), POLYGON((130 166,127 159,128 162,130 166)))</screen>

        <para>Triangulation edges returned as a <varname>MULTILINESTRING</varname>.</para>
        <programlisting language="sql">WITH data AS (
  SELECT polygon, ST_Buffer(center, 20) AS point_buffer
  FROM (SELECT
    'POLYGON((175 150,20 40,50 60,125 100,175 150))'::geometry AS polygon,
    'POINT(110 170)'::geometry AS center
  ) AS input
)
SELECT ST_DelaunayTriangles(ST_Union(polygon, point_buffer), 0.001, 1) AS triangulation_edges
FROM data;</programlisting>
        <screen role="visual-primary geometry-output-precision-0">MULTILINESTRING((121 187,175 150),(118 188,121 187),(114 190,118 188),(110 190,114 190),(106 190,110 190),(102 188,106 190),(99 187,102 188),(96 184,99 187),(93 181,96 184),(92 178,93 181),(20 40,92 178),(20 40,125 100),(125 100,175 150),(124 156,125 100),(124 156,175 150),(124 156,127 159),(127 159,175 150),(127 159,128 162),(128 162,175 150),(128 162,130 166),(130 166,175 150),(130 166,130 170),(130 170,175 150),(130 174,130 170),(130 174,175 150),(128 178,130 174),(128 178,175 150),(127 181,128 178),(127 181,175 150),(124 184,127 181),(124 184,175 150),(121 187,124 184),(124 156,124 184),(121 187,124 156),(121 153,124 156),(121 153,121 187),(118 188,121 153),(110 150,121 153),(110 150,118 188),(110 150,110 190),(110 190,118 188),(106 150,110 150),(106 150,110 190),(106 190,106 150),(102 152,106 150),(102 152,106 190),(102 152,102 188),(99 153,102 152),(99 153,102 188),(96 156,99 153),(96 156,102 188),(96 156,96 184),(96 184,102 188),(93 181,96 156),(93 159,96 156),(93 159,93 181),(92 178,93 159),(92 162,93 159),(92 162,92 178),(90 170,92 162),(90 170,92 178),(90 170,90 174),(90 174,92 178),(20 40,90 174),(20 40,90 170),(90 170,90 166),(20 40,90 166),(50 60,90 166),(20 40,50 60),(50 60,125 100),(50 60,99 153),(99 153,125 100),(50 60,96 156),(50 60,93 159),(50 60,92 162),(90 166,92 162),(102 152,125 100),(106 150,125 100),(110 150,125 100),(110 150,114 150),(114 150,125 100),(114 150,118 152),(118 152,125 100),(118 152,121 153),(121 153,125 100),(114 150,121 153),(124 184,128 178),(124 156,128 178),(128 178,130 166),(124 156,130 166),(127 159,130 166),(128 178,130 170))</screen>

        <para>Triangulation of 42 points forming an L shape.</para>
        <programlisting language="sql">WITH data AS (
  SELECT 'MULTIPOINT(14 14,34 14,54 14,74 14,94 14,114 14,134 14,
    150 14,154 14,154 6,134 6,114 6,94 6,74 6,54 6,34 6,
    14 6,10 6,8 6,7 7,6 8,6 10,6 30,6 50,6 70,6 90,6 110,6 130,
    6 150,6 170,6 190,6 194,14 194,14 174,14 154,14 134,14 114,
    14 94,14 74,14 54,14 34,14 14)'::geometry AS l_shape_points
)
SELECT ST_DelaunayTriangles(l_shape_points) AS triangles
FROM data;</programlisting>
        <screen role="visual-primary geometry-output-precision-0">GEOMETRYCOLLECTION(POLYGON((6 194,6 190,14 194,6 194)), POLYGON((14 194,6 190,14 174,14 194)), POLYGON((14 194,14 174,154 14,14 194)), POLYGON((154 14,14 174,14 154,154 14)), POLYGON((154 14,14 154,150 14,154 14)), POLYGON((154 14,150 14,154 6,154 14)), POLYGON((154 6,150 14,134 6,154 6)), POLYGON((134 6,150 14,134 14,134 6)), POLYGON((134 6,134 14,114 14,134 6)), POLYGON((134 6,114 14,114 6,134 6)), POLYGON((114 6,114 14,94 14,114 6)), POLYGON((114 6,94 14,94 6,114 6)), POLYGON((94 6,94 14,74 14,94 6)), POLYGON((94 6,74 14,74 6,94 6)), POLYGON((74 6,74 14,54 14,74 6)), POLYGON((74 6,54 14,54 6,74 6)), POLYGON((54 6,54 14,34 14,54 6)), POLYGON((54 6,34 14,34 6,54 6)), POLYGON((34 6,34 14,14 14,34 6)), POLYGON((34 6,14 14,14 6,34 6)), POLYGON((14 6,14 14,10 6,14 6)), POLYGON((10 6,14 14,6 10,10 6)), POLYGON((10 6,6 10,7 7,10 6)), POLYGON((10 6,7 7,8 6,10 6)), POLYGON((7 7,6 10,6 8,7 7)), POLYGON((6 10,14 14,6 30,6 10)), POLYGON((6 30,14 14,14 34,6 30)), POLYGON((6 30,14 34,6 50,6 30)), POLYGON((6 50,14 34,14 54,6 50)), POLYGON((6 50,14 54,6 70,6 50)), POLYGON((6 70,14 54,14 74,6 70)), POLYGON((6 70,14 74,6 90,6 70)), POLYGON((6 90,14 74,14 94,6 90)), POLYGON((6 90,14 94,6 110,6 90)), POLYGON((6 110,14 94,14 114,6 110)), POLYGON((6 110,14 114,6 130,6 110)), POLYGON((6 130,14 114,14 134,6 130)), POLYGON((6 130,14 134,6 150,6 130)), POLYGON((6 150,14 134,14 154,6 150)), POLYGON((6 150,14 154,6 170,6 150)), POLYGON((6 170,14 154,14 174,6 170)), POLYGON((6 170,14 174,6 190,6 170)), POLYGON((14 154,14 134,150 14,14 154)), POLYGON((150 14,14 134,134 14,150 14)), POLYGON((134 14,14 134,114 14,134 14)), POLYGON((114 14,14 134,14 114,114 14)), POLYGON((114 14,14 114,94 14,114 14)), POLYGON((94 14,14 114,14 94,94 14)), POLYGON((94 14,14 94,74 14,94 14)), POLYGON((74 14,14 94,14 74,74 14)), POLYGON((74 14,14 74,54 14,74 14)), POLYGON((54 14,14 74,14 54,54 14)), POLYGON((54 14,14 54,34 14,54 14)), POLYGON((34 14,14 54,14 34,34 14)), POLYGON((34 14,14 34,14 14,34 14)))</screen>

        <para>Example using vertices with Z values.</para>
        <programlisting language="sql" role="visual-skip">SELECT ST_DelaunayTriangles(
  'MULTIPOINT Z(14 14 10,150 14 100,34 6 25,20 10 150)'::geometry);</programlisting>
        <screen role="visual-primary">GEOMETRYCOLLECTION Z (POLYGON Z ((14 14 10,20 10 150,34 6 25,14 14 10)),POLYGON Z ((14 14 10,34 6 25,150 14 100,14 14 10)))</screen>
        </refsection>

      <refsection>
        <title>See Also</title>
        <para><xref linkend="ST_VoronoiPolygons"/>,
            <xref linkend="ST_TriangulatePolygon"/>,
            <xref linkend="CG_ConstrainedDelaunayTriangles"/>,
            <xref linkend="ST_VoronoiLines"/>,
            <xref linkend="ST_ConvexHull"/>
        </para>
      </refsection>
    </refentry>

    <refentry xml:id="ST_FilterByM">
      <refnamediv>
        <refname>ST_FilterByM</refname>
        <refpurpose>Removes vertices based on their M value</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_FilterByM</function></funcdef>
            <paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
            <paramdef><type>double precision</type> <parameter>min</parameter></paramdef>
            <paramdef><type>double precision</type> <parameter>max = null</parameter></paramdef>
            <paramdef><type>boolean</type> <parameter>returnM = false</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>
        <para>Filters out vertex points based on their M-value. Returns a geometry with only
            vertex points that have a M-value larger or equal to the min value and smaller or equal to
            the max value. If max-value argument is left out only min value is considered. If fourth argument is left out the m-value
            will not be in the resulting geometry. If resulting geometry have too few vertex points left for its geometry type an empty
            geometry will be returned. In a geometry collection
            geometries without enough points will just be left out silently.</para>
        <para>This function is mainly intended to be used in conjunction with ST_SetEffectiveArea. ST_EffectiveArea sets the effective area
            of a vertex in its m-value. With ST_FilterByM it then is possible to get a simplified version of the geometry without any calculations, just by filtering</para>

        <note><para>There is a difference in what ST_SimplifyVW returns when not enough points meet the criteria compared to ST_FilterByM.
                ST_SimplifyVW returns the geometry with enough points while ST_FilterByM returns an empty geometry</para></note>
        <note><para>Note that the returned geometry might be invalid</para></note>
        <note><para>This function returns all dimensions, including the Z and M values</para></note>
        <para role="availability" conformance="2.5.0">Availability: 2.5.0</para>
      </refsection>

          <refsection>
            <title>Examples</title>
            <para>A linestring is filtered</para>
                <programlisting>
SELECT ST_FilterByM(geom, 30) simplified
FROM (SELECT  ST_SetEffectiveArea('LINESTRING(5 2,3 8,6 20,7 25,10 10)'::geometry) geom) As foo;</programlisting>
<screen role="visual-primary text-primary">LINESTRING(5 2,7 25,10 10)</screen>
          </refsection>
          <refsection>
            <title>See Also</title>
            <para><xref linkend="ST_SetEffectiveArea"/>, <xref linkend="ST_SimplifyVW"/></para>
          </refsection>
    </refentry>

    <refentry xml:id="ST_GeneratePoints">
      <refnamediv>
        <refname>ST_GeneratePoints</refname>

        <refpurpose>Generates a multipoint of random points contained in a Polygon or MultiPolygon.</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_GeneratePoints</function></funcdef>
            <paramdef><type>geometry</type> <parameter>g</parameter></paramdef>
            <paramdef><type>integer</type> <parameter>npoints</parameter></paramdef>
            <paramdef choice="opt"><type>integer</type> <parameter>seed = 0</parameter></paramdef>
          </funcprototype>

        </funcsynopsis>
        </refsynopsisdiv>

        <refsection>
        <title>Description</title>

        <para>
            ST_GeneratePoints generates a multipoint consisting of a given number of pseudo-random points
            which lie within the input area.
            The optional <varname>seed</varname> is used to regenerate a deterministic sequence of points,
            and must be greater than zero.
        </para>

        <para role="availability" conformance="2.3.0">Availability: 2.3.0</para>
        <para role="enhanced" conformance="3.0.0">Enhanced: 3.0.0, added seed parameter</para>
        </refsection>

        <refsection>
            <title>Examples</title>

<para>Generate 12 points inside a buffered LineString using the deterministic seed 1996.</para>
<programlisting>WITH source AS (
  SELECT ST_Buffer(ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'),
           10, 'endcap=round join=round') AS geom
)
SELECT geom AS area,
       ST_GeneratePoints(geom, 12, 1996) AS points
FROM source;</programlisting>
<screen role="visual-primary">POLYGON((142.929 157.071,144.444 158.315,146.173 159.239,148.049 159.808,150 160,151.951 159.808,153.827 159.239,155.556 158.315,157.071 157.071,158.315 155.556,159.239 153.827,159.808 151.951,160 150,160 50,159.808 48.049,159.239 46.173,158.315 44.444,157.071 42.929,155.556 41.685,153.827 40.761,151.951 40.192,150 40,148.049 40.192,146.173 40.761,144.444 41.685,142.929 42.929,141.685 44.444,140.761 46.173,140.192 48.049,140 50,140 125.858,57.071 42.929,55.556 41.685,53.827 40.761,51.951 40.192,50 40,48.049 40.192,46.173 40.761,44.444 41.685,42.929 42.929,41.685 44.444,40.761 46.173,40.192 48.049,40 50,40.192 51.951,40.761 53.827,41.685 55.556,42.929 57.071,142.929 157.071)) | MULTIPOINT((97.546 111.15),(155.206 69.56),(101.94 114.818),(90.308 91.125),(151.257 106.401),(143.12 120.461),(152.952 146.697),(119.774 123.985),(148.672 40.92),(54.376 45.337),(150.667 88.153),(129.634 120.578))</screen>
<para>Given a table of polygons s, return 12 individual points per polygon. Results will be different each time you run.</para>
<programlisting>SELECT s.id, dp.path[1] AS pt_id, dp.geom
FROM s, ST_DumpPoints(ST_GeneratePoints(s.geom, 12)) AS dp;</programlisting>
<para>Generate dot-density points from a polygon table, using the absolute value of an attribute
as the number of points and keeping the sign of the attribute for styling.</para>
<programlisting>SELECT z.id,
       CASE WHEN z.count_delta &lt; 0 THEN -1 ELSE 1 END AS sign,
       dp.path[1] AS pt_id,
       dp.geom
FROM zones AS z
CROSS JOIN LATERAL ST_DumpPoints(
    ST_GeneratePoints(z.geom, abs(z.count_delta)::integer, z.id + 1)
) AS dp
WHERE z.count_delta &lt;&gt; 0;</programlisting>
	        </refsection>
        <refsection>
          <title>See Also</title>
          <para><xref linkend="ST_DumpPoints"/></para>
        </refsection>
    </refentry>

    <refentry xml:id="ST_GeometricMedian">
      <refnamediv>
          <refname>ST_GeometricMedian</refname>

        <refpurpose>
            Returns the geometric median of a MultiPoint.
        </refpurpose>
      </refnamediv>

    <refsynopsisdiv>
      <funcsynopsis>
        <funcprototype>
            <funcdef>geometry <function>ST_GeometricMedian</function> </funcdef>

            <paramdef> <type>geometry</type> <parameter>geom</parameter></paramdef>
            <paramdef choice="opt"><type>float8</type> <parameter>tolerance = NULL</parameter></paramdef>
            <paramdef choice="opt"><type>int</type> <parameter>max_iter = 10000</parameter></paramdef>
            <paramdef choice="opt"><type>boolean</type> <parameter>fail_if_not_converged = false</parameter></paramdef>

        </funcprototype>
      </funcsynopsis>
    </refsynopsisdiv>

    <refsection>
      <title>Description</title>

    <para>
          Computes the approximate geometric median of a MultiPoint geometry
          using the Weiszfeld algorithm.
          The geometric median is the point minimizing the sum of distances to the input points.
          It provides a centrality measure
          that is less sensitive to outlier points than the centroid (center of mass).
    </para>
    <para>
          The algorithm iterates until the distance change between
          successive iterations is less than the supplied <varname>tolerance</varname>
          parameter.  If this condition has not been met after <varname>max_iterations</varname>
          iterations, the function produces an error and exits,
          unless <varname>fail_if_not_converged</varname> is set to <code>false</code> (the default).
    </para>
    <para>
          If a <varname>tolerance</varname> argument is not provided, the tolerance value
          is calculated based on the extent of the input geometry.
    </para>
    <para>
          If present, the input point M values are interpreted as their relative weights.
    </para>
    <para role="availability" conformance="2.3.0">Availability: 2.3.0</para>
    <para role="enhanced" conformance="2.5.0">Enhanced: 2.5.0 Added support for M as weight of points.</para>
    <para>&Z_support;</para>
    <para>&M_support;</para>
    </refsection>
    <refsection>
      <title>Examples</title>
		<para>Compare the geometric median and centroid of a MultiPoint.</para>
      <programlisting>
WITH test AS (
SELECT 'MULTIPOINT((10 10),(10 40),(40 10),(190 190))'::geometry geom)
SELECT
  ST_Centroid(geom) centroid,
  ST_GeometricMedian(geom) median
FROM test;</programlisting>
<screen xml:id="st-geometricmedian-example" role="visual-primary">      centroid      |                 median
--------------------+----------------------------------------
   POINT(62.5 62.5) | POINT(25.01778421249728 25.01778421249728)
(1 row)</screen>
    </refsection>

    <refsection>
      <title>See Also</title>

      <para><xref linkend="ST_Centroid"/></para>
    </refsection>

    </refentry>

	<refentry xml:id="ST_LineMerge">
		<refnamediv>
			<refname>ST_LineMerge</refname>

			<refpurpose>Return the lines formed by sewing together
			a MultiLineString.</refpurpose>
		</refnamediv>

		<refsynopsisdiv>
			<funcsynopsis>
			  <funcprototype>
				<funcdef>geometry <function>ST_LineMerge</function></funcdef>
				<paramdef><type>geometry </type> <parameter>amultilinestring</parameter></paramdef>
			  </funcprototype>
			  <funcprototype>
				<funcdef>geometry <function>ST_LineMerge</function></funcdef>
				<paramdef><type>geometry </type> <parameter>amultilinestring</parameter></paramdef>
				<paramdef><type>boolean </type> <parameter>directed</parameter></paramdef>
			  </funcprototype>
			</funcsynopsis>
		</refsynopsisdiv>

		<refsection>
			<title>Description</title>

			<para>Returns a LineString or MultiLineString formed by joining together
			the line elements of a MultiLineString.
            Lines are joined at their endpoints at 2-way intersections.
            Lines are not joined across intersections of 3-way or greater degree.
            </para>

			<para>If <emphasis role="bold">directed</emphasis> is TRUE, then ST_LineMerge
			will not change point order within LineStrings, so lines with opposite directions
			will not be merged</para>

			<note><para>Only use with MultiLineString/LineStrings. Other geometry types
			return an empty GeometryCollection</para></note>
			<para>Performed by the GEOS module.</para>
			<para role="enhanced" conformance="3.3.0">Enhanced: 3.3.0 accept a directed parameter.</para>
            <para role="geos_requirement" conformance="3.11.0">Requires GEOS &gt;= 3.11.0 to use the directed parameter.</para>
			<para role="availability" conformance="1.1.0">Availability: 1.1.0</para>
			<warning><para>This function strips the M dimension.</para></warning>
		</refsection>

		<refsection>
			<title>Examples</title>
      <refsection>
        <title>Cardinality 2</title>
      <para>Nodes with cardinality 2 are merged away.</para>
				<programlisting language="sql">SELECT ST_LineMerge('MULTILINESTRING((10 160,60 120),(120 140,60 120),(120 140,180 120))'
);</programlisting>
<screen role="visual-primary text-primary">LINESTRING(10 160,60 120,120 140,180 120)</screen>
</refsection>
<refsection>
<title>Cardinality 3 or More</title>
      <para>Lines are not merged across intersections with degree &gt; 2.</para>
				<programlisting language="sql">SELECT ST_LineMerge('MULTILINESTRING((10 160,60 120),(120 140,60 120),(120 140,180 120),(100 180,120 140))'
);</programlisting>
<screen role="visual-primary text-primary">MULTILINESTRING((10 160,60 120,120 140),(100 180,120 140),(120 140,180 120))</screen>
</refsection>

<refsection>
  <title>Non-Touching Lines</title>
<para>If merging is not possible due to non-touching lines,
the original MultiLineString is returned.</para>
<programlisting language="sql">SELECT ST_LineMerge('MULTILINESTRING((-29 -27,-30 -29.7,-36 -31,-45 -33),(-45.2 -33.2,-46 -32))'
);</programlisting>
<screen role="visual-primary text-primary">MULTILINESTRING((-45.2 -33.2,-46 -32),(-29 -27,-30 -29.7,-36 -31,-45 -33))</screen>
</refsection>

<refsection>
  <title>Directed Parameter</title>
<para>Lines with opposite directions are not merged if <parameter>directed</parameter> is <literal>TRUE</literal>.</para>
<programlisting language="sql">SELECT ST_LineMerge('MULTILINESTRING((60 30,10 70),(120 50,60 30),(120 50,180 30))',
TRUE);</programlisting>
<screen role="visual-primary text-primary">MULTILINESTRING((120 50,60 30,10 70),(120 50,180 30))</screen>
</refsection>

<refsection>
<title>Z-dimension Handling</title>
<programlisting>SELECT ST_LineMerge('MULTILINESTRING((-29 -27 11,-30 -29.7 10,-36 -31 5,-45 -33 6),(-29 -27 12,-30 -29.7 5),(-45 -33 1,-46 -32 11))'
        );</programlisting>
<screen role="visual-primary text-primary">LINESTRING Z (-30 -29.7 5,-29 -27 11,-30 -29.7 10,-36 -31 5,-45 -33 1,-46 -32 11)</screen>
</refsection>
		</refsection>
		<refsection>
			<title>See Also</title>
			<para><xref linkend="ST_Segmentize"/>, <xref linkend="ST_LineSubstring"/></para>
		</refsection>
	</refentry>

    <refentry xml:id="ST_MaximumInscribedCircle">
      <refnamediv>
        <refname>ST_MaximumInscribedCircle</refname>
        <refpurpose>Computes the largest circle contained within a geometry.</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>(geometry, geometry, double precision) <function>ST_MaximumInscribedCircle</function></funcdef>
            <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>
        <para>Finds the largest circle that is contained within a (multi)polygon,
        or which does not overlap any lines and points.
        Returns a record with fields:
        </para>
        <itemizedlist>
            <listitem><para> <varname>center</varname> - center point of the circle </para></listitem>
            <listitem><para> <varname>nearest</varname> - a point on the geometry nearest to the center </para></listitem>
            <listitem><para> <varname>radius</varname> - radius of the circle </para></listitem>
        </itemizedlist>

        <para>For polygonal inputs, the circle is inscribed within the boundary rings, using the internal rings as boundaries.
        For linear and point inputs, the circle is inscribed within the convex hull of the input,
        using the input lines and points as further boundaries.</para>

        <para role="availability" conformance="3.1.0">Availability: 3.1.0.</para>
        <para role="geos_requirement" conformance="3.9.0">Requires GEOS &gt;= 3.9.0.</para>

      </refsection>

      <refsection>
        <title>Examples</title>
		<para>Maximum inscribed circle of a polygon. Center, nearest point, radius,
		circle, and radius line are returned.</para>
<programlisting role="requires-geos-3.12">WITH mic AS (
  SELECT * FROM ST_MaximumInscribedCircle(
    'POLYGON ((40 180,110 160,180 180,180 120,140 90,160 40,80 10,70 40,20 50,40 180),
              (60 140,50 90,90 140,60 140))')
)
SELECT round(radius::numeric, 3) AS radius,
       ST_SnapToGrid(center, 1) AS center,
       ST_SnapToGrid(nearest, 1) AS nearest,
       ST_SnapToGrid(ST_Buffer(center, radius), 1) AS circle,
       ST_SnapToGrid(ST_MakeLine(center, nearest), 1) AS radius_line
FROM mic;</programlisting>
<screen role="visual-overlay visual-hide-output-area-vertices">-[ RECORD 1 ]-----
radius      | 45.189
center      | POINT(97 76)
nearest     | POINT(62 105)
circle      | POLYGON((142 76,141 68,139 59,135 51,129 44,122 39,114 35,106 32,97 31,88 32,80 35,72 39,65 44,59 51,55 59,53 68,52 76,53 85,55 94,59 101,65 108,72 114,80 118,88 121,97 122,106 121,114 118,122 114,129 108,135 101,139 94,141 85,142 76))
radius_line | LINESTRING(97 76,62 105)</screen>

		<para>Maximum inscribed circle of a MultiLineString.</para>
<programlisting role="requires-geos-3.12">WITH mic AS (
  SELECT * FROM ST_MaximumInscribedCircle(
    'MULTILINESTRING((100 40,10 150),(10 160,100 150),(190 150,80 40))')
)
SELECT round(radius::numeric, 3) AS radius,
       ST_SnapToGrid(center, 1) AS center,
       ST_SnapToGrid(nearest, 1) AS nearest,
       ST_SnapToGrid(ST_Buffer(center, radius), 1) AS circle,
       ST_SnapToGrid(ST_MakeLine(center, nearest), 1) AS radius_line
FROM mic;</programlisting>
<screen role="visual-overlay visual-hide-output-area-vertices">-[ RECORD 1 ]-----
radius      | 39.924
center      | POINT(94 110)
nearest     | POINT(63 85)
circle      | POLYGON((134 110,133 103,131 95,127 88,122 82,116 77,109 74,102 71,94 71,86 71,79 74,72 77,66 82,61 88,57 95,55 103,54 110,55 118,57 126,61 133,66 139,72 144,79 147,86 150,94 150,102 150,109 147,116 144,122 139,127 133,131 126,133 118,134 110))
radius_line | LINESTRING(94 110,63 85)</screen>
      </refsection>
      <refsection>
        <title>See Also</title>
        <para><xref linkend="ST_MinimumBoundingRadius"/>, <xref linkend="ST_LargestEmptyCircle"/></para>
      </refsection>
    </refentry>


    <refentry xml:id="ST_LargestEmptyCircle">
      <refnamediv>
        <refname>ST_LargestEmptyCircle</refname>
        <refpurpose>Computes the largest circle not overlapping a geometry.</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>(geometry, geometry, double precision) <function>ST_LargestEmptyCircle</function></funcdef>
            <paramdef><type>geometry </type> <parameter>geom</parameter></paramdef>
            <paramdef choice="opt"><type>double precision </type> <parameter>tolerance=0.0</parameter></paramdef>
            <paramdef choice="opt"><type>geometry </type> <parameter>boundary=POINT EMPTY</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>
        <para>Finds the largest circle which does not overlap a set of point and line obstacles. (Polygonal geometries may be included as obstacles, but only their boundary lines are used.) The center of the circle is constrained to lie inside a polygonal boundary, which by default is the convex hull of the input geometry. The circle center is the point in the interior of the boundary which has the farthest distance from the obstacles. The circle itself is provided by the center point and a nearest point lying on an obstacle determining the circle radius.</para>
        <para>If a boundary is supplied it must be a valid polygonal geometry with positive area.</para>
        <para>The circle center is determined to a given  accuracy specified by a distance tolerance, using an iterative algorithm. If the accuracy distance is not specified a reasonable default is used.</para>
        <para>Returns a record with fields:</para>

        <itemizedlist>
            <listitem><para> <varname>center</varname> - center point of the circle </para></listitem>
            <listitem><para> <varname>nearest</varname> - a point on the geometry nearest to the center </para></listitem>
            <listitem><para> <varname>radius</varname> - radius of the circle </para></listitem>
        </itemizedlist>

        <para>To find the largest empty circle in the interior of a polygon, see <xref linkend="ST_MaximumInscribedCircle"/>.</para>

        <para role="availability" conformance="3.4.0">Availability: 3.4.0.</para>
        <para role="geos_requirement" conformance="3.9.0">Requires GEOS &gt;= 3.9.0.</para>

      </refsection>

      <refsection>
        <title>Examples</title>

<para>Largest empty circle within a set of lines.</para>
<programlisting language="sql" role="requires-geos-3.12">WITH obstacles(geom) AS (VALUES ('MULTILINESTRING (
        (10 100,60 180,130 150,190 160),
        (20 50,70 70,90 20,110 40),
        (160 30,100 100,180 100))'::geometry)),
circle AS (
  SELECT result.*
  FROM obstacles
  CROSS JOIN LATERAL ST_LargestEmptyCircle(obstacles.geom) AS result
)
SELECT round(radius::numeric, 6) AS radius,
       ST_SnapToGrid(center, 1) AS center,
       ST_SnapToGrid(nearest, 1) AS nearest,
       ST_SnapToGrid(ST_MakeLine(center, nearest), 1) AS radius_line,
       ST_SnapToGrid(ST_Buffer(center, radius), 1) AS circle
FROM circle;</programlisting>
<screen role="visual-overlay visual-hide-output-area-vertices">-[ RECORD 1 ]-----
radius      | 39.260545
center      | POINT(62 108)
nearest     | POINT(70 70)
radius_line | LINESTRING(62 108,70 70)
circle      | POLYGON((101 108,100 101,98 93,94 87,89 81,83 76,77 72,69 70,62 69,54 70,47 72,40 76,34 81,29 87,25 93,23 101,22 108,23 116,25 123,29 130,34 136,40 141,47 145,54 147,62 148,69 147,77 145,83 141,89 136,94 130,98 123,100 116,101 108))</screen>

<para>Largest empty circle within a set of points, constrained to lie in a polygon.
The constraint polygon boundary is included both as an obstacle and as the constraint for the circle center.</para>
<programlisting language="sql" role="requires-geos-3.12">WITH inputs(points, boundary) AS (VALUES (
  'MULTIPOINT ((70 50),(60 130),(130 150),(80 90))'::geometry,
  'POLYGON ((90 190,10 100,60 10,190 40,120 100,190 180,90 190))'::geometry
)),
circle AS (
  SELECT result.*
  FROM inputs
  CROSS JOIN LATERAL ST_LargestEmptyCircle(
    ST_Collect(points, boundary), 0, boundary
  ) AS result
)
SELECT round(radius::numeric, 6) AS radius,
       ST_SnapToGrid(center, 1) AS center,
       ST_SnapToGrid(nearest, 1) AS nearest,
       ST_SnapToGrid(ST_MakeLine(center, nearest), 1) AS radius_line,
       ST_SnapToGrid(ST_Buffer(center, radius), 1) AS circle
FROM circle;</programlisting>
<screen role="visual-overlay visual-hide-output-area-vertices">-[ RECORD 1 ]-----
radius      | 19.903876
center      | POINT(97 100)
nearest     | POINT(80 90)
radius_line | LINESTRING(97 100,80 90)
circle      | POLYGON((117 100,117 96,116 92,114 89,111 86,108 83,105 82,101 80,97 80,93 80,90 82,86 83,83 86,81 89,79 92,78 96,77 100,78 104,79 108,81 111,83 114,86 116,90 118,93 119,97 120,101 119,105 118,108 116,111 114,114 111,116 108,117 104,117 100))</screen>

      </refsection>
      <refsection>
        <title>See Also</title>
        <para><xref linkend="ST_MinimumBoundingRadius"/></para>
      </refsection>
    </refentry>


    <refentry xml:id="ST_MinimumBoundingCircle">
      <refnamediv>
        <refname>ST_MinimumBoundingCircle</refname>
        <refpurpose>Returns the smallest circle polygon that contains a geometry.</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_MinimumBoundingCircle</function></funcdef>
            <paramdef><type>geometry </type> <parameter>geomA</parameter></paramdef>
            <paramdef choice="opt"><type>integer </type> <parameter>num_segs_per_qt_circ=48</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>
            <para>Returns the smallest circle polygon that contains a geometry. </para>

            <note><para>The bounding circle is approximated by a polygon with a default of 48 segments per quarter circle.
            Because the polygon is an approximation of the minimum bounding circle, some points in the input geometry may not be contained within the polygon.
            The approximation can be improved by increasing the number of segments.
            For applications where an approximation is not suitable <xref linkend="ST_MinimumBoundingRadius"/> may be used.</para></note>

        <para>Use with <xref linkend="ST_Collect"/> to get the minimum bounding circle of a set of geometries.</para>

        <para>To compute two points lying on the minimum circle (the "maximum diameter") use <xref linkend="ST_LongestLine"/>.
        </para>

        <para>The ratio of the area of a polygon divided by the area of its Minimum Bounding Circle
        is referred to as the <emphasis>Reock compactness score</emphasis>.</para>
        <para>Performed by the GEOS module.</para>
        <para role="availability" conformance="1.4.0">Availability: 1.4.0</para>

      </refsection>

      <refsection>
        <title>Examples</title>
<programlisting>SELECT d.disease_type,
ST_MinimumBoundingCircle(ST_Collect(d.geom)) As geom
FROM disease_obs As d
GROUP BY d.disease_type;
</programlisting>
<para>Minimum bounding circle of a point and linestring, using 8 segments to approximate a quarter circle.</para>
<programlisting language="sql">SELECT ST_MinimumBoundingCircle(ST_Collect('LINESTRING(55 75,125 150)',
ST_Point(20, 80)), 8
) As wktmbc;</programlisting>
<screen role="visual-primary">POLYGON((72.5 178.4024474346694,84.86920388664029 177.18418718546332,96.76306620464646 173.57622349601382,107.72451249529237 167.71720838753708,117.33230052487836 159.83230052487838,125.21720838753708 150.22451249529237,131.07622349601382 139.26306620464646,134.68418718546332 127.3692038866403,135.9024474346694 115,134.68418718546332 102.63079611335971,131.07622349601382 90.73693379535354,125.21720838753708 79.77548750470766,117.33230052487838 70.16769947512164,107.72451249529237 62.282791612462916,96.76306620464648 56.42377650398619,84.86920388664032 52.815812814536685,72.50000000000001 51.59755256533059,60.13079611335969 52.815812814536685,48.236933795353536 56.42377650398618,37.27548750470765 62.28279161246291,27.667699475121637 70.16769947512162,19.782791612462923 79.77548750470763,13.923776503986204 90.7369337953535,10.315812814536692 102.63079611335968,9.097552565330588 114.99999999999999,10.315812814536685 127.3692038866403,13.923776503986197 139.2630662046465,19.78279161246291 150.22451249529234,27.667699475121623 159.83230052487835,37.275487504707634 167.71720838753708,48.236933795353494 173.5762234960138,60.13079611335967 177.18418718546332,72.5 178.4024474346694))</screen>
      </refsection>
      <refsection>
        <title>See Also</title>
        <para><xref linkend="ST_Collect"/>, <xref linkend="ST_MinimumBoundingRadius"/>, <xref linkend="ST_LargestEmptyCircle"/>, <xref linkend="ST_LongestLine"/> </para>
      </refsection>
    </refentry>


    <refentry xml:id="ST_MinimumBoundingRadius">
    <refnamediv>
        <refname>ST_MinimumBoundingRadius</refname>
        <refpurpose>Returns the center point and radius of the smallest circle that contains a geometry.</refpurpose>
    </refnamediv>

    <refsynopsisdiv>
        <funcsynopsis>
            <funcprototype>
                <funcdef>(geometry, double precision) <function>ST_MinimumBoundingRadius</function></funcdef>
                <paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
            </funcprototype>
        </funcsynopsis>
    </refsynopsisdiv>

    <refsection>
        <title>Description</title>
        <para>Computes the center point and radius of the smallest circle that contains a geometry.
        Returns a record with fields:
        </para>
        <itemizedlist>
            <listitem><para> <varname>center</varname> - center point of the circle </para></listitem>
            <listitem><para> <varname>radius</varname> - radius of the circle </para></listitem>
        </itemizedlist>

        <para>Use with <xref linkend="ST_Collect"/> to get the minimum bounding circle of a set of geometries.</para>

        <para>To compute two points lying on the minimum circle (the "maximum diameter") use <xref linkend="ST_LongestLine"/>.
        </para>

        <para role="availability" conformance="2.3.0">Availability - 2.3.0</para>
    </refsection>

      <refsection>
        <title>Examples</title>
<programlisting>SELECT center, radius FROM ST_MinimumBoundingRadius('POLYGON((26426 65078,26531 65242,26075 65136,26096 65427,26426 65078))');</programlisting>
<screen>                st_astext                 |      radius
------------------------------------------+------------------
 POINT(26284.84180271327 65267.114509082545) | 247.43604559140655</screen>
      </refsection>

      <refsection>
        <title>See Also</title>
        <para><xref linkend="ST_Collect"/>, <xref linkend="ST_MinimumBoundingCircle"/>, <xref linkend="ST_LongestLine"/></para>
      </refsection>

    </refentry>

    <refentry xml:id="ST_OrientedEnvelope">
        <refnamediv>
            <refname>ST_OrientedEnvelope</refname>
            <refpurpose>Returns a minimum-area rectangle containing a geometry.</refpurpose>
        </refnamediv>

        <refsynopsisdiv>
            <funcsynopsis>
                <funcprototype>
                    <funcdef>geometry <function>ST_OrientedEnvelope</function></funcdef>
                    <paramdef>
                        <type>geometry</type>
                        <parameter>geom</parameter>
                    </paramdef>
                </funcprototype>
            </funcsynopsis>
        </refsynopsisdiv>

        <refsection>
            <title>Description</title>
            <para>
                Returns the minimum-area rotated rectangle enclosing a geometry.
                Note that more than one such rectangle may exist.
                May return a Point or LineString in the case of degenerate inputs.
            </para>
            <para role="availability" conformance="2.5.0">
                Availability: 2.5.0.
            </para>
            <para role="geos_requirement" conformance="3.6.0">Requires GEOS &gt;= 3.6.0.</para>
        </refsection>

        <refsection>
            <title>Examples</title>
            <programlisting>SELECT ST_OrientedEnvelope('MULTIPOINT ((0 0),(-1 -1),(3 2))');</programlisting>
<screen role="visual-primary text-primary">POLYGON((3 2,-1 -1,-1.12 -0.84,2.88 2.16,3 2))</screen>

		<para>Oriented envelope of a Point and LineString.</para>
<programlisting>
SELECT ST_OrientedEnvelope(ST_Collect('LINESTRING(55 75,125 150)',
                ST_Point(20, 80))
                ) As wktenv;</programlisting>
<screen role="visual-primary text-primary geometry-output-precision-11">POLYGON((20 80,125 150,138.0769230769241 130.38461538461573,33.07692307692291 60.384615384615195,20 80))</screen>

        </refsection>

        <refsection>
            <title>See Also</title>
            <para>
                <xref linkend="ST_Envelope"/>
                <xref linkend="ST_MinimumBoundingCircle"/>
            </para>
        </refsection>
    </refentry>

    <refentry xml:id="ST_OffsetCurve">
        <refnamediv>
            <refname>ST_OffsetCurve</refname>

            <refpurpose>
Returns an offset line at a given distance and side from an input line.
        </refpurpose>
        </refnamediv>

        <refsynopsisdiv>
            <funcsynopsis>

                <funcprototype>
                <funcdef>geometry <function>ST_OffsetCurve</function></funcdef>
                <paramdef><type>geometry </type> <parameter>line</parameter></paramdef>
                <paramdef><type>float </type> <parameter>signed_distance</parameter></paramdef>
                <paramdef choice="opt"><type>text </type> <parameter>style_parameters=''</parameter></paramdef>
                </funcprototype>

            </funcsynopsis>
        </refsynopsisdiv>

        <refsection>
            <title>Description</title>

            <para>
Return an offset line at a given distance and side from an input line.
All points of the returned geometries are not further than the given
distance from the input geometry.
Useful for computing parallel lines about a center line.
            </para>

            <para>
For positive distance the offset is on the left side of the input line
and retains the same direction. For a negative distance it is on the right
side and in the opposite direction.
            </para>
            <para>
Units of distance are measured in units of the spatial reference system.
            </para>
            <para>
Note that output may be a MULTILINESTRING or EMPTY for some jigsaw-shaped input geometries.
            </para>
            <para>
The optional third parameter allows specifying a list of blank-separated
key=value pairs to tweak operations as follows:
<itemizedlist>
<listitem>
<para>'quad_segs=#' : number of segments used to approximate a quarter circle (defaults to 8).</para>
</listitem>
<listitem>
<para>'join=round|mitre|bevel' : join style (defaults to "round"). 'miter' is also accepted as a synonym for 'mitre'.</para>
</listitem>
<listitem>
<para>'mitre_limit=#.#' : mitre ratio limit (only affects mitred join style). 'miter_limit' is also accepted as a synonym for 'mitre_limit'.</para>
</listitem>
</itemizedlist>
                </para>

            <para>Performed by the GEOS module.</para>
            <para role="changed">Behavior changed in GEOS 3.11 so offset curves now have the same direction as the input line, for both positive and negative offsets.</para>
            <para role="availability" conformance="2.0">Availability: 2.0</para>
            <para role="enhanced" conformance="2.5">Enhanced: 2.5 - added support for GEOMETRYCOLLECTION and MULTILINESTRING</para>

            <note><para>This function ignores the Z dimension.
It always gives a 2D result even when used on a 3D geometry.</para></note>

            </refsection>

            <refsection>
            <title>Examples</title>
<para>Compute an open buffer around roads.</para>
                <programlisting language="sql">
SELECT ST_Union(
 ST_OffsetCurve(f.geom, f.width/2, 'quad_segs=4 join=round'),
 ST_OffsetCurve(f.geom, -f.width/2, 'quad_segs=4 join=round')
) as track
FROM someroadstable;

                </programlisting>
                <para>Offset 15 units with <code>quad_segs=4 join=round</code>.</para>
                <programlisting language="sql">SELECT ST_OffsetCurve(
    ST_GeomFromText('LINESTRING(164 16,144 16,124 16,104 16,84 16,64 16,
    44 16,24 16,20 16,18 16,17 17,
    16 18,16 20,16 40,16 60,16 80,16 100,
    16 120,16 140,16 160,16 180,16 195)'),
    15, 'quad_segs=4 join=round');</programlisting>
                <screen role="visual-primary visual-overlay text-primary">LINESTRING(164 1,18 1,15.073645169758077 1.288220793951544,
    12.259748514523654 2.141807012330698,9.66644650470597 3.527955815461818,
    7.393398282201788 5.393398282201788,5.393398282201788 7.393398282201788,
    3.527955815461818 9.66644650470597,2.141807012330696 12.259748514523654,
    1.288220793951544 15.073645169758075,1 18,1 195)</screen>

                <para>Offset -15 units with <code>quad_segs=4 join=round</code>.</para>
                <programlisting language="sql">
SELECT ST_OffsetCurve(
    geom,
    -15,
    'quad_segs=4 join=round') As notsocurvy
    FROM ST_GeomFromText('LINESTRING(164 16,144 16,124 16,104 16,84 16,64 16,
    44 16,24 16,20 16,18 16,17 17,
    16 18,16 20,16 40,16 60,16 80,16 100,
    16 120,16 140,16 160,16 180,16 195)') As geom;</programlisting>
                <screen role="visual-primary visual-overlay text-primary">LINESTRING(164 31,31 31,31 195)</screen>

                <para>Apply two negative offsets to obtain a smoother curve; the distances combine to -45 units.</para>
                <programlisting language="sql">
SELECT ST_OffsetCurve(
    ST_OffsetCurve(
        geom,
        -30,
        'quad_segs=4 join=round'),
    -15,
    'quad_segs=4 join=round') As morecurvy
    FROM ST_GeomFromText('LINESTRING(164 16,144 16,124 16,104 16,84 16,64 16,
    44 16,24 16,20 16,18 16,17 17,
    16 18,16 20,16 40,16 60,16 80,16 100,
    16 120,16 140,16 160,16 180,16 195)') As geom;</programlisting>
                <screen role="visual-primary visual-overlay text-primary">LINESTRING(164 61,61 61,61 195)</screen>

                <para>Collect the positive offset and the double-offset to produce parallel curves.</para>
                <programlisting language="sql">SELECT ST_Collect(
    ST_OffsetCurve(geom, 15, 'quad_segs=4 join=round'),
    ST_OffsetCurve(
        ST_OffsetCurve(
            geom,
            -30,
            'quad_segs=4 join=round'),
        -15,
        'quad_segs=4 join=round')
) As parallel_curves
    FROM ST_GeomFromText('LINESTRING(164 16,144 16,124 16,104 16,84 16,64 16,
    44 16,24 16,20 16,18 16,17 17,
    16 18,16 20,16 40,16 60,16 80,16 100,
    16 120,16 140,16 160,16 180,16 195)') As geom;</programlisting>
                <screen role="visual-primary visual-overlay text-primary">MULTILINESTRING((164 1,18 1,15.073645169758077 1.288220793951544,
12.259748514523654 2.141807012330698,9.66644650470597 3.527955815461818,
7.393398282201788 5.393398282201788,5.393398282201788 7.393398282201788,
3.527955815461818 9.66644650470597,2.141807012330696 12.259748514523654,
1.288220793951544 15.073645169758075,1 18,1 195),(164 61,61 61,61 195))</screen>

                <para>Offset 15 units with a bevel join.</para>
                <programlisting language="sql">SELECT ST_OffsetCurve(
    ST_GeomFromText('LINESTRING(164 16,144 16,124 16,104 16,84 16,64 16,
    44 16,24 16,20 16,18 16,17 17,
    16 18,16 20,16 40,16 60,16 80,16 100,
    16 120,16 140,16 160,16 180,16 195)'),
        15, 'quad_segs=4 join=bevel');</programlisting>
                <screen role="visual-primary visual-overlay text-primary">LINESTRING(164 1,18 1,7.393398282201788 5.393398282201788,
    5.393398282201788 7.393398282201788,1 18,1 195)</screen>

                <para>Collect offsets on both sides using a mitre join and a mitre limit of 2.2.</para>
                <programlisting language="sql">
SELECT ST_Collect(
    ST_OffsetCurve(geom, 15, 'quad_segs=4 join=mitre mitre_limit=2.2'),
    ST_OffsetCurve(geom, -15, 'quad_segs=4 join=mitre mitre_limit=2.2')
    )
    FROM ST_GeomFromText('LINESTRING(164 16,144 16,124 16,104 16,84 16,64 16,
    44 16,24 16,20 16,18 16,17 17,
    16 18,16 20,16 40,16 60,16 80,16 100,
    16 120,16 140,16 160,16 180,16 195)') As geom;</programlisting>
                <screen role="visual-overlay visual-primary text-primary">MULTILINESTRING((164 1,11.786796564403577 1,1 11.786796564403577,1 195),
    (164 31,31 31,31 195))</screen>

            </refsection>

              <refsection>
                <title>See Also</title>
                <para><xref linkend="ST_Buffer"/></para>
              </refsection>
    </refentry>

    <refentry xml:id="ST_PointOnSurface">
      <refnamediv>
        <refname>ST_PointOnSurface</refname>
        <refpurpose>Computes a point guaranteed to lie in a polygon, or on a geometry.</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_PointOnSurface</function></funcdef>

            <paramdef><type>geometry </type>
            <parameter>g1</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>

        <para>Returns a <varname>POINT</varname> which is guaranteed to lie in the interior of a surface
        (<varname>POLYGON</varname>, <varname>MULTIPOLYGON</varname>, and <varname>CURVEPOLYGON</varname>).
        In PostGIS this function also works on line and point geometries.
        </para>

        <para>&sfs_compliant; s3.2.14.2 // s3.2.18.2</para>
        <para>&sqlmm_compliant; SQL-MM 3: 8.1.5, 9.5.6.
         The specifications define ST_PointOnSurface for surface geometries only.
         PostGIS extends the function to support all common geometry types.
         Other databases (Oracle, DB2, ArcSDE) seem to support this function only for surfaces.
         SQL Server 2008 supports all common geometry types.</para>
        <para>&Z_support;</para>
      </refsection>

      <refsection>
        <title>Examples</title>

		<para>Point on surface of a MultiPoint.</para>
<programlisting>SELECT ST_PointOnSurface(
  'MULTIPOINT (8 24,10 92,12 154,17 68,28 10,29 52,29 84,55 50,56 24,131 14,160 180,189 180)');</programlisting>
<screen xml:id="st-pointonsurface-multipoint" role="visual-primary text-primary">POINT(55 50)</screen>

		<para>Point on surface of a LineString.</para>
<programlisting>SELECT ST_PointOnSurface(
  'LINESTRING (190 160,10 190,40 90,20 70,10 10,30 40,30 10,110 40,70 10,110 10,140 40,140 10,160 30,180 10)');</programlisting>
<screen role="visual-primary text-primary">POINT(40 90)</screen>

		<para>Point on surface of a Polygon.</para>
<programlisting>SELECT ST_PointOnSurface(
  'POLYGON ((190 190,10 190,10 10,190 10,190 20,160 30,60 30,60 130,190 140,190 190))');</programlisting>
<screen role="visual-primary text-primary">POINT(35 80)</screen>

		<para>Point on surface of the highest-dimension components of a GeometryCollection.</para>
<programlisting>SELECT ST_PointOnSurface(
  'GEOMETRYCOLLECTION (POLYGON ((190 170,180 100,80 140,80 160,130 160,110 180,110 190,180 180,190 170)),
    LINESTRING (80 120,120 20,140 70,150 30,180 50,190 10),
    MULTIPOINT (19 150,22 49,30 13,32 101,45 35,67 88,75 16))');</programlisting>
<screen role="visual-primary text-primary">POINT(133.571 150)</screen>

<programlisting>SELECT ST_PointOnSurface('LINESTRING(0 5 1,0 0 1,0 10 2)');</programlisting>
<screen>  st_asewkt
--------------
 POINT(0 0 1)
(1 row)</screen>

        <para><emphasis role="bold">Example:</emphasis>
        The result of ST_PointOnSurface is guaranteed to lie within polygons,
        whereas the point computed by <xref linkend="ST_Centroid"/> may be outside.
        </para>

<programlisting>
SELECT ST_PointOnSurface(geom) AS pt_on_surf, ST_Centroid(geom) AS centroid
    FROM (SELECT 'POLYGON ((130 120,120 190,30 140,50 20,190 20,
                      170 100,90 60,90 130,130 120))'::geometry AS geom) AS t;</programlisting>
<screen>   pt_on_surf    |                  centroid
-----------------+---------------------------------------------
 POINT(62.5 110) | POINT(100.18264840182648 85.11415525114155)</screen>
      </refsection>

      <refsection>
        <title>See Also</title>
        <para><xref linkend="ST_Centroid"/>, <xref linkend="ST_MaximumInscribedCircle"/></para>
      </refsection>
    </refentry>

    <refentry xml:id="ST_Polygonize">
        <refnamediv>
            <refname>ST_Polygonize</refname>

            <refpurpose>Computes a collection of polygons formed from the linework of a set of geometries.
            </refpurpose>
        </refnamediv>

        <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_Polygonize</function></funcdef>
            <paramdef><type>geometry set</type> <parameter>geomfield</parameter></paramdef>
          </funcprototype>

          <funcprototype>
            <funcdef>geometry <function>ST_Polygonize</function></funcdef>
            <paramdef><type>geometry[]</type> <parameter>geom_array</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
        </refsynopsisdiv>

        <refsection>
            <title>Description</title>

            <para>Creates a GeometryCollection containing the
            polygons formed by the linework of a set of geometries.
            If the input linework does not form any polygons, an empty GeometryCollection is returned.
            </para>

            <para>This function creates polygons covering all delimited areas.
            If the result is intended to form a valid polygonal geometry,
            use <xref linkend="ST_BuildArea"/> to prevent holes being filled.
            </para>

            <note>
                <para>
                The input linework must be correctly noded for this function to work properly.
                To ensure input is noded use <xref linkend="ST_Node"/> on the input geometry
                before polygonizing.
                </para>
            </note>

            <note>
                <para>GeometryCollections can be difficult to handle with external tools.
                Use <xref linkend="ST_Dump"/> to convert the polygonized result
                into separate polygons.</para>
            </note>
            <para>Performed by the GEOS module.</para>

            <para role="availability" conformance="1.0.0">Availability: 1.0.0RC1</para>
        </refsection>

        <refsection>
        <title>Examples</title>

		<para>Polygonize a set of input lines.</para>
      <programlisting language="sql">WITH data(geom) AS (
  VALUES
    ('LINESTRING (180 40,30 20,20 90)'::geometry),
    ('LINESTRING (180 40,160 160)'::geometry),
    ('LINESTRING (80 60,120 130,150 80)'::geometry),
    ('LINESTRING (80 60,150 80)'::geometry),
    ('LINESTRING (20 90,70 70,80 130)'::geometry),
    ('LINESTRING (80 130,160 160)'::geometry),
    ('LINESTRING (20 90,20 160,70 190)'::geometry),
    ('LINESTRING (70 190,80 130)'::geometry),
    ('LINESTRING (70 190,160 160)'::geometry)
)
SELECT ST_Polygonize(geom)
FROM data;</programlisting>
<screen role="visual-primary text-primary">GEOMETRYCOLLECTION(POLYGON((180 40,30 20,20 90,70 70,80 130,160 160,180 40),(150 80,120 130,80 60,150 80)), POLYGON((80 60,120 130,150 80,80 60)), POLYGON((80 130,70 70,20 90,20 160,70 190,80 130)), POLYGON((160 160,80 130,70 190,160 160)))</screen>


        <para>Polygonizing two polygon coverages and transferring attributes to the resultants:</para>
<programlisting>WITH poly_a(id, geom) AS (VALUES
  ('a1', 'POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))'::geometry),
  ('a2', 'POLYGON ((4 0, 8 0, 8 4, 4 4, 4 0))'::geometry)
),
poly_b(id, geom) AS (VALUES
  ('b1', 'POLYGON ((0 0, 8 0, 8 2, 0 2, 0 0))'::geometry),
  ('b2', 'POLYGON ((0 2, 8 2, 8 4, 0 4, 0 2))'::geometry)
),
lines AS (
  SELECT ST_Boundary(geom) AS geom FROM poly_a
  UNION ALL
  SELECT ST_Boundary(geom) FROM poly_b
),
noded AS (
  SELECT ST_UnaryUnion(ST_Collect(geom)) AS geom FROM lines
),
cells AS (
  SELECT (ST_Dump(ST_Polygonize(geom))).geom AS geom FROM noded
)
SELECT a.id AS id_a,
       b.id AS id_b,
       c.geom AS geom
FROM cells AS c
LEFT JOIN poly_a AS a ON ST_Within(ST_PointOnSurface(c.geom), a.geom)
LEFT JOIN poly_b AS b ON ST_Within(ST_PointOnSurface(c.geom), b.geom)
WHERE a.id IS NOT NULL OR b.id IS NOT NULL
ORDER BY id_a, id_b;</programlisting>
<screen> id_a | id_b |              geom
------+------+--------------------------------
 a1   | b1   | POLYGON((4 0,0 0,0 2,4 2,4 0))
 a1   | b2   | POLYGON((4 4,4 2,0 2,0 4,4 4))
 a2   | b1   | POLYGON((4 0,4 2,8 2,8 0,4 0))
 a2   | b2   | POLYGON((4 2,4 4,8 4,8 2,4 2))
</screen>

        <para>Polygonizing a table of linestrings:</para>
         <programlisting role="requires-external-state">
SELECT ST_Polygonize(geom_4269) As geomtextrep
FROM (SELECT geom_4269 FROM ma.suffolk_edges) As foo;</programlisting>
<screen> geomtextrep
-------------
 SRID=4269;GEOMETRYCOLLECTION(POLYGON((-71.040878 42.285678,-71.040943 42.2856,-71.04096 42.285752,-71.040878 42.285678)),
 POLYGON((-71.17166 42.353675,-71.172026 42.354044,-71.17239 42.354358,-71.171794 42.354971,-71.170511 42.354855,
 -71.17112 42.354238,-71.17166 42.353675)))
(1 row)</screen>

<para>Use ST_Dump to dump out the polygonize geoms into individual polygons.</para>
<programlisting role="requires-external-state" language="sql">
SELECT (ST_Dump(t.polycoll)).geom AS geomtextrep
FROM (SELECT ST_Polygonize(geom_4269) AS polycoll
    FROM (SELECT geom_4269 FROM ma.suffolk_edges)
        As foo) AS t;
</programlisting>
<screen> geomtextrep
-------------
 SRID=4269;POLYGON((-71.040878 42.285678,-71.040943 42.2856,-71.04096 42.285752,
-71.040878 42.285678))
 SRID=4269;POLYGON((-71.17166 42.353675,-71.172026 42.354044,-71.17239 42.354358,
-71.171794 42.354971,-71.170511 42.354855,-71.17112 42.354238,-71.17166 42.353675))
(2 rows)</screen>
        </refsection>

        <refsection>
            <title>See Also</title>
            <para>
            <xref linkend="ST_BuildArea"/>,
            <xref linkend="ST_Boundary"/>,
            <xref linkend="ST_Collect"/>,
            <xref linkend="ST_Dump"/>,
            <xref linkend="ST_Node"/>,
            <xref linkend="ST_PointOnSurface"/>,
            <xref linkend="ST_UnaryUnion"/>,
            <xref linkend="ST_Within"/>
            </para>
        </refsection>
    </refentry>

    <refentry xml:id="ST_ReducePrecision">
      <refnamediv>
        <refname>ST_ReducePrecision</refname>

        <refpurpose>Returns a valid geometry with points rounded to a grid tolerance.</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_ReducePrecision</function></funcdef>

            <paramdef><type>geometry </type>
            <parameter>g</parameter></paramdef>
            <paramdef><type>float8 </type>
            <parameter>gridsize</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>

        <para>Returns a valid geometry with all points rounded to the provided grid tolerance, and features below the tolerance removed.</para>

        <para>Unlike <xref linkend="ST_SnapToGrid"/> the returned geometry will be valid, with no ring self-intersections or collapsed components.</para>

		<para>
        Precision reduction can be used to:
        <itemizedlist>
            <listitem><para>
            match coordinate precision to the data accuracy
            </para></listitem>
            <listitem><para>
            reduce the number of coordinates needed to represent a geometry
            </para></listitem>
            <listitem><para>
            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).
            </para></listitem>
            <listitem><para>
            export valid geometry to systems which use lower or limited precision
            (e.g. SDE, Oracle tolerance value)
            </para></listitem>
        </itemizedlist>
		</para>

        <para role="availability" conformance="3.1.0">Availability: 3.1.0.</para>
        <para role="geos_requirement" conformance="3.9.0">Requires GEOS &gt;= 3.9.0.</para>
      </refsection>

      <refsection>
        <title>Examples</title>

        <programlisting>SELECT ST_ReducePrecision('POINT(1.412 19.323)', 0.1);</programlisting>
<screen role="visual-primary text-primary">POINT(1.4 19.3)</screen>
<programlisting>SELECT ST_ReducePrecision('POINT(1.412 19.323)', 1.0);</programlisting>
<screen role="visual-primary text-primary">POINT(1 19)</screen>
<programlisting>SELECT ST_ReducePrecision('POINT(1.412 19.323)', 10);</programlisting>
<screen role="visual-primary text-primary">POINT(0 20)</screen>

<para>Precision reduction can reduce number of vertices</para>
<programlisting>SELECT ST_ReducePrecision('LINESTRING (10 10,19.6 30.1,20 30,20.3 30,40 40)', 1);</programlisting>
<screen role="visual-primary text-primary">LINESTRING (10 10, 20 30, 40 40)</screen>

<para>Precision reduction splits polygons if needed to ensure validity</para>
<programlisting language="sql">WITH data(geom) AS (
  VALUES ('POLYGON ((10 10,60 60.1,70 30,40 40,50 10,10 10))'::geometry)
)
SELECT geom AS input,
       ST_ReducePrecision(geom, 10) AS reduced
FROM data;</programlisting>
<screen role="visual-primary text-primary visual-output-only visual-separate-output psql-expanded">-[ RECORD 1 ]------------------------------------------------
input   | POLYGON((10 10,60 60.1,70 30,40 40,50 10,10 10))
reduced | MULTIPOLYGON(((10 10,40 40,50 10,10 10)),((40 40,60 60,70 30,40 40)))</screen>
      </refsection>

      <refsection>
        <title>See Also</title>

        <para><xref linkend="ST_SnapToGrid"/>, <xref linkend="ST_Simplify"/>, <xref linkend="ST_SimplifyVW"/></para>
      </refsection>
    </refentry>

    <refentry xml:id="ST_SharedPaths">
      <refnamediv>
        <refname>ST_SharedPaths</refname>
        <refpurpose>Returns a collection containing paths shared by the two input linestrings/multilinestrings.</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_SharedPaths</function></funcdef>
            <paramdef><type>geometry</type> <parameter>lineal1</parameter></paramdef>
            <paramdef><type>geometry</type> <parameter>lineal2</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>
        <para>Returns a collection containing paths shared by the two input geometries.
            Those going in the same direction are in the first element of the collection, those going in the opposite direction are in the second element.
            The paths themselves are given in the direction of the first geometry.
        </para>
        <para>Performed by the GEOS module.</para>
        <para role="availability" conformance="2.0.0">Availability: 2.0.0</para>
      </refsection>
      <refsection>
        <title>Examples: Finding shared paths</title>
        <para>Adjacent shared path segments may be returned as separate or merged LineStrings
          depending on the GEOS version.</para>
        <para>Find the shared paths of a MultiLineString and a LineString.</para>
<programlisting language="sql">
SELECT ST_SharedPaths(ST_GeomFromText('MULTILINESTRING((26 125,26 200,126 200,126 125,26 125),
      (51 150,101 150,76 175,51 150))'),
   ST_GeomFromText('LINESTRING(151 100,126 156.25,126 125,101 150,76 175)')
   )</programlisting>
<screen role="visual-primary text-primary">GEOMETRYCOLLECTION(MULTILINESTRING((126 156.25,126 125),
(101 150,76 175)),MULTILINESTRING EMPTY)</screen>

        <para>Flip the LineString orientation to return the same paths in the opposite-direction member.</para>
        <programlisting language="sql">
SELECT ST_SharedPaths(ST_GeomFromText('LINESTRING(76 175,101 150,126 125,126 156.25,151 100)'),
   ST_GeomFromText('MULTILINESTRING((26 125,26 200,126 200,126 125,26 125),
       (51 150,101 150,76 175,51 150))')
    )</programlisting>
<screen role="visual-primary text-primary">GEOMETRYCOLLECTION(MULTILINESTRING EMPTY,
MULTILINESTRING((76 175,101 150),(126 125,126 156.25)))</screen>
     </refsection>
      <refsection>
        <title>See Also</title>
    <para>
        <xref linkend="ST_Dump"/>,
        <xref linkend="ST_GeometryN"/>,
        <xref linkend="ST_NumGeometries"/>
    </para>
      </refsection>
    </refentry>

    <refentry xml:id="ST_Simplify">
      <refnamediv>
        <refname>ST_Simplify</refname>
        <refpurpose>Returns a simplified representation of a geometry, using the Douglas-Peucker algorithm.</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_Simplify</function></funcdef>
            <paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
            <paramdef><type>float</type> <parameter>tolerance</parameter></paramdef>
          </funcprototype>
          <funcprototype>
            <funcdef>geometry <function>ST_Simplify</function></funcdef>
            <paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
            <paramdef><type>float</type> <parameter>tolerance</parameter></paramdef>
            <paramdef><type>boolean</type> <parameter>preserveCollapsed</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>
        <para>Computes a simplified representation of a geometry using the
            <link xlink:href="https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm">Douglas-Peucker algorithm</link>.
            The simplification <varname>tolerance</varname> is a distance value, in the units of the input SRS.
            Simplification removes vertices which are within the tolerance distance of the simplified linework.
            The result may not be valid even if the input is.
            </para>
          <para>
            The function can be called with any kind of geometry (including GeometryCollections),
            but only line and polygon elements are simplified.
            Endpoints of linear geometry are preserved.
            </para>

        <para>The <varname>preserveCollapsed</varname> flag retains small geometries that would otherwise
          be removed at the given tolerance. For example, if a 1m long line is simplified with a 10m
          tolerance, when <varname>preserveCollapsed</varname> is true the line will not disappear.
          This flag is useful for rendering purposes, to prevent
          very small features disappearing from a map.</para>

        <note><para>The returned geometry may lose its simplicity (see <xref linkend="ST_IsSimple"/>),
         topology may not be preserved, and polygonal results may be invalid (see <xref linkend="ST_IsValid"/>).
         Use <xref linkend="ST_SimplifyPreserveTopology"/> to preserve topology and ensure validity.</para></note>
        <note><para>This function does not preserve boundaries shared between polygons.  Use <xref linkend="ST_CoverageSimplify"/> if this is required.</para></note>

        <para role="availability" conformance="1.2.2">Availability: 1.2.2</para>
      </refsection>

          <refsection>
            <title>Examples</title>
            <para>A circle simplified with a medium tolerance becomes an octagon, and with a large tolerance disappears.</para>
                <programlisting role="requires-geos-3.12">SELECT ST_NPoints(geom) AS np_before,
     ST_NPoints(ST_Simplify(geom, 0.1)) AS np01_notbadcircle,
     ST_NPoints(ST_Simplify(geom, 0.5)) AS np05_notquitecircle,
     ST_NPoints(ST_Simplify(geom, 1)) AS np1_octagon,
     ST_NPoints(ST_Simplify(geom, 10)) AS np10_gone,
     (ST_Simplify(geom, 100) is null) AS  np100_geometrygoesaway
FROM (SELECT ST_Buffer('POINT(1 3)', 10, 12) As geom) AS t;</programlisting>
<screen>-[ RECORD 1 ]------------
np_before                | 49
np01_notbadcircle        | 33
np05_notquitecircle      | 17
np1_octagon              | 9
np10_gone                | null
np100_geometrygoesaway   | t</screen>

    <para>Simplifying a set of lines.  Lines may intersect after simplification.</para>
    <programlisting>SELECT ST_Simplify('MULTILINESTRING ((20 180,20 150,50 150,50 100,110 150,150 140,170 120),(20 10,80 30,90 120),(90 120,130 130),(130 130,130 70,160 40,180 60,180 90,140 80),(50 40,70 40,80 70,70 60,60 60,50 50,50 40))'::geometry,
40);</programlisting>
<screen role="visual-primary text-primary">MULTILINESTRING((20 180,50 100,170 120),(20 10,90 120),(90 120,130 130),(130 130,160 40,180 90,140 80),(50 40,80 70,50 40))</screen>

    <para>Simplifying a MultiPolygon.  Polygonal results may be invalid.</para>
    <programlisting>SELECT ST_Simplify('MULTIPOLYGON (((90 110,80 180,50 160,10 170,10 140,20 110,90 110)),((40 80,100 100,120 160,170 180,190 70,140 10,110 40,60 40,40 80),(180 70,170 110,142.5 128.5,128.5 77.5,90 60,180 70)))'::geometry,
40);</programlisting>
<screen role="visual-primary text-primary">MULTIPOLYGON(((90 110,80 180,10 170,20 110,90 110)),((40 80,170 180,140 10,40 80),(180 70,142.5 128.5,90 60,180 70)))</screen>

          </refsection>
          <refsection>
            <title>See Also</title>
            <para>
    <xref linkend="ST_IsSimple"/>,
    <xref linkend="ST_SimplifyPreserveTopology"/>,
    <xref linkend="ST_SimplifyVW"/>,
    <xref linkend="ST_CoverageSimplify"/>,
    Topology <xref linkend="TP_ST_Simplify"/></para>
          </refsection>
    </refentry>

    <refentry xml:id="ST_SimplifyPreserveTopology">
      <refnamediv>
        <refname>ST_SimplifyPreserveTopology</refname>
        <refpurpose>Returns a simplified and valid representation of a geometry, using
            the Douglas-Peucker algorithm.</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_SimplifyPreserveTopology</function></funcdef>
            <paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
            <paramdef><type>float</type> <parameter>tolerance</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>
        <para>Computes a simplified representation of a geometry using a variant of the
            <link xlink:href="https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm">Douglas-Peucker algorithm</link>
            which limits simplification to ensure the result has the same topology as the input.
            The simplification <varname>tolerance</varname> is a distance value, in the units of the input SRS.
            Simplification removes vertices which are within the tolerance distance
            of the simplified linework, as long as topology is preserved.
            The result will be valid and simple if the input is.
            </para>
          <para>
            The function can be called with any kind of geometry (including GeometryCollections),
            but only line and polygon elements are simplified.
            For polygonal inputs, the result will have the same number of rings (shells and holes),
            and the rings will not cross.  Ring endpoints may be simplified.
            For linear inputs, the result will have the same number of lines, and lines will not intersect
            if they did not do so in the original geometry.
            Endpoints of linear geometry are preserved.
            </para>

        <note><para>This function does not preserve boundaries shared between polygons.  Use <xref linkend="ST_CoverageSimplify"/> if this is required.</para></note>

        <para>Performed by the GEOS module.</para>
        <para role="availability" conformance="1.3.3">Availability: 1.3.3</para>
      </refsection>

          <refsection>
            <title>Examples</title>
            <para>For the same example as <xref linkend="ST_Simplify"/>, ST_SimplifyPreserveTopology prevents the geometry from disappearing.</para>
                <programlisting>
SELECT  ST_NPoints(geom) AS np_before,
        ST_NPoints(ST_SimplifyPreserveTopology(geom, 0.1)) AS np01_notbadcircle,
        ST_NPoints(ST_SimplifyPreserveTopology(geom, 0.5)) AS np05_notquitecircle,
        ST_NPoints(ST_SimplifyPreserveTopology(geom, 1))   AS np1_octagon,
        ST_NPoints(ST_SimplifyPreserveTopology(geom, 10))  AS np10_minimal,
        ST_NPoints(ST_SimplifyPreserveTopology(geom, 100)) AS np100_minimal
FROM (SELECT ST_Buffer('POINT(1 3)', 10, 12) AS geom) AS t;</programlisting>
<screen> np_before | np01_notbadcircle | np05_notquitecircle | np1_octagon | np10_minimal | np100_minimal
-----------+-------------------+---------------------+-------------+--------------+---------------
        49 |                33 |                  17 |           9 |            4 |             4</screen>

    <para>Simplifying a set of lines, preserving topology of non-intersecting lines.</para>
    <programlisting>SELECT ST_SimplifyPreserveTopology('MULTILINESTRING ((20 180,20 150,50 150,50 100,110 150,150 140,170 120),(20 10,80 30,90 120),(90 120,130 130),(130 130,130 70,160 40,180 60,180 90,140 80),(50 40,70 40,80 70,70 60,60 60,50 50,50 40))'::geometry,
40);</programlisting>
<screen role="visual-primary text-primary">MULTILINESTRING((20 180,50 100,110 150,170 120),(20 10,80 30,90 120),(90 120,130 130),(130 130,130 70,160 40,180 90,140 80),(50 40,70 40,80 70,60 60,50 40))</screen>

    <para>Simplifying a MultiPolygon, preserving topology of shells and holes.</para>
    <programlisting>SELECT ST_SimplifyPreserveTopology('MULTIPOLYGON (((90 110,80 180,50 160,10 170,10 140,20 110,90 110)),((40 80,100 100,120 160,170 180,190 70,140 10,110 40,60 40,40 80),(180 70,170 110,142.5 128.5,128.5 77.5,90 60,180 70)))'::geometry,
40);</programlisting>
<screen role="visual-primary text-primary">MULTIPOLYGON(((90 110,80 180,10 170,20 110,90 110)),((40 80,100 100,170 180,190 70,140 10,40 80),(180 70,142.5 128.5,90 60,180 70)))</screen>

          </refsection>

          <refsection>
            <title>See Also</title>
            <para><xref linkend="ST_Simplify"/>,
              <xref linkend="ST_SimplifyVW"/>,
              <xref linkend="ST_CoverageSimplify"/></para>
          </refsection>
    </refentry>


    <refentry xml:id="ST_SimplifyPolygonHull">
      <refnamediv>
        <refname>ST_SimplifyPolygonHull</refname>
        <refpurpose>Computes a simplified topology-preserving outer or inner hull of a polygonal geometry.</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
         <funcprototype>
            <funcdef>geometry <function>ST_SimplifyPolygonHull</function></funcdef>
            <paramdef><type>geometry </type> <parameter>param_geom</parameter></paramdef>
            <paramdef><type>float </type> <parameter>vertex_fraction</parameter></paramdef>
            <paramdef choice="opt"><type>boolean </type> <parameter>is_outer = true</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>

        <para>Computes a simplified topology-preserving outer or inner hull of a polygonal geometry.
        An outer hull completely covers the input geometry.
        An inner hull is completely covered by the input geometry.
        The result is a polygonal geometry formed by a subset of the input vertices.
        MultiPolygons and holes are handled and produce a result with the same structure as the input.
        </para>

        <para>The reduction in vertex count is controlled by the <varname>vertex_fraction</varname> parameter,
        which is a number in the range 0 to 1.
        Lower values produce simpler results, with smaller vertex count and less concaveness.
        For both outer and inner hulls a vertex fraction of 1.0 produces the original geometry.
        For outer hulls a value of 0.0 produces the convex hull (for a single polygon);
        for inner hulls it produces a triangle.</para>

        <para>
        The simplification process operates by progressively removing concave corners that contain the least amount of area, until the vertex count target is reached.
        It prevents edges from crossing, so the result is always a valid polygonal geometry.
        </para>

        <para>To get better results with geometries that contain relatively long line segments, it might be necessary to "segmentize" the input, as shown below.</para>

        <para>Performed by the GEOS module.</para>
    	<para role="availability" conformance="3.3.0">Availability: 3.3.0.</para>
        <para role="geos_requirement" conformance="3.11.0">Requires GEOS &gt;= 3.11.0.</para>

      </refsection>
      <refsection>
        <title>Examples</title>

    <para>Outer hull of a Polygon.</para>
    <programlisting>SELECT ST_SimplifyPolygonHull(
  'POLYGON ((131 158,136 163,161 165,173 156,179 148,169 140,186 144,190 137,185 131,174 128,174 124,166 119,158 121,158 115,165 107,161 97,166 88,166 79,158 57,145 57,112 53,111 47,93 43,90 48,88 40,80 39,68 32,51 33,40 31,39 34,49 38,34 38,25 34,28 39,36 40,44 46,24 41,17 41,14 46,19 50,33 54,21 55,13 52,11 57,22 60,34 59,41 68,75 72,62 77,56 70,46 72,31 69,46 76,52 82,47 84,56 90,66 90,64 94,56 91,33 97,36 100,23 100,22 107,29 106,31 112,46 116,36 118,28 131,53 132,59 127,62 131,76 130,80 135,89 137,87 143,73 145,80 150,88 150,85 157,99 162,116 158,115 165,123 165,122 170,134 164,131 158))'::geometry,
  0.3
);</programlisting>
    <screen role="visual-primary text-primary">POLYGON((161 165,173 156,186 144,190 137,185 131,174 124,166 119,166 79,158 57,68 32,40 31,25 34,17 41,14 46,11 57,56 91,33 97,23 100,22 107,28 131,80 135,73 145,85 157,99 162,122 170,161 165))</screen>

    <para>Inner hull of a Polygon.</para>
    <programlisting role="requires-geos-3.12">SELECT ST_SimplifyPolygonHull(
  'POLYGON ((131 158,136 163,161 165,173 156,179 148,169 140,186 144,190 137,185 131,174 128,174 124,166 119,158 121,158 115,165 107,161 97,166 88,166 79,158 57,145 57,112 53,111 47,93 43,90 48,88 40,80 39,68 32,51 33,40 31,39 34,49 38,34 38,25 34,28 39,36 40,44 46,24 41,17 41,14 46,19 50,33 54,21 55,13 52,11 57,22 60,34 59,41 68,75 72,62 77,56 70,46 72,31 69,46 76,52 82,47 84,56 90,66 90,64 94,56 91,33 97,36 100,23 100,22 107,29 106,31 112,46 116,36 118,28 131,53 132,59 127,62 131,76 130,80 135,89 137,87 143,73 145,80 150,88 150,85 157,99 162,116 158,115 165,123 165,122 170,134 164,131 158))'::geometry,
  0.3, false
);</programlisting>
    <screen role="visual-primary text-primary">POLYGON((131 158,116 158,99 162,89 137,76 130,59 127,28 131,46 116,36 100,64 94,75 72,41 68,33 54,68 32,90 48,112 53,145 57,158 57,161 97,158 115,158 121,190 137,169 140,179 148,161 165,131 158))</screen>

    <para>Outer hull simplification of a MultiPolygon, with segmentization.</para>
    <programlisting>WITH letters AS (
  SELECT ST_Letters('xt') AS geom
)
SELECT geom AS input,
  ST_SimplifyPolygonHull(ST_Segmentize(geom, 2.0), 0.1) AS outer_hull
FROM letters;</programlisting>
    <screen role="visual-primary">MULTIPOLYGON(((18.3 57.6,20.7 51,23.3 41.9,26 51,28.4 57.6,45.4 57.6,33.1 28.8,46.6 0,29.5 0,26.6 6.7,23.3 16.3,19.8 6.3,17.1 0,0 0,13.5 28.8,1.3 57.6,18.3 57.6)),((77.808 15.2,82.208 15.2,83.508 16,83.508 -0.9,82.108 -0.2,76.808 -0.2,76.108 -0.2,75.408 -0.2,74.608 -0.1,73.908 -0.1,73.208 0,72.508 0,71.808 0.1,71.108 0.2,70.408 0.3,69.708 0.5,69.008 0.6,68.408 0.9,67.708 1.1,67.008 1.4,66.408 1.7,65.708 2,65.108 2.4,64.408 2.8,63.808 3.2,63.208 3.7,62.608 4.1,62.108 4.7,61.508 5.2,61.008 5.8,60.508 6.4,60.008 7.1,59.508 7.8,59.108 8.6,58.708 9.5,58.308 10.4,57.908 11.3,57.608 12.3,57.608 42.7,52.208 42.7,51.108 41.8,51.108 58.9,52.208 57.9,57.608 57.9,57.608 74.4,56.508 75.4,74.408 75.4,73.308 74.2,73.308 57.9,81.408 57.9,82.508 58.9,82.508 41.8,81.408 42.7,73.308 42.7,73.308 17.7,73.408 17.4,73.608 17.2,73.808 16.9,74.008 16.7,74.208 16.5,74.408 16.3,74.708 16.1,75.008 15.9,75.308 15.7,75.608 15.6,76.008 15.5,76.308 15.4,76.708 15.3,77.008 15.2,77.408 15.2,77.808 15.2))) | MULTIPOLYGON(((45.4 57.6,44.631 55.8,33.869 30.6,46.6 0,29.5 0,19.8 6.3,18.45 3.15,17.1 0,0 0,10.969 23.4,9.688 37.8,2.062 55.8,1.3 57.6,45.4 57.6)),((83.508 16,83.508 -0.9,72.508 0,71.108 0.2,70.408 0.3,69.008 0.6,67.708 1.1,67.008 1.4,65.708 2,64.408 2.8,63.808 3.2,62.608 4.1,61.508 5.2,60.508 6.4,59.508 7.8,59.108 8.6,58.308 10.4,57.908 11.3,57.608 12.3,51.108 41.8,51.108 58.9,56.508 75.4,74.408 75.4,82.508 58.9,83.508 16)))</screen>

      </refsection>

      <refsection>
        <title>See Also</title>
        <para><xref linkend="ST_ConvexHull"/>, <xref linkend="ST_SimplifyVW"/>, <xref linkend="ST_ConcaveHull"/>, <xref linkend="ST_Segmentize"/></para>
      </refsection>
    </refentry>


    <refentry xml:id="ST_SimplifyVW">
      <refnamediv>
        <refname>ST_SimplifyVW</refname>
        <refpurpose>Returns a simplified representation of a geometry, using the Visvalingam-Whyatt algorithm</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_SimplifyVW</function></funcdef>
            <paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
            <paramdef><type>float</type> <parameter>tolerance</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>
        <para> Returns a simplified representation of a geometry using the
        <link xlink:href="https://en.wikipedia.org/wiki/Visvalingam%E2%80%93Whyatt_algorithm">Visvalingam-Whyatt algorithm</link>.
            The simplification <varname>tolerance</varname> is an area value, in squared units of the input SRS.
            Simplification removes vertices which form "corners" with area less than the tolerance.
            The result may not be valid even if the input is.
            </para>
          <para>
            The function can be called with any kind of geometry (including GeometryCollections),
            but only line and polygon elements are simplified.
            Endpoints of linear geometry are preserved.
            </para>

        <note><para>The returned geometry may lose its simplicity (see <xref linkend="ST_IsSimple"/>),
         topology may not be preserved, and polygonal results may be invalid (see <xref linkend="ST_IsValid"/>).
         Use <xref linkend="ST_SimplifyPreserveTopology"/> to preserve topology and ensure validity.
         <xref linkend="ST_CoverageSimplify"/> also preserves topology and validity.
         </para></note>
          <para>This is a general-purpose simplification function. It may remove narrow polygon spikes when their effective area is below the tolerance, but it is not a dedicated spike-removal or polygon-repair operation. Use <xref linkend="ST_IsValid"/> to check the result and <xref linkend="ST_MakeValid"/> to repair invalid polygonal output if needed.</para>
          <para>This function does not preserve boundaries shared between polygons. Use <xref linkend="ST_CoverageSimplify"/> if this is required.</para>
          <para>This function handles 3D and the third dimension will affect the result.</para>
        <para role="availability" conformance="2.2.0">Availability: 2.2.0</para>
      </refsection>

          <refsection>
            <title>Examples</title>
            <para>This polygon has a narrow spike whose effective area is small enough to be removed by a tolerance of 20 square units.</para>
                <programlisting language="sql">SELECT geom AS original, ST_SimplifyVW(geom, 20) AS simplified
FROM (SELECT 'POLYGON((0 0,10 0,10 10,5.2 10,5 16,4.8 10,0 10,0 0))'::geometry AS geom) AS t;</programlisting>
<screen role="visual-primary visual-overlay text-primary">POLYGON((0 0,10 0,10 10,5.2 10,5 16,4.8 10,0 10,0 0)) | POLYGON((0 0,10 0,10 10,0 10,0 0))</screen>

            <para>A LineString is simplified with a minimum-area tolerance of 30. For a linear simplification using <xref linkend="ST_Simplify"/>, a comparable tolerance would be a length in input-SRS units, so the value here is roughly that linear tolerance squared.</para>
                <programlisting language="sql">
SELECT ST_SimplifyVW(geom, 30) simplified
  FROM (SELECT 'LINESTRING(5 2,3 8,6 20,7 25,10 10)'::geometry AS geom) AS t;</programlisting>
<screen role="visual-primary text-primary">LINESTRING(5 2,7 25,10 10)</screen>

    <para>Simplifying a line.</para>
    <programlisting language="sql">SELECT ST_SimplifyVW('LINESTRING (10 10,50 40,30 70,50 60,70 80,50 110,100 100,90 140,100 180,150 170,170 140,190 90,180 40,110 40,150 20)'::geometry,
1600);</programlisting>
<screen role="visual-primary text-primary">LINESTRING(10 10,100 100,100 180,150 170,190 90,150 20)</screen>

    <para>Simplifying a polygon.</para>
    <programlisting language="sql">SELECT ST_SimplifyVW('POLYGON ((20 20,50 60,20 120,40 170,80 180,120 140,180 180,160 130,180 100,180 30,130 70,150 10,20 20))'::geometry,
1600);</programlisting>
<screen role="visual-primary text-primary">POLYGON((20 20,20 120,80 180,160 130,180 30,20 20))</screen>

          </refsection>
          <refsection>
            <title>See Also</title>
            <para><xref linkend="ST_SetEffectiveArea"/>,
            <xref linkend="ST_Simplify"/>,
            <xref linkend="ST_SimplifyPreserveTopology"/>,
            <xref linkend="ST_CoverageSimplify"/>,
            Topology <xref linkend="TP_ST_Simplify"/></para>
          </refsection>
    </refentry>

    <refentry xml:id="ST_SetEffectiveArea">
      <refnamediv>
        <refname>ST_SetEffectiveArea</refname>
        <refpurpose>
            Sets the effective area for each vertex, using the Visvalingam-Whyatt algorithm.
        </refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_SetEffectiveArea</function></funcdef>
            <paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
            <paramdef><type>float</type> <parameter>threshold = 0</parameter></paramdef>
            <paramdef><type>integer</type> <parameter>set_area = 1</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>
        <para>
            Sets the effective area for each vertex, using the Visvalingam-Whyatt algorithm.
            The effective area is stored as the M-value of the vertex.
            If the optional "threshold" parameter is used, a simplified geometry will be returned, containing only vertices with an effective area
            greater than or equal to the threshold value.
            </para><para>
            This function can be used for server-side simplification when a threshold is specified.  Another option is to use a threshold value of zero.
            In this case, the full geometry will be returned with effective areas as M-values, which can be used by the client to simplify very quickly.
            </para><para>
            Will actually do something only with
            (multi)lines and (multi)polygons but you can safely call it with
            any kind of geometry. Since simplification occurs on a
            object-by-object basis you can also feed a GeometryCollection to
            this function.
            </para>


        <note><para>Note that returned geometry might lose its
                simplicity (see <xref linkend="ST_IsSimple"/>)</para></note>
        <note><para>Note topology may not be preserved and may result in invalid geometries.  Use  (see <xref linkend="ST_SimplifyPreserveTopology"/>) to preserve topology.</para></note>
        <note><para>The output geometry will lose all previous information in the M-values</para></note>
        <note><para>This function handles 3D and the third dimension will affect the effective area</para></note>
        <para role="availability" conformance="2.2.0">Availability: 2.2.0</para>
      </refsection>

          <refsection>
            <title>Examples</title>
            <para>
                Calculating the effective area of a LineString.  Because we use a threshold value of zero, all vertices in the input geometry are returned.
            </para>
                <programlisting>

SELECT ST_SetEffectiveArea(geom) AS all_pts,
       ST_SetEffectiveArea(geom, 30) AS threshold_30
FROM (SELECT  'LINESTRING(5 2,3 8,6 20,7 25,10 10)'::geometry geom) As foo;</programlisting>
<screen role="visual-primary text-primary geometry-output-precision-1 psql-expanded">-[ RECORD 1 ]------------------
all_pts      | LINESTRING M (5 2 3.4e+38,3 8 29,6 20 1.5,7 25 49.5,10 10 3.4e+38)
threshold_30 | LINESTRING M (5 2 3.4e+38,7 25 49.5,10 10 3.4e+38)</screen>
          </refsection>
          <refsection>
            <title>See Also</title>
            <para><xref linkend="ST_SimplifyVW"/></para>
          </refsection>
    </refentry>

    <refentry xml:id="ST_TriangulatePolygon">
      <refnamediv>
        <refname>ST_TriangulatePolygon</refname>
        <refpurpose>Computes the constrained Delaunay triangulation of polygons</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_TriangulatePolygon</function></funcdef>
            <paramdef><type>geometry</type> <parameter>geom</parameter></paramdef>
          </funcprototype>
        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>
        <para>Computes the constrained Delaunay triangulation of polygons.
        Holes and Multipolygons are supported.
        </para>
        <para>
        The "constrained Delaunay triangulation" of a polygon is a set of triangles formed from the vertices of the polygon,
        and covering it exactly, with the maximum total interior angle over all possible triangulations.
        It provides the "best quality" triangulation of the polygon.</para>

        <para role="availability" conformance="3.3.0">Availability: 3.3.0.</para>
        <para role="geos_requirement" conformance="3.11.0">Requires GEOS &gt;= 3.11.0.</para>
      </refsection>

          <refsection>
            <title>Examples</title>
            <para>Triangulation of a square.</para>
                <programlisting>SELECT ST_TriangulatePolygon('POLYGON((0 0,0 1,1 1,1 0,0 0))');</programlisting>
<screen role="visual-primary">GEOMETRYCOLLECTION(POLYGON((0 0,0 1,1 1,0 0)), POLYGON((1 1,1 0,0 0,1 1)))</screen>
            <para>Triangulation of the letter P.</para>
            <programlisting>SELECT ST_TriangulatePolygon('POLYGON ((26 17,31 19,34 21,37 24,38 29,39 43,39 161,38 172,36 176,34 179,30 181,25 183,10 185,10 190,100 190,121 189,139 187,154 182,167 177,177 169,184 161,189 152,190 141,188 128,186 123,184 117,180 113,176 108,170 104,164 101,151 96,136 92,119 89,100 89,86 89,73 89,73 39,74 32,75 27,77 23,79 20,83 18,89 17,106 15,106 10,10 10,10 15,26 17),(152 147,151 152,149 157,146 162,142 166,137 169,132 172,126 175,118 177,109 179,99 180,89 180,80 179,76 178,74 176,73 171,73 100,85 99,91 99,102 99,112 100,121 102,128 104,134 107,139 110,143 114,147 118,149 123,151 128,153 141,152 147))'
);</programlisting>
            <screen role="visual-primary">GEOMETRYCOLLECTION (POLYGON ((10 10, 10 15, 26 17, 10 10)), POLYGON ((25 183, 10 185, 10 190, 25 183)), POLYGON ((126 175, 121 189, 139 187, 126 175)), POLYGON ((137 169, 139 187, 154 182, 137 169)), POLYGON ((149 157, 167 177, 177 169, 149 157)), POLYGON ((153 141, 189 152, 190 141, 153 141)), POLYGON ((153 141, 188 128, 186 123, 153 141)), POLYGON ((186 123, 184 117, 180 113, 186 123)), POLYGON ((149 123, 176 108, 170 104, 149 123)), POLYGON ((147 118, 164 101, 151 96, 147 118)), POLYGON ((121 102, 136 92, 119 89, 121 102)), POLYGON ((85 99, 73 89, 73 100, 85 99)), POLYGON ((89 17, 106 15, 106 10, 89 17)), POLYGON ((83 18, 10 10, 26 17, 83 18)), POLYGON ((100 190, 25 183, 10 190, 100 190)), POLYGON ((121 189, 109 179, 100 190, 121 189)), POLYGON ((189 152, 152 147, 184 161, 189 152)), POLYGON ((153 141, 190 141, 188 128, 153 141)), POLYGON ((147 118, 170 104, 164 101, 147 118)), POLYGON ((139 110, 151 96, 136 92, 139 110)), POLYGON ((73 89, 85 99, 86 89, 73 89)), POLYGON ((83 18, 89 17, 106 10, 83 18)), POLYGON ((83 18, 26 17, 31 19, 83 18)), POLYGON ((100 190, 30 181, 25 183, 100 190)), POLYGON ((189 152, 153 141, 152 147, 189 152)), POLYGON ((176 108, 151 128, 180 113, 176 108)), POLYGON ((91 99, 86 89, 85 99, 91 99)), POLYGON ((10 10, 83 18, 106 10, 10 10)), POLYGON ((76 178, 100 190, 80 179, 76 178)), POLYGON ((86 89, 91 99, 100 89, 86 89)), POLYGON ((79 20, 83 18, 31 19, 79 20)), POLYGON ((102 99, 100 89, 91 99, 102 99)), POLYGON ((34 21, 79 20, 31 19, 34 21)), POLYGON ((112 100, 100 89, 102 99, 112 100)), POLYGON ((37 24, 79 20, 34 21, 37 24)), POLYGON ((100 89, 112 100, 119 89, 100 89)), POLYGON ((79 20, 37 24, 77 23, 79 20)), POLYGON ((119 89, 112 100, 121 102, 119 89)), POLYGON ((77 23, 37 24, 75 27, 77 23)), POLYGON ((136 92, 121 102, 128 104, 136 92)), POLYGON ((38 29, 75 27, 37 24, 38 29)), POLYGON ((134 107, 136 92, 128 104, 134 107)), POLYGON ((75 27, 38 29, 74 32, 75 27)), POLYGON ((139 110, 136 92, 134 107, 139 110)), POLYGON ((74 32, 38 29, 73 39, 74 32)), POLYGON ((151 96, 139 110, 143 114, 151 96)), POLYGON ((39 43, 73 39, 38 29, 39 43)), POLYGON ((151 96, 143 114, 147 118, 151 96)), POLYGON ((73 39, 39 43, 73 89, 73 39)), POLYGON ((170 104, 147 118, 149 123, 170 104)), POLYGON ((73 89, 39 43, 73 100, 73 89)), POLYGON ((176 108, 149 123, 151 128, 176 108)), POLYGON ((39 161, 73 100, 39 43, 39 161)), POLYGON ((180 113, 151 128, 186 123, 180 113)), POLYGON ((73 100, 39 161, 73 171, 73 100)), POLYGON ((186 123, 151 128, 153 141, 186 123)), POLYGON ((38 172, 73 171, 39 161, 38 172)), POLYGON ((151 152, 184 161, 152 147, 151 152)), POLYGON ((73 171, 38 172, 74 176, 73 171)), POLYGON ((184 161, 151 152, 177 169, 184 161)), POLYGON ((36 176, 74 176, 38 172, 36 176)), POLYGON ((149 157, 177 169, 151 152, 149 157)), POLYGON ((34 179, 74 176, 36 176, 34 179)), POLYGON ((146 162, 167 177, 149 157, 146 162)), POLYGON ((74 176, 34 179, 76 178, 74 176)), POLYGON ((167 177, 146 162, 154 182, 167 177)), POLYGON ((30 181, 76 178, 34 179, 30 181)), POLYGON ((154 182, 146 162, 142 166, 154 182)), POLYGON ((100 190, 76 178, 30 181, 100 190)), POLYGON ((154 182, 142 166, 137 169, 154 182)), POLYGON ((80 179, 100 190, 89 180, 80 179)), POLYGON ((139 187, 137 169, 132 172, 139 187)), POLYGON ((100 190, 99 180, 89 180, 100 190)), POLYGON ((139 187, 132 172, 126 175, 139 187)), POLYGON ((100 190, 109 179, 99 180, 100 190)), POLYGON ((121 189, 126 175, 118 177, 121 189)), POLYGON ((121 189, 118 177, 109 179, 121 189)))</screen>
            <para>Triangulation of the polygon used in the <xref linkend="CG_Tesselate"/> example.</para>
            <programlisting language="sql">SELECT ST_TriangulatePolygon('POLYGON (( 10 190,10 70,80 70,80 130,50 160,120 160,120 190,10 190 ))'::geometry
);</programlisting>
<screen role="visual-primary">GEOMETRYCOLLECTION(POLYGON((50 160,120 190,120 160,50 160)),
POLYGON((10 70,80 130,80 70,10 70)),
POLYGON((50 160,10 70,10 190,50 160)),
POLYGON((120 190,50 160,10 190,120 190)),
POLYGON((80 130,10 70,50 160,80 130)))</screen>
        </refsection>

          <refsection>
            <title>See Also</title>
			<para><xref linkend="CG_ConstrainedDelaunayTriangles"/>,
				<xref linkend="ST_DelaunayTriangles"/>,
				<xref linkend="CG_Tesselate"/>
            </para>
          </refsection>
    </refentry>

    <refentry xml:id="ST_VoronoiLines">
      <refnamediv>
        <refname>ST_VoronoiLines</refname>

        <refpurpose>Returns the boundaries of the Voronoi diagram of the vertices of a geometry.</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_VoronoiLines</function></funcdef>
            <paramdef>
                <type>geometry</type> <parameter>geom</parameter>
            </paramdef>
            <paramdef choice="opt">
                <type>float8</type> <parameter>tolerance = 0.0</parameter>
            </paramdef>
            <paramdef choice="opt">
                <type>geometry</type> <parameter>extend_to = NULL</parameter>
            </paramdef>
          </funcprototype>

        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>
        <para>
            Computes a two-dimensional <link xlink:href="https://en.wikipedia.org/wiki/Voronoi_diagram">Voronoi diagram</link> from the vertices of
            the supplied geometry and returns the boundaries between cells in the diagram as a MultiLineString.
            Returns null if input geometry is null. Returns an empty geometry collection if the input geometry contains only one vertex.
            Returns an empty geometry collection if the <varname>extend_to</varname> envelope has zero area.
        </para>
        <para>
            Optional parameters:
            <itemizedlist>
                <listitem>
                    <para> <varname>tolerance</varname>: The distance within which vertices will be considered equivalent.  Robustness of the algorithm can be improved by supplying a nonzero tolerance distance.  (default = 0.0)</para>
                </listitem>
                <listitem>
                    <para> <varname>extend_to</varname>: If present, the diagram is extended to cover the envelope of the supplied geometry,
                    unless smaller than the default envelope (default = NULL, default envelope is the bounding box of the input expanded by about 50%).
                    </para>
                </listitem>
            </itemizedlist>
        </para>
        <para>Performed by the GEOS module.</para>
        <para role="availability" conformance="2.3.0">Availability: 2.3.0</para>
      </refsection>

      <!-- Examples -->
      <refsection>
        <title>Examples</title>

        <para>Voronoi diagram lines with a tolerance of 30 units.</para>
        <programlisting language="sql">
SELECT ST_VoronoiLines('MULTIPOINT (50 30,60 30,100 100,10 150,110 120)'::geometry,
            30) AS geom;
</programlisting>
<screen role="visual-primary text-primary">MULTILINESTRING((135.555555555556 270,36.8181818181818 92.2727272727273),(36.8181818181818 92.2727272727273,-110 43.3333333333333),(230 -45.7142857142858,36.8181818181818 92.2727272727273))
</screen>

      </refsection>

      <!-- Optionally add a "See Also" section -->
      <refsection>
        <title>See Also</title>

        <para>
            <xref linkend="ST_DelaunayTriangles"/>,
            <xref linkend="ST_VoronoiPolygons"/>
        </para>
      </refsection>
    </refentry>

    <refentry xml:id="ST_VoronoiPolygons">
      <refnamediv>
        <refname>ST_VoronoiPolygons</refname>

        <refpurpose>Returns the cells of the Voronoi diagram of the vertices of a geometry.</refpurpose>
      </refnamediv>

      <refsynopsisdiv>
        <funcsynopsis>
          <funcprototype>
            <funcdef>geometry <function>ST_VoronoiPolygons</function></funcdef>
            <paramdef>
                <type>geometry</type> <parameter>geom</parameter>
            </paramdef>
            <paramdef choice="opt">
                <type>float8</type> <parameter>tolerance = 0.0</parameter>
            </paramdef>
            <paramdef choice="opt">
                <type>geometry</type> <parameter>extend_to = NULL</parameter>
            </paramdef>
          </funcprototype>

        </funcsynopsis>
      </refsynopsisdiv>

      <refsection>
        <title>Description</title>

        <para>
            Computes a two-dimensional <link xlink:href="https://en.wikipedia.org/wiki/Voronoi_diagram">Voronoi diagram</link> from the vertices of
            the supplied geometry.
            The result is a GEOMETRYCOLLECTION of POLYGONs that covers an envelope larger than the extent of the input vertices.
            Returns null if input geometry is null. Returns an empty geometry collection if the input geometry contains only one vertex.
            Returns an empty geometry collection if the <varname>extend_to</varname> envelope has zero area.
        </para>

        <para>
            Optional parameters:
            <itemizedlist>
                <listitem>
                    <para> <varname>tolerance</varname>: The distance within which vertices will be considered equivalent.  Robustness of the algorithm can be improved by supplying a nonzero tolerance distance.  (default = 0.0) </para>
                </listitem>
                <listitem>
                    <para> <varname>extend_to</varname>: If present, the diagram is extended to cover the envelope of the supplied geometry,
                    unless smaller than the default envelope (default = NULL, default envelope is the bounding box of the input expanded by about 50%).
                    </para>
                </listitem>
            </itemizedlist>
        </para>
        <para>Performed by the GEOS module.</para>
        <para role="availability" conformance="2.3.0">Availability: 2.3.0</para>
      </refsection>

      <!-- Examples -->
      <refsection>
        <title>Examples</title>

        <para>Points overlaid on top of the Voronoi diagram.</para>
<programlisting language="sql">
SELECT ST_VoronoiPolygons('MULTIPOINT (50 30,60 30,100 100,10 150,110 120)'::geometry
            ) AS geom;
</programlisting>
<screen role="visual-primary">GEOMETRYCOLLECTION(POLYGON((-110 270,100.5 270,59.34782608695652 132.82608695652175,36.81818181818182 92.27272727272727,-110 43.33333333333332,-110 270)),
POLYGON((-110 -90,-110 43.33333333333332,36.81818181818182 92.27272727272727,55 79.28571428571429,55 -90,-110 -90)),
POLYGON((230 -20.71428571428572,55 79.28571428571429,36.81818181818182 92.27272727272727,59.34782608695652 132.82608695652175,230 47.50000000000001,230 -20.71428571428572)), POLYGON((230 -90,55 -90,55 79.28571428571429,230 -20.71428571428572,230 -90)),
POLYGON((230 270,230 47.50000000000001,59.34782608695652 132.82608695652175,100.5 270,230 270)))
</screen>

        <para>Voronoi diagram with a tolerance of 30 units.</para>
<programlisting language="sql">
SELECT ST_VoronoiPolygons('MULTIPOINT (50 30,60 30,100 100,10 150,110 120)'::geometry,
            30) AS geom;
</programlisting>
<screen role="visual-primary">GEOMETRYCOLLECTION(POLYGON((-110 270,135.55555555555557 270,36.81818181818182 92.27272727272727,-110 43.33333333333332,-110 270)),
POLYGON((230 270,230 -45.71428571428574,36.81818181818182 92.27272727272727,135.55555555555557 270,230 270)),
POLYGON((230 -90,-110 -90,-110 43.33333333333332,36.81818181818182 92.27272727272727,230 -45.71428571428574,230 -90)))
</screen>

      </refsection>

      <!-- Optionally add a "See Also" section -->
      <refsection>
        <title>See Also</title>

        <para>
            <xref linkend="ST_DelaunayTriangles"/>,
            <xref linkend="ST_VoronoiLines"/>
        </para>
      </refsection>
    </refentry>
</section>
