I'm trying to transform my longitude and latitude column in PostgreSQL, into PostGIS geometry point. (address in LA area)
This is the sample:(-118.373258481016618, 34.712161771785425) // longitude, latitude
When I run this Command:
SET geometry =
ST_Transform(ST_SetSRID(ST_MakePoint(longitude, latitude), 4326),
2227);
I would have this
Terminal Error :
Executing (default): UPDATE myTable SET geometry =
ST_Transform(ST_SetSRID(ST_MakePoint(longitude, latitude), 4326),
2227); Unhandled rejection SequelizeDatabaseError: transform: couldn't
project point (-118.001 -1.4873e+008 0): latitude or longitude
exceeded limits (-14)
I know the command works because, if I hard code in latitude like this:
UPDATE crime_la_counties SET geometry =
ST_Transform(ST_SetSRID(ST_MakePoint(longitude, 34.095360134448367), 4326),
2227);
It's sort of working, and I can see my points in QGIS like this:
(It's a line because I hard coded in latitude).
Anyone knows what went wrong with latitude column?
The column type currently is numeric.
I also tried to trunc + round latitude:
SELECT trunc( CAST("latitude" as numeric), 8) FROM myTable;
SELECT round( CAST("latitude" as numeric), 8) FROM myTable;
It didn't work either…
version:
QGIS 2.3.3
PG Admin4
psql (PostgreSQL) 9.6.5
UPDATE:
After I type in:
select min(latitude), max(latitude) from crime_la_counties
I got this:
so trying to filter the raw data now… in progress
Best Answer
The problem was solved by doing : select min(latitude), max(latitude) from mytable; according to – Mike T 's anwer.
We found multiple data in latitude that were random negative numbers. So the solution was using conditional DELETE: