Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

PostGIS 1.5.

1 Manual
226 / 315

The original linestrings shown together.

The difference of the two linestrings

--Safe for 2d. This is same geometries as what is shown for st_symdifference
SELECT ST_AsText(
ST_Difference(
ST_GeomFromText(LINESTRING(50 100, 50 200)),
ST_GeomFromText(LINESTRING(50 50, 50 150))
)
);
st_astext
--------LINESTRING(50 150,50 200)

--When used in 3d doesnt quite do the right thing


SELECT ST_AsEWKT(ST_Difference(ST_GeomFromEWKT(MULTIPOINT(-118.58 38.38 5,-118.60 38.329
6,-118.614 38.281 7)), ST_GeomFromEWKT(POINT(-118.614 38.281 5))));
st_asewkt
--------MULTIPOINT(-118.6 38.329 6,-118.58 38.38 5)

See Also
ST_SymDifference

7.9.7 ST_Dump
Name
ST_Dump Returns a set of geometry_dump (geom,path) rows, that make up a geometry g1.

Synopsis
geometry_dump[]ST_Dump(geometry g1);

PostGIS 1.5.1 Manual


227 / 315

Description
This is a set-returning function (SRF). It returns a set of geometry_dump rows, formed by a geometry (geom) and an array of
integers (path). When the input geometry is a simple type (POINT,LINESTRING,POLYGON) a single record will be returned
with an empty path array and the input geometry as geom. When the input geometry is a collection or multi it will return a record
for each of the collection components, and the path will express the position of the component inside the collection.
ST_Dump is useful for expanding geometries. It is the reverse of a GROUP BY in that it creates new rows. For example it can
be use to expand MULTIPOLYGONS into POLYGONS.
Availability: PostGIS 1.0.0RC1. Requires PostgreSQL 7.3 or higher.

Note
Prior to 1.3.4, this function crashes if used with geometries that contain CURVES. This is fixed in 1.3.4+

This function supports 3d and will not drop the z-index.


This method supports Circular Strings and Curves

Examples
SELECT sometable.field1, sometable.field1,
(ST_Dump(sometable.the_geom)).geom AS the_geom
FROM sometable;
--Break a compound curve into its constituent linestrings and circularstrings
SELECT ST_AsEWKT(a.geom), ST_HasArc(a.geom)
FROM ( SELECT (ST_Dump(p_geom)).geom AS geom
FROM (SELECT ST_GeomFromEWKT(COMPOUNDCURVE(CIRCULARSTRING(0 0, 1 1, 1 0),(1 0, 0
1))) AS p_geom) AS b
) AS a;
st_asewkt
| st_hasarc
-----------------------------+---------CIRCULARSTRING(0 0,1 1,1 0) | t
LINESTRING(1 0,0 1)
| f
(2 rows)

See Also
geometry_dump, Section 8.4, ST_Collect, ST_Collect, ST_GeometryN

7.9.8 ST_DumpPoints
Name
ST_DumpPoints Returns a set of geometry_dump (geom,path) rows of all points that make up a geometry.

Synopsis
geometry_dump[]ST_DumpPoints(geometry geom);

You might also like