In PostGIS there is the ST_Transform() function that can re-project the XY coordinates of Point/Linestring/Polygon/etc to another coordinates system including meters-based projection to a feet-based projection system.

Is there a similar function or method to transform the z-values of vector geometries from meters to feet or vice versa?

I am storing my z-values in my database as meters but sometimes I need to return them in a view as feet z-values

1 Answer 1


You can scale just the Z coordinate with ST_Scale https://postgis.net/docs/ST_Scale.html The first example modified to convert Z values from meters to feet

SELECT ST_AsEWKT(ST_Scale(ST_GeomFromEWKT('LINESTRING(1 2 3, 1 1 1)'), 1, 1, 3.280839895));
LINESTRING(1 2 9.842519685000001,1 1 3.280839895)
  • That answers my question and solves that problem but I one additional note. If one tries it with a ZM geometry and you also need to scale the m/distance value for geocoding, the scale factors have to be used as a point (SELECT ST_AsEWKT(ST_Scale(ST_GeomFromEWKT('LINESTRING(1 2 3 0, 1 1 1 1.3)'), ST_MakePoint(1,1, 3.280839895,3.280839895))); ). Mar 31, 2022 at 15:12
  • Right, just as documented in postgis.net/docs/ST_Scale.html.
    – user30184
    Mar 31, 2022 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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