Lon/Lat Order when using spatial POINT type with MySQL

as one can see here https://stackoverflow.com/a/5757054/1393681 the order is (lon lat).

lon is basicly the y axis and lat the x if i look at my globe, but the lon's are traveling along the x axis and the lat's along the y axis so i think thats the reason why you use (lon lat)

Despite that, if you stay consistent in your application it shoudn't matter if the world is flipped inside your db ;-)


Seems like lat lon to me. You can check this from your mysql shell:

mysql> SELECT ST_ASTEXT(coords), ST_LONGITUDE(coords), ST_LATITUDE(coords) FROM table;

+----------------------------+-----------------------+----------------------+
| ST_ASTEXT(coords)          | ST_LONGITUDE(coords)  | ST_LATITUDE(coords)  |
+----------------------------+-----------------------+----------------------+
| POINT(33.520571 -18.20072) | -18.20072             | 33.520571            |
+----------------------------+-----------------------+----------------------+

Note: SRID 4326 used.

See also: https://dev.mysql.com/doc/refman/8.0/en/gis-point-property-functions.html#function_st-latitude

Tags:

Mysql

Point