15

What is the function for getting SRID from Geometry field.

I have inserted a shapefile into SQL Server table with a Geometry field defined. I know the projection of shapefile is Swreff99_1800 (EPSG:3011).

Now my question is How I get this SRID:3011 by using some OGC method of the geometry field?

  • I'm not clear as to what you are needing. Do you need the definition of the SRID 3011 from SQL Server? It sounds like you have already inserted the data with the proper SRID set, yes? – Chad Cooper Feb 7 '12 at 12:54
30

Is this what you are looking for?

select distinct SP_GEOMETRY.STSrid from dbo.MYTABLE

This will give you a table with the different SRID's used in the table dbo.MYTABLE

  • Thanks!. My second question is SRID 3011 is not defined in sys.spatial_reference_systems table. And i need to transform the geometry from SRID 3011 to SRID 4326. What I do then ? – user1899 Feb 7 '12 at 13:41
  • 1
    As far as I know, SQL Server 2008 is not able to transform your geometry data bewteen different coordinate systems - it sees all geometry data as stored in a mathematical coordinate system. – Peter Horsbøll Møller Mar 19 '12 at 20:10
3

After trying the above with no luck, I tried the method below:

select [geomColumnName].STSrid
from [schema].[tableName]

This gives the SRID value for all records in the table. I would assume that since all records SHOULD have the same SRID, that if you wanted to simply get the value for one record it would tell you the SRID for the entire table:

select top 1 [geomColumnName].STSrid
from [schema].[tableName]
  • I'm wondering what version of MS SQL Server you are using and if there has been any change in the later versions that would make the use of Distinct not supported? Or is it just that your Geometry column name isn't SP_GEOMETRY? I have seen a few cases where the Geometry was stored with different SRIDs eventhough they were referring to similar coordinate systems. – Peter Horsbøll Møller Nov 11 '16 at 7:49
  • 1
    @PeterHorsbøllMøller looking at this again, I didn't see that his use of SP_GEOMETRY was referring to the geometry column name, so my answer is almost the same as the accepted... – DPSSpatial Nov 11 '16 at 16:41
0

I believe the number that you'd want to use at this point would be srid 4619 or srid 4977 is SQL server.

These are both equivalent to EPSG 3011.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.