Reputation: 12574
I have a table with some geometry types in and need to be able to return the SRID of a given field. How can I do this. I have had a search but all I can find is the function to alter a SRID. In Oracle I am doing this:
A.CLUSTER_EXTENT.SDO_SRID
Is there an equivalent function in PostGIS?
Upvotes: 30
Views: 46813
Reputation: 706
ST_SRID will give you the SRID of a single geometry. Use Find_SRID for getting the SRID of a column.
Upvotes: 60
Reputation: 13
Figure out SRID of the data
You will notice one of the files it extracts is called TOWNS_POLY.prj
. A .prj
is often included with ESRI shape files and tells you the projection of the data. We'll need to match this descriptive projection to an SRID (the id field of a spatial ref record in the spatial_ref_sys table) if we ever want to reproject our data.
Open up the .prj file in a text editor. You'll see something like NAD_1983_StatePlane_Massachusetts_Mainland_FIPS_2001
and UNIT["Meter",1.0]
Open up your PgAdmin III query tool and type in the following statement
select srid, srtext, proj4text from spatial_ref_sys where srtext ILIKE '%Massachusetts%'
And then click the green arrow. This will bring up about 10 records. Note the srid of the closest match. In this case its 26986.
NOTE: srid is not just a PostGIS term. It is an OGC standard so you will see SRID mentioned a lot in other spatial databases, gis webservices and applications. Most of the common spatial reference systems have globally defined numbers. So 26986 always maps to NAD83_StatePlane_Massachusetts_Mainland_FIPS_2001 Meters. Most if not all MassGIS data is in this particular projection.
Upvotes: -2