Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL selecting spatial points

I am trying to select a spatial point in SQL so that I can receive the latitude and coordinate of the point in the most simple form possible.

Currently my query looks like this:

SELECT AsText(`coordinates`) FROM table

This returns something along the lines of:

POINT(53.432985 -1.357258)

Are there any other spatial functions that will allow me to return these as two seperate values or at least make them a little easier to perform something like substr on them?

Ideally I'd like it to return two values, a latitude value and a longitude value

like image 804
jskidd3 Avatar asked Jan 12 '14 16:01

jskidd3


1 Answers

This is the geospatial way to retrieve latitude/longitude from a POINT type, assuming that coordinates is stored as a POINT type. X will return the latitude and Y the longitude.

SELECT X(coordinates),Y(coordinates) FROM table
like image 133
Andrew - OpenGeoCode Avatar answered Sep 21 '22 18:09

Andrew - OpenGeoCode