Processing functions
Lindorm GanosBase provides spatial processing functions for geometry construction, set operations, and geometry repair. All functions described on this page apply to all versions of LindormTable.
Functions
| Function | Description |
|---|---|
ST_Buffer | Returns a buffer geometry consisting of all points whose 2D distance from the source geometry equals the specified radius. |
ST_BufferSphere | Returns a buffer geometry consisting of all points whose spherical distance from the source geometry equals the specified radius. |
ST_Collect | Combines two or more geometry objects into a MultiPoint, MultiLineString, MultiPolygon, or GeometryCollection object without modifying the inputs. |
ST_Difference | Returns the part of the first geometry that does not intersect the second geometry. |
ST_Intersection | Returns the part where the first geometry intersects the second geometry. |
ST_MinimumBoundingCircle | Returns a polygon approximating the smallest circle that fully contains the input geometry. |
ST_MinimumBoundingRadius | Returns the radius of the smallest circle that fully contains the input geometry. |
ST_MakeValid | Converts an invalid geometry to a valid geometry. |
ST_Union | Returns the geometric union of two or more geometry objects. |
ST_Buffer
Returns a buffer geometry consisting of all points whose 2D distance from the source geometry equals the specified radius.
Syntax
ST_Buffer(geometry g, double radius)Parameters
| Parameter | Description |
|---|---|
g | The source geometry. All distances are measured from this object. |
radius | The 2D distance from the source geometry to the buffer boundary. Unit: degree. |
Usage notes
Supported geometry types: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection.
A positive
radiusexpands the buffer outward from the source geometry. A negativeradiusshrinks it inward toward the center of the source geometry. The returned geometry may be empty.Only the default buffer style is supported. The values are:
quadrantSegments = 8(number of line segments per quarter circle)endCapStyle = round
Examples
Example 1: Buffer around a point.
SELECT ST_AsText(ST_Buffer(ST_GeomFromText('POINT(120.18 30.25)'), 0.05)) AS buffer;Result:
+--------------------------------+
| buffer |
+--------------------------------+
| POLYGON ((120.23 30.25, |
| 120.22903926402017 |
| 30.240245483899194, |
| 120.22619397662557 |
| 30.230865828381745, |
| 120.22157348061513 |
| 30.22222148834902, |
| 120.21535533905933 |
| 30.21464466094067, |
| 120.20777851165099 |
| 30.208426519384872, |
| 120.19913417161825 |
| 30.203806023374437, |
| 120.18975451610082 |
| 30.200960735979837, 120.18 |
| 30.2, 120.1702454838992 |
| 30.200960735979837, |
| 120.16086582838176 |
| 30.203806023374437, |
| 120.15222148834903 |
| 30.208426519384872, |
| 120.14464466094068 |
| 30.21464466094067, |
| 120.13842651938488 |
| 30.22222148834902, |
| 120.13380602337445 |
| 30.230865828381745, |
| 120.13096073597984 |
| 30.240245483899194, |
| 120.13000000000001 |
| 30.25, 120.13096073597984 |
| 30.259754516100806, |
| 120.13380602337445 |
| 30.269134171618255, |
| 120.13842651938488 |
| 30.27777851165098, |
| 120.14464466094068 |
| 30.28535533905933, |
| 120.15222148834903 |
| 30.291573480615128, |
| 120.16086582838176 |
| 30.296193976625563, |
| 120.1702454838992 |
| 30.299039264020163, 120.18 |
| 30.3, 120.18975451610082 |
| 30.299039264020163, |
| 120.19913417161825 |
| 30.296193976625563, |
| 120.20777851165099 |
| 30.291573480615128, |
| 120.21535533905933 |
| 30.28535533905933, |
| 120.22157348061513 |
| 30.27777851165098, |
| 120.22619397662557 |
| 30.269134171618255, |
| 120.22903926402017 |
| 30.259754516100806, 120.23 |
| 30.25)) |
+--------------------------------+Example 2: Buffer around a line segment.
SELECT ST_AsText(ST_Buffer(ST_GeomFromText('LINESTRING (120.18 30.25, 120.16 30.23)'), 0.01)) AS buffer;Result:
+--------------------------------+
| buffer |
+--------------------------------+
| POLYGON ((120.16707106781186 |
| 30.222928932188132, |
| 120.1655557023302 |
| 30.221685303876974, |
| 120.16382683432364 |
| 30.220761204674886, |
| 120.16195090322016 |
| 30.220192147195966, 120.16 |
| 30.22, 120.15804909677983 |
| 30.22019214719597, |
| 120.15617316567635 |
| 30.22076120467489, |
| 120.1544442976698 |
| 30.221685303876978, |
| 120.15292893218813 |
| 30.222928932188136, |
| 120.15168530387697 |
| 30.224444297669805, |
| 120.15076120467488 |
| 30.226173165676354, |
| 120.15019214719597 |
| 30.22804909677984, |
| 120.14999999999999 |
| 30.230000000000004, |
| 120.15019214719597 |
| 30.231950903220163, |
| 120.15076120467488 |
| 30.233826834323654, |
| 120.15168530387697 |
| 30.2355557023302, |
| 120.15292893218813 |
| 30.23707106781187, |
| 120.17292893218814 |
| 30.257071067811868, |
| 120.17444429766981 |
| 30.258314696123026, |
| 120.17617316567636 |
| 30.259238795325114, |
| 120.17804909677984 |
| 30.259807852804034, 120.18 |
| 30.26, 120.18195090322017 |
| 30.25980785280403, |
| 120.18382683432365 |
| 30.25923879532511, |
| 120.1855557023302 |
| 30.258314696123023, |
| 120.18707106781187 |
| 30.257071067811864, |
| 120.18831469612303 |
| 30.255555702330195, |
| 120.18923879532512 |
| 30.253826834323647, |
| 120.18980785280404 |
| 30.25195090322016, |
| 120.19000000000001 |
| 30.249999999999996, |
| 120.18980785280404 |
| 30.248049096779837, |
| 120.18923879532512 |
| 30.246173165676346, |
| 120.18831469612303 |
| 30.2444442976698, |
| 120.18707106781187 |
| 30.242928932188132, |
| 120.16707106781186 |
| 30.222928932188132)) |
+--------------------------------+ST_BufferSphere
Returns a buffer geometry consisting of all points whose spherical distance from the source geometry equals the specified radius.
Syntax
ST_BufferSphere(geometry g, double radius)Parameters
| Parameter | Description |
|---|---|
g | The source geometry. All distances are measured from this object along the sphere surface. |
radius | The spherical distance from the source geometry to the buffer boundary. Unit: meter. |
Usage notes
Supported geometry types: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection.
A positive
radiusexpands the buffer outward. A negativeradiusshrinks it inward toward the center of the source geometry. The returned geometry may be empty.Only the default buffer style is supported. The values are:
quadrantSegments = 8(number of line segments per quarter circle)endCapStyle = round
Examples
Example 1: 500-meter buffer around a point.
SELECT ST_AsText(ST_BufferSphere(ST_GeomFromText('POINT(120.18 30.25)'), 500)) AS buffer;Result:
+--------------------------------+
| buffer |
+--------------------------------+
| POLYGON ((120.1851909310331 |
| 30.25011173053024, |
| 120.18511627294788 |
| 30.249230378090658, |
| 120.18484500297895 |
| 30.248378605521545, |
| 120.18438755060062 |
| 30.247589145091563, |
| 120.1837614989031 |
| 30.246892333708224, |
| 120.18299090835872 |
| 30.24631494733322, |
| 120.18210539193977 |
| 30.245879172318283, |
| 120.18113897716789 |
| 30.24560175314354, |
| 120.18012879881775 |
| 30.245493349257533, |
| 120.17911367245745 |
| 30.245558125686234, |
| 120.17813260355221 |
| 30.245793593106626, |
| 120.17722328930826 |
| 30.246190703510113, |
| 120.17642067070908 |
| 30.24673419777976, |
| 120.17575559027851 |
| 30.247403191844143, |
| 120.17525360707266 |
| 30.248171978919647, |
| 120.1749340144007 |
| 30.249011017060198, |
| 120.17480909803247 |
| 30.249888064116504, |
| 120.17488366345407 |
| 30.250769416537622, |
| 120.17515485043153 |
| 30.251621204446096, |
| 120.17561224212514 |
| 30.252410693237966, |
| 120.17623826468355 |
| 30.253107541687907, |
| 120.17700886207045 |
| 30.253684968191145, |
| 120.17789442027193 |
| 30.254120780286797, |
| 120.1788609054053 |
| 30.25439822784955, |
| 120.17987117198402 |
| 30.25450664710903, |
| 120.18088639100795 |
| 30.254441870698788, |
| 120.18186754290468 |
| 30.254206387939035, |
| 120.1827769178333 |
| 30.25380924917365, |
| 120.1835795655716 |
| 30.253265717837415, |
| 120.1842446391596 |
| 30.252596683644782, |
| 120.18474658058295 |
| 30.251827859488568, |
| 120.18506610289342 |
| 30.250988792960012, |
| 120.1851909310331 |
| 30.25011173053024)) |
+--------------------------------+Example 2: 20-meter buffer around a line segment.
SELECT ST_AsText(ST_BufferSphere(ST_GeomFromText('LINESTRING (120.18 30.25, 120.16 30.23)'), 20)) AS buffer;Result:
+--------------------------------+
| buffer |
+--------------------------------+
| POLYGON ((120.1601568095326 |
| 30.229881789491696, |
| 120.16012723865646 |
| 30.22985749603038, |
| 120.16009277809007 |
| 30.229838678911875, |
| 120.16005475213065 |
| 30.229826061263992, |
| 120.16001462208855 |
| 30.22982012797305, |
| 120.15997393013107 |
| 30.229821107050387, |
| 120.15993424001891 |
| 30.22982896087028, |
| 120.15989707701289 |
| 30.229843387615915, |
| 120.15986386926043 |
| 30.229863832877875, |
| 120.15983589291346 |
| 30.229889510959428, |
| 120.15981422308717 |
| 30.229919435069952, |
| 120.15979969254388 |
| 30.22995245524614, |
| 120.15979285969011 |
| 30.22998730254394, |
| 120.15979398711634 |
| 30.23002263780298, |
| 120.15980303150468 |
| 30.230057103109367, |
| 120.15981964529222 |
| 30.230089373979652, |
| 120.15984319002649 |
| 30.230118210260056, |
| 120.17984317814214 |
| 30.250118233425205, |
| 120.17987275990819 |
| 30.250142523059253, |
| 120.17990723145967 |
| 30.250161335607235, |
| 120.17994526807108 |
| 30.250173948109982, |
| 120.17998540801094 |
| 30.250179875873307, |
| 120.18002610871608 |
| 30.25017889109486, |
| 120.18006580607275 |
| 30.25017103161881, |
| 120.18010297452594 |
| 30.250156599481485, |
| 120.18013618570674 |
| 30.25013614930418, |
| 120.18016416332479 |
| 30.25011046697896, |
| 120.18018583221566 |
| 30.250080539466826, |
| 120.18020035965924 |
| 30.250047516868772, |
| 120.18020718737982 |
| 30.25001266822753, |
| 120.18020605299972 |
| 30.249977332758547, |
| 120.18019700012098 |
| 30.2499428683844, |
| 120.18018037664854 |
| 30.249910599550603, |
| 120.1801568214192 |
| 30.249881766327974, |
| 120.1601568095326 |
| 30.229881789491696)) |
+--------------------------------+ST_Collect
Combines two or more geometry objects into a collection without modifying or merging the inputs.
ST_Collect aggregates geometries as-is. It does not dissolve shared boundaries or check for overlaps. For geometric merging, use ST_Union.
Syntax
ST_Collect(geometry geomA, geometry geomB)
ST_Collect(geometry geomA, geometry geomB, ..., geometry geomN)Parameters
| Parameter | Description |
|---|---|
geomA | The first geometry object. |
geomB | The second geometry object. |
geomN | Additional geometry objects (for three or more inputs). |
Usage notes
The return type is MultiPoint, MultiLineString, MultiPolygon, or GeometryCollection. These types can be read but cannot be written by Lindorm GanosBase SQL.
ST_Collectis generally faster thanST_Unionbecause it does not split geometry boundaries or check for overlaps in MultiPolygon inputs.Key difference from
ST_Union:ST_Collectnever dissolves boundaries or splits LineStrings at intersections.ST_Uniondoes both, and may return a single geometry rather than a collection.
Examples
Example 1: Collect two points into a MultiPoint.
SELECT ST_AsText(ST_Collect(ST_MakePoint(0,0), ST_MakePoint(0,1))) AS g;Result:
+---------------------------+
| g |
+---------------------------+
| MULTIPOINT ((0 0), (0 1)) |
+---------------------------+Example 2: Collect a point and a line into a GeometryCollection.
SELECT ST_AsText(ST_Collect(ST_MakePoint(0,0), ST_GeomFromText('LINESTRING(0 2,0 3)'))) AS g;Result:
+--------------------------------+
| g |
+--------------------------------+
| GEOMETRYCOLLECTION (POINT (0 |
| 0), LINESTRING (0 2, 0 3)) |
+--------------------------------+ST_Difference
Returns the part of geomA that does not intersect geomB.
Syntax
ST_Difference(geometry geomA, geometry geomB)Parameters
| Parameter | Description |
|---|---|
geomA | The geometry to subtract from. |
geomB | The geometry to subtract. |
Usage notes
Supported geometry types: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection.
If
geomAis empty or is fully contained bygeomB, an empty geometry is returned.Input order matters:
ST_Difference(A, B)andST_Difference(B, A)produce different results.If a polygon has self-intersecting edges, the function may not return a result.
Example
SELECT ST_AsText(ST_Difference(
ST_GeomFromText('LINESTRING(50 100, 50 200)'),
ST_GeomFromText('LINESTRING(50 50, 50 150)')
)) AS diff;Result:
+-----------------------------+
| diff |
+-----------------------------+
| LINESTRING (50 150, 50 200) |
+-----------------------------+ST_Intersection
Returns the geometry representing the shared area between geomA and geomB.
Syntax
ST_Intersection(geometry geomA, geometry geomB)Parameters
| Parameter | Description |
|---|---|
geomA | The first geometry object. |
geomB | The second geometry object. |
Usage notes
Supported geometry types: Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection.
If either input is empty, an empty geometry is returned.
If a polygon has self-intersecting edges, the function may not return a result.
Example
SELECT ST_AsText(ST_Intersection(
ST_GeomFromText('POINT(0 0)'),
ST_GeomFromText('LINESTRING ( 0 0, 0 2 )')
)) AS inter;Result:
+-------------+
| inter |
+-------------+
| POINT (0 0) |
+-------------+ST_MinimumBoundingCircle
Returns a polygon that approximates the smallest circle fully containing the input geometry.
The returned value is a polygon, not a true circle. Each quarter of the approximated circle is divided into 8 line segments (32 segments total). For an exact radius value instead of the circle polygon, use ST_MinimumBoundingRadius.
Syntax
ST_MinimumBoundingCircle(geometry g)Parameters
| Parameter | Description |
|---|---|
g | The geometry to enclose. |
Usage notes
Best suited for MultiPoint, MultiLineString, MultiPolygon, and GeometryCollection inputs.
This is not an aggregate function. To get the minimum bounding circle of a set of geometries, combine it with
ST_Collect:ST_MinimumBoundingCircle(ST_Collect(geomA, geomB, geomC, ...)).
Example
SELECT ST_AsText(ST_MinimumBoundingCircle(ST_GeomFromText('POLYGON((0 0,1 0,1 1,0 1,0 0))'))) AS g;Result:
+--------------------------------+
| g |
+--------------------------------+
| POLYGON ((1.2071067811865475 |
| 0.5, 1.1935199226610738 |
| 0.3620503103585285, |
| 1.1532814824381883 |
| 0.2294019499269015, |
| 1.0879378012096794 |
| 0.1071525208064489, 1 |
| 0, 0.8928474791935512 |
| -0.0879378012096794, |
| 0.7705980500730986 |
| -0.1532814824381883, |
| 0.6379496896414716 |
| -0.1935199226610738, |
| 0.5 -0.2071067811865476, |
| 0.3620503103585285 |
| -0.1935199226610738, |
| 0.2294019499269015 |
| -0.1532814824381883, |
| 0.107152520806449 |
| -0.0879378012096794, |
| 0 -0.0000000000000001, |
| -0.0879378012096794 |
| 0.1071525208064489, |
| -0.1532814824381883 |
| 0.2294019499269014, |
| -0.1935199226610738 |
| 0.3620503103585282, |
| -0.2071067811865476 |
| 0.4999999999999999, |
| -0.1935199226610738 |
| 0.6379496896414716, |
| -0.1532814824381884 |
| 0.7705980500730985, |
| -0.0879378012096795 |
| 0.892847479193551, |
| -0.0000000000000001 |
| 1, 0.1071525208064489 |
| 1.0879378012096794, |
| 0.2294019499269011 |
| 1.1532814824381883, |
| 0.3620503103585282 |
| 1.1935199226610735, |
| 0.4999999999999999 |
| 1.2071067811865475, |
| 0.6379496896414716 |
| 1.1935199226610738, |
| 0.7705980500730987 |
| 1.1532814824381883, |
| 0.8928474791935508 |
| 1.0879378012096796, |
| 0.9999999999999999 |
| 1, 1.0879378012096794 |
| 0.892847479193551, |
| 1.1532814824381883 |
| 0.7705980500730989, |
| 1.1935199226610735 |
| 0.6379496896414718, |
| 1.2071067811865475 0.5)) |
+--------------------------------+ST_MinimumBoundingRadius
Returns the radius of the smallest circle that fully contains the input geometry.
Use this function when you need an exact radius value. To get the circle polygon itself, use ST_MinimumBoundingCircle.
Syntax
ST_MinimumBoundingRadius(geometry g)Parameters
| Parameter | Description |
|---|---|
g | The geometry to enclose. |
Usage notes
Returns a DOUBLE value with up to 16 decimal places.
To get the minimum bounding radius of a set of geometries, combine with
ST_Collect:ST_MinimumBoundingRadius(ST_Collect(geomA, geomB, ...)).
Example
SELECT ST_MinimumBoundingRadius(ST_GeomFromText('POLYGON((0 1,-1 0,0 -1,1 0,0 1))')) AS radius;Result:
+----------+
| radius |
+----------+
| 1.0 |
+----------+ST_MakeValid
Converts an invalid geometry to a valid geometry.
Syntax
geometry ST_MakeValid(geometry g)Parameters
| Parameter | Description |
|---|---|
g | The invalid geometry to repair. |
Usage notes
A self-intersecting Polygon is split into a MultiPolygon made up of non-self-intersecting Polygon objects.
A MultiPolygon with overlapping Polygon objects is merged into a single Polygon representing their union.
Examples
Example 1: Repair a self-intersecting polygon.
SELECT ST_AsText(geom) AS original, ST_AsText(ST_MakeValid(geom)) AS validated
FROM mapdata
WHERE id = 10000001;Result:
+--------------------------------+--------------------------------+
| original | validated |
+--------------------------------+--------------------------------+
| POLYGON ((0 0, 10 10, 0 10, 10 | MULTIPOLYGON (((0 0, 5 5, 10 |
| 0, 0 0)) | 0, 0 0)), ((5 5, 0 10, 10 10, |
| | 5 5))) |
+--------------------------------+--------------------------------+Example 2: Merge overlapping polygons into one.
SELECT ST_AsText(geom) AS original, ST_AsText(ST_MakeValid(geom)) AS validated
FROM mapdata
WHERE adcode = 10000002;Result:
+--------------------------------+--------------------------------+
| original | validated |
+--------------------------------+--------------------------------+
| MULTIPOLYGON (((0 0, 5 6, 10 | POLYGON ((4.166666666666667 |
| 0, 0 0)), ((5 4, 0 10, 10 10, | 5, 0 10, 10 10, |
| 5 4))) | 5.833333333333333 5, 10 0, 0 |
| | 0, 4.166666666666667 5)) |
+--------------------------------+--------------------------------+ST_Union
Returns the geometric union of two or more geometry objects. Shared boundaries are dissolved and overlapping areas are merged.
Syntax
-- Two geometry objects
ST_Union(geometry g1, geometry g2)
-- Three or more geometry objects
ST_Union(geometry g1, geometry g2, ..., geometry gn)Parameters
| Parameter | Description |
|---|---|
g1 | The first geometry object. |
g2 | The second geometry object. |
gn | Additional geometry objects (for three or more inputs). |
Usage notes
Supported geometry types: Point, LineString, and Polygon.
Two-input behavior: Returns a single geometry, MultiPoint, MultiLineString, MultiPolygon, or GeometryCollection. If either input is NULL, the function returns NULL. If either input is empty, the function returns the other geometry.
Three-or-more-input behavior: Returns a single geometry or a Multi* object.
ST_Collectis generally faster thanST_Unionfor combining geometries without needing boundary dissolution.If a polygon has self-intersecting edges, the function may not return a result.
Example
SELECT ST_AsText(ST_Union(ST_MakePoint(1.0, 1.0), ST_MakePoint(2.0, 2.0))) AS u;Result:
+---------------------------+
| u |
+---------------------------+
| MULTIPOINT ((1 1), (2 2)) |
+---------------------------+