1

I have a PostGIS query that throws an error somewhere down the line:

 SELECT ST_Disjoint(ST_Transform(location, 26910),ST_Buffer(ST_Transform(ST_SetSRID(ST_MakePoint(-121.3991535, 37.7458),4326), 26910), 100))

ERROR:  transform: couldn't project point (19.9597 50.0466 0): latitude or longitude exceeded limits (-14)

There may have been some error in point collection which is causing this error because there are points in location outside of the projection limits .

How can I skip records/points in my query that can't be projected?? In other words, how can I skip records/points that are outside of the projection limits?

1

From http://spatialreference.org/ref/epsg/26910/, it would seem that the lat/lon limits of this projection (nad83 / utm zone 10n) are: -126.0000, 34.4000, -120.0000, 77.0000.

So, one approach would be to use a sub-query or CTE to select only points within these bounds, before passing to ST_Transform, eg,

WITH 
   valid_coords (location) AS (
 SELECT
    location 
   FROM 
     some_table
  WHERE ST_XMin(location) > -126
    AND ST_XMax(location) < -120
    AND ST_YMin(location) > 34
    AND ST_YMax(location) < 77
)
SELECT ST_Transform(ST_SetSRID(location,4326), 26910)
  FROM valid_coords

type thing.

You could probably do this more generically by getting the projection extents from spatial_ref_sys metadata table.

Also, I did notice that it is possible to put some very invalid coordinates into such a transform before getting the error you reported. However, assuming that you really are working with nad83 / utm zone 10n,then the above should work.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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