I have a set of coordinates, that I receive from GPS. I store them in database, its geometry is 4326. I am using the next query to calculate the travelled distance:

ST_length(ST_Transform(st_makeline(points), 26986)) AS distance_travelled

Everything was working fine until i got the next error:

Couldn't project point (741.695 176.355 0): latitude or longitude exceeded limits (-14)

The error is probably due to GPS device malfunction. What is the most efficient and elegant way to filter out the 'out of bounds' points (any alternative to filtering by [180, -180, 90, -90] in WHERE clause) - is there any built in Postgis function that is able to do the filtering based on SRID?

  • 1
    If the device is malfunctioning that badly, I wouldn't trust any information it generated.
    – Vince
    Commented Nov 17, 2015 at 15:37

1 Answer 1


As Vince said, if a GPS is functioning so badly that it doesn't give valid coordinates (rather than simply inaccurate coordinates), I wouldn't trust any of its data. It seems more likely that the data is not in 4326 as you expected. Perhaps you set the table to 4326 when the data it contains is really in 26986 already?

You may also only have a few bad points. Something like the query below should give you an idea as to how many bad coordinates are in the table if it has srid of 4326.

SELECT id, ST_AsText(geom), ST_X(geom), ST_Y(geom)
FROM well 
WHERE ST_X(geom) > 180 
   OR ST_Y(geom) > 90
   OR ST_X(geom) < -180
   OR ST_Y(geom) < -90

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.