MySQL tutorial: ST_GEOMFROMGEOJSON [EN]
top of page
CerebroSQL

MySQL: 

ST_GEOMFROMGEOJSON

ST_GeomFromGeoJSON(str [, options [, srid]])

Parses a string str representing a GeoJSON object and returns a
geometry.

If any argument is NULL, the return value is NULL. If any non-NULL
argument is invalid, an error occurs.

URL: https://dev.mysql.com/doc/refman/8.0/en/spatial-geojson-functions.html

Example

mysql> SET @json = '{ "type": "Point", "coordinates": [102.0, 0.0]}';
mysql> SELECT ST_AsText(ST_GeomFromGeoJSON(@json));
+--------------------------------------+
| ST_AsText(ST_GeomFromGeoJSON(@json)) |
+--------------------------------------+
| POINT(0 102) |
+--------------------------------------+
mysql> SELECT ST_SRID(ST_GeomFromGeoJSON(@json));
+------------------------------------+
| ST_SRID(ST_GeomFromGeoJSON(@json)) |
+------------------------------------+
| 4326 |
+------------------------------------+
mysql> SELECT ST_AsText(ST_SRID(ST_GeomFromGeoJSON(@json),0));
+-------------------------------------------------+
| ST_AsText(ST_SRID(ST_GeomFromGeoJSON(@json),0)) |
+-------------------------------------------------+
| POINT(102 0) |
+-------------------------------------------------+

bottom of page