Using ST_Transform() to get the length of a LineString using SRID 4326

If I cast to text, I get a very small number such as 0.086.:

ST_Length(ST_Transform(geometry, 4326))::text
It seems that this is in geodesic distances.

How would I convert the geodesic distance into meters?

Using ST_Transform() to get the length of a LineString using SRID 4326 returning very small numbers

I am far from an expert on this so there are likely better ways. . .

As I understand it ST_Length() returns the length in the projection units. So using a ST_Length(ST_transform(geometry,*)) would need a * projection that is close to meters for the area of interest. If you are only dealing with a small region and don’t mind hard coding things then you could use the valid UTM projection for that area.

In my case, I needed to clean up the ways some anyway (for distances between junctions) and found the easiest way was to create a separate table/database for normally used for routing. It turns out that osm2pgrouting populates a number of fields including one that is the way length in meters.

You can use a ::geography type-cast operator which will push your underlying geometry into a unified :

SELECT ST_LENGTH(geometry::geography) FROM ...

will return the length in metres. You can compare the result with plain ST_LENGTH to sense check