My goal here is to take a polygonal area defined in latitude-longitude coordinates (SRID=4326) and translate it to another place on the globe while preserving size and shape. I had thought to use ST_Translate for this as follows:
SELECT ST_AsText(ST_Translate(ST_GeomFromEWKT('SRID=4326;POLYGON((38.436047 -9.103183,38.431081 -9.1005,38.427922 -9.109997,38.432886 -9.112686,38.436047 -9.103183))'),-8.344589,-76.890003)) As wgs_transgeomtxt;
wgs_transgeomtxt
--------------------------------------------------------------------------------------------------------------
POLYGON((30.091458 -85.993186,30.086492 -85.990503,30.083333 -86,30.088297 -86.002689,30.091458 -85.993186))
(1 row)
However, when I compare the side lengths of the resulting polygon versus the original, they are not the same. Using just the first two points:
SELECT ST_Length(the_geog) As length_spheroid, ST_Length(the_geog,false) As length_sphere FROM (SELECT ST_GeographyFromText('SRID=4326;LINESTRING(38.436047 -9.103183,38.431081 -9.1005)') As the_geog) As foo;
length_spheroid | length_sphere
-------------------+-------------------
621.3389574115513 | 621.5250338349151
for the original versus
SELECT ST_Length(the_geog) As length_spheroid, ST_Length(the_geog,false) As length_sphere FROM (SELECT ST_GeographyFromText('SRID=4326;LINESTRING(30.091458 -85.993186,30.086492 -85.990503)') As the_geog) As foo;
length_spheroid | length_sphere
--------------------+--------------------
302.15778025327586 | 300.82283651431646
(1 row)
for the transformed. Is this some artifact of how ST_Translate works and is there a way to correct for it? Or am I using the wrong function entirely?
geographytype'sst_length()– Ian Turton Aug 23 '21 at 15:47