Pergunta

I would like to find out what is the pragmatic meaning of SRID (spatial reference id) in postgis.

I really do not understand what it is for. Can anyone throw some light on the matter?

For instance I noticed that the postigs function ST_GeomFromText(text WKT, integer srid) accept such an (optional) param as second argument. Why would I need to pass it in the get postigs to turn the text representation into a binary one? What is the value it adds?

Thanks

Foi útil?

Solução 2

This is an example of a query I use. It uses the Lambert azimuthal equal-area projection (ETRS89-LAEA, srid = 3035).

ST_GeomFromText('POINT(2843711.1098048678, 2279498.6551480694)', 3035);

If you don't pass the srid, postgis will not know which spatial reference system to use.

Outras dicas

Spatial reference ID refers to the spatial reference system being employed -- this is important when going from a a geographic view of the world to a projected view of the world, ie, what you see when you look at a 2 dimensional paper map. Spatial reference systems contain a couple of elements.

Firstly, the geoid, is a model of the shape of the earth -- the earth is not a sphere (sh, don't tell Google), it is in fact an oblate spheroid. The geoid shape used for GPS is known as WGS84, which is a model that works faily well globally. National mapping agencies use other geoids, that might be a better fit to local geographies.

Secondly, the projection type. This is essentially the mathematical model used to go from a 3D to a 2D representation of the world. Types include Mercator, Transverse Mercator, (both cylindical), Azimuthal, Conic, etc. All of these have trade-offs between accurately measuring distance, area or direction -- you can't preserve all three.

So, essentially when you declare a SRID in Postgis you are saying use this geoid and this projection model. Under the hood, Postgis uses a library called Proj.4, and based on the SRID information, it can convert from one coordinate system to another.

So, for example, to convert from lat/lon, which is know as 4326 in SRID terms to 900913, which is spherical Mercator, as used by Google/Bing maps, and other web mapping frameworks, you could run something like:

select st_astext(st_transform(st_setsrid(st_makepoint(-.5,52),4326),900913));
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top