Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Geometry column: STGeomFromText and SRID (what is an SRID?)

I'm playing with the new geography column in SQL Server 2008 and the STGeomFromText function. Here is my code (works with AdventureWorks2008)

DECLARE @region geography; set @region = geography::STGeomFromText('POLYGON((         -80.0 50.0, -90.0 50.0,         -90.0 25.0, -80.0 25.0,         -80.0 50.0))', 4326);  SELECT @region; 

My question is about the 4326 in the code. It is supposed to be a spacial Reference ID. When I go to MSDN there isn't a lot on it. If I change the value to 56 I get an error telling me the value must be in the sys.spatial_reference_systems table.

You can look at that table by executing:

select * from sys.spatial_reference_systems  

There is a well_known_text column in that table, but it doesn't tell me much. The value for 4326 is:

GEOGCS["WGS 84", DATUM["World Geodetic System 1984", ELLIPSOID["WGS 84", 6378137, 298.257223563]], PRIMEM["Greenwich", 0], UNIT["Degree", 0.0174532925199433]] 

Can anyone explain this mystery to me? What is the SRID?

like image 284
Chris Brandsma Avatar asked Dec 17 '08 03:12

Chris Brandsma


People also ask

What is SRID in geometry?

A spatial reference identifier (SRID) is a unique identifier associated with a specific coordinate system, tolerance, and resolution.

What is SRID used for?

The SRID is used to tell which spatial reference system will be used to interpret each spatial object. A common SRID in use is 4326, which represents spatial data using longitude and latitude coordinates on the Earth's surface as defined in the WGS84 standard, which is also used for the Global Positioning System (GPS).

What is SRID in SQL?

Each spatial instance has a spatial reference identifier (SRID). The SRID corresponds to a spatial reference system based on the specific ellipsoid used for either flat-earth mapping or round-earth mapping. A spatial column can contain objects with different SRIDs.

What does SRID 0 mean?

SRID of 0 doesn't technically exist, it just means no SRID — ie, the default if you forget to set it. Zero is a valid SRID, your PostGIS configurations will set for some default value, that in a fresh installation will be WGS84, srid 4326 .


1 Answers

So I ended up talking with an ex-military guy yesterday who was a radar/mapping specialist. Basically, he knew exactly what that number (4326) was, where it came from, and why it is there.

It is an industry standard for computing geography. The problem is that the earth is not a perfect sphere (it bulges in the middle), and SRID 4326 accounts for that.

As I stated, the table sys.spatial_reference_systems lists all of the code and what they are. But the short version is that you are really only going to use 4326 unless you have a very specific reason to use something different.

like image 142
Chris Brandsma Avatar answered Sep 25 '22 22:09

Chris Brandsma