ST_POINT
Descriptionβ
Creates a Point geometry object from the given X and Y coordinates. In geospatial contexts, X/Y typically represent longitude and latitude respectively,
Sytaxβ
ST_POINT( <x>, <y>)
Parametersβ
Parameter | Description |
---|---|
<x> | X-coordinate (longitude) of the point, range: -180.0 to 180.0 (degrees) |
<y> | Y-coordinate (latitude) of the point, range: -90.0 to 90.0 (degrees)οΌ |
Return valueβ
Returns a Point geometry object representing a 2D coordinate.
- Returns NULL if
or exceeds valid longitude/latitude ranges. - Returns NULL if either parameter is NULL.
Exampleβ
Valid Coordinates
SELECT ST_AsText(ST_Point(24.7, 56.7));
+---------------------------------+
| st_astext(st_point(24.7, 56.7)) |
+---------------------------------+
| POINT (24.7 56.7) |
+---------------------------------+
Invalid Longitude (Out of Range)
mysql> SELECT ST_Point(200, 50);
+-------------------+
| ST_Point(200, 50) |
+-------------------+
| NULL |
+-------------------+
Invalid Latitude (Out of Range)
mysql> SELECT ST_Point(116, -100);
+---------------------+
| ST_Point(116, -100) |
+---------------------+
| NULL |
+---------------------+
Any parameter NULL
mysql> SELECT ST_Point(NULL, 50);
+--------------------+
| ST_Point(NULL, 50) |
+--------------------+
| NULL |
+--------------------+
mysql> SELECT ST_Point(50, NULL);
+--------------------+
| ST_Point(50, NULL) |
+--------------------+
| NULL |
+--------------------+