Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I select Lat & Long coordinates back out of SQL Server Geography data type field

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?

like image 850
ChrisCurrie Avatar asked Aug 08 '14 03:08

ChrisCurrie


People also ask

How do I find my local longitude?

The Earth rotates one full turn (360º of longitude) in one day. It therefore turns one degree of longitude in 1/360th of a day, or every four minutes. To calculate your longitude, you therefore simply need to work out the time difference between noon at your location and noon at the Prime Meridian.

What is my latitude and longitude?

Android: Open Google Maps; it will zoom to your approximate location. Press and hold on the screen to drop a pin marker. Click on the dropped pin; latitude and longitude will be displayed below the map. If you don't have Google Maps, you can install a free GPS app before heading to your site.


2 Answers

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

like image 190
Litisqe Kumar Avatar answered Oct 12 '22 00:10

Litisqe Kumar


Select convert(varchar(max),Coordinates) as Coordinates from SpatialZonePolygons ;

take a look here for more information - SQL Server Geography Data Type

like image 41
Hardik Vinzava Avatar answered Oct 12 '22 00:10

Hardik Vinzava