You are not logged in.

- Topics: Active | Unanswered

## #1 2021-10-16 08:34:14

**iamzain****Banned**- From: PAKISTAN
- Registered: 2021-10-16
- Posts: 1

### 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

Offline

## #2 2021-10-16 14:57:02

**n76****Member**- Registered: 2013-05-22
- Posts: 309

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

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.

Offline

## #3 2021-10-17 09:47:20

**SK53****Member**- Registered: 2009-01-11
- Posts: 685

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

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

Offline