[postgis-users] Transformations to RT90 2.5 gon W have a ~200 m error

Lars Luthman larsl at users.sourceforge.net
Thu Mar 31 03:29:10 PST 2005


Hello!

I've just installed PostGIS and created a table which holds point
geometries in both unprojected WGS84 and the Swedish coordinate system
RT90 2.5 gon W. I've created a trigger that transforms the WGS84
geometry to get the RT90 geometry whenever the table is updated:

CREATE OR REPLACE FUNCTION geo_to_rt90() RETURNS "trigger" AS '
BEGIN
IF NEW.point_geo IS NOT NULL THEN
  NEW.point_rt90 = transform(NEW.point_geo, 2400);
END IF;
RETURN NEW;
END;
' LANGUAGE plpgsql;

CREATE TRIGGER trg_points_rt90
    BEFORE INSERT OR UPDATE ON points
    FOR EACH ROW
    EXECUTE PROCEDURE geo_to_rt90();

It works in the sense that it creates the RT90 geometry whenever I
insert or update a row with non-null WGS84 geometry, but the transformed
points appears to be about 200 meters off. Here is a screenshot from
QGIS with a raster layer, the RT90 column, and another vector layer
loaded:

http://www.student.nada.kth.se/~d00-llu/qgis/postgis_rt90.png

 The green diamonds are the same points as the ones in the RT90 column,
but projected from WGS84 using another method - and they are correct.
They line up with the raster layer to within 15 meters (which is an
acceptable error because they are captured with simple handheld GPS
devices). The pink diamonds are the points from the RT90 columns,
transformed by PostGIS, and all of them are about 200 meters SW of the
"real" points.

I have tried both the coordinate systems with SRID 2400 (RT90 2.5 gon W)
and SRID 3021 (RT90 2.5 gon V), they seem to give identical results.

The green diamonds are projected using command line proj and a set of
parameters that someone gave to me, saying that it was an approximation
of RT90 with an error of a few meters within Sweden. The command line is
this:

proj +proj=tmerc +ellps=GRS80 +lon_0="15d48\'22.624306E"
+x_0=1500064.274 +y_0=-667.711 +k=1.00000561024 -r

This projects lat long pairs written on stdin to Y X pairs written on
stdout (except RT90 calls the Y coordinate "X" and the X coordinate
"Y").

Are the RT90 2.5 gon W systems in the spatial_ref_sys table incorrect,
or am I using them incorrectly?

Is there any way to insert my approximation into spatial_ref_sys and use
that instead? I suppose it would have to be changed so it projects long
lat to X Y instead, and I would need some sort of srtext. I really don't
know much about proj or the srtext format though.

-- 
Lars Luthman
PGP key:     http://www.d.kth.se/~d00-llu/pgp_key.php
Fingerprint: FCA7 C790 19B9 322D EB7A  E1B3 4371 4650 04C7 7E2E
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20050331/7b33ab5b/attachment.pgp>


More information about the postgis-users mailing list