# ST_MidPoint function

The ST_MidPoint function takes a curve as an input parameter and returns the point on the curve that is equidistant from both end points of the curve, measured along the curve. The resulting point is represented in the spatial reference system of the given curve.

If the given curve is empty, then an empty point is returned. If the given curve is null, then null is returned.

If the curve contains Z coordinates or M coordinates (measures), the midpoint is determined solely by the values of the X and Y coordinates in the curve. The Z coordinate and measure in the returned point are interpolated.

This function can also be called as a method.

## Syntax

## Parameter

- curve
- A value of type ST_Curve or one of its subtypes that represents the curve for which the point in the middle is returned.

## Return type

db2gse.ST_Point

## Example

This example illustrates the use
of ST_MidPoint for returning the midpoint of curves.

```
SET CURRENT FUNCTION PATH = CURRENT FUNCTION PATH, db2gse
CREATE TABLE sample_lines (id INTEGER, geometry ST_LineString)
INSERT INTO sample_lines (id, geometry)
VALUES (1, ST_LineString ('linestring (0 0, 0 10, 0 20, 0 30, 0 40)', 1 ) )
INSERT INTO sample_lines (id, geometry)
VALUES (2, ST_LineString ('linestring (2 2, 3 5, 3 3, 4 4, 5 5, 6 6)', 1 ) )
INSERT INTO sample_lines (id, geometry)
VALUES (3, ST_LineString ('linestring (0 10, 0 0, 10 0, 10 10)', 1 ) )
INSERT INTO sample_lines (id, geometry)
VALUES (4, ST_LineString ('linestring (0 20, 5 20, 10 20, 15 20)', 1 ) )
SELECT id, CAST( ST_AsText( ST_MidPoint(geometry) ) AS VARCHAR(60) ) MID_POINT
FROM sample_lines
```

Results:

```
ID MID_POINT
---------- ------------------------------------
1 POINT ( 0.00000000 20.00000000)
2 POINT ( 3.00000000 3.45981800)
3 POINT ( 5.00000000 0.00000000)
4 POINT ( 7.50000000 20.00000000)
```