PostGIS ST_Transform Error – Latitude or Longitude Exceeded Limits(-14)

coordinate systemgeometrypostgispostgresql

I am trying to run a query in PostGres on a multiline spatial feature class table. Among other things, I am trying to use PostGIS to get the shape length of the reprojected geometry. My query looks like this:

SELECT  7 as region, reach_id, study_id, 
        case_no, co_fips, cid, fld_zone,
        validation_status, status_type, miles, 
        ST_Length(ST_Transform(geom,102008)) * 0.000621371 new_miles, 
        status_date, study_type, tier, line_type, 
        bs_zone, bs_stdytyp, bs_prelim_date, bs_lfd_date, geom
FROM data.studies_ln_reg_07

I have run this on multiple similar tables without issue but on this table I get the following error – tranform: latitude or longitude exceeded limits(-14). How can I overcome this issue?

Best Answer

Some of your data is not in 4269 as expected. Maybe it has already been converted to 102008 or else.

You can query all records that are out of bounds:

select * from data.studies_ln_reg_07
where abs(st_x(geom)) > 180 or abs(st_y(geom)>90;

example:

select st_transform(st_setsrid('point(575 90)'::geometry,4269),102008);
ERROR:  transform: latitude or longitude exceeded limits (-14)
Related Question