04 July 2012

Well Known Text (WTK) and Coordinates in Geography Objects

I’ve been working with MS-SQL Spatial objects lately and specially for Geography objects documentation seems to be somewhat erratic; specifically which number in a Well Known Text (WKT) string definition is the latitude and which is the longitude.

Points in WKT for Geography coordinates are defined “longitude latitude”.
This makes some sense as it corresponds to the “X Y” representation of coordinates of Geometry object, longitude being marked on the X axis and latitude on the Y axis of a North on top map, except, it doesn’t.
That’s because everywhere else coordinates are usually represented “latitude longitude” even in the Geography classes themselves.
The signaure of the factory method for Geography Points is:

public static SqlGeography Point(
double latitude,
double longitude,
int srid

For example:

SqlGeography.Point(-30, 10, 4326);

is the same as:

SqlGeometry.STPointFromText("POINT (10 -30)");

Bonus fact:

When specifying geographic boundaries as Geography Polygons the points should be specified counter-clockwise.

No comments:

Post a Comment