A spheroid is a representation of a curved surface. A 'lat/lon' or geographic coordinate system is also a representation of a curved surface. When using these coordinate systems, measurements between points are represented in degrees along the curve of the spheroid. To convert this into meters, you need to use the spheroid to calculate the accurate length using a curved line, rather than the shorter straight line that would connect the points on a planar surface.
A projected coordinate system is a flat plane. Lines between points are always straight lines. So calculations done in projected coordinate systems almost always use meters.
- If you don't know what coordinate system your geometry is using, use
select st_srid(geom) to find it.
- If you want a detailed explanation of the srid returned by st_srid, use
select * from spatial_ref_sys where srid = 4326 but replace 4326 with your srid
- If the srid is 0, it means it was never set. You will need to find out what the srid should be and set it using
alter table your_table alter column geom type geometry(linestring,4326) using st_setsrid(geom,4326)
Based on your last comment, your geometry is not using the WGS84 projection, so you are using the incorrect spheroid.
If your geometry is not using a lat/lon coordinate system, it must be using a projected coordinate system. If so, you can simply use
select st_length(geom) to get the length in meters.
If your geometry is, in fact, using a lat/lon coordinate system, use this instead:
This will use the spheroid by default, and returns the length in meters.