How do I select Lat & Long coordinates back out of SQL Server Geography data type field
18,604
Solution 1
Select convert(varchar(max),Coordinates) as Coordinates from SpatialZonePolygons ;
take a look here for more information - SQL Server Geography Data Type
Solution 2
You may use something like this(SQL SERVER)
SELECT Coordinates.Lat 'Latitude', Coordinates.Long 'Longitude' FROM SpatialZonePolygons
For more information - How To Get Lat-Long From Geography Data Type
Author by
ChrisCurrie
Software Delivery Project Manager (and casual developer).
Updated on June 07, 2022Comments
-
ChrisCurrie about 2 years
Considering the SQL Server 'geography' data type...
I can enter an array of latitude and longitude (btw is that the correct order to do so or should it be longitude latitude?) points into the field as follows:
INSERT INTO SpatialZonePolygons (Coordinates) VALUES (geography::STGeomFromText('POLYGON((-122.358 47.653 , -122.348 47.649, -122.348 47.658, -122.358 47.658, -122.358 47.653))', 4326)); GO
This then appears as:
0xE6100000010405000000DD24068195D34740F4FDD478E9965EC0508D976E12D3474083C0CAA145965EC04E62105839D4474083C0CAA145965EC04E62105839D44740F4FDD478E9965EC0DD24068195D34740F4FDD478E9965EC001000000020000000001000000FFFFFFFF0000000003
How do I select them back into their latitude and longitude formats?