Calculate Lat / Lon values in a Spatialite point layer

26 views
Skip to first unread message

cesare gerbino

unread,
Apr 18, 2017, 4:00:13 PM4/18/17
to SpatiaLite Users
Hi all!

I've a point layer in Spatialite in EPSG32632 system reference.

Then I've added two columns to calculate x, y coordinates in this way

ALTER TABLE points ADD COLUMN X REAL
ALTER TABLE points ADD COLUMN Y REAL


and calculate the coordinates in this way

SELECT load_extension('mod_spatialite');
UPDATE points SET X
=ST_X("Geometry") , Y=ST_Y("Geometry")


Now I need to calculate the Lat, Lon values too.

I've tried this:

ALTER TABLE points ADD COLUMN LON REAL;
ALTER TABLE points ADD COLUMN LAT REAL
;
UPDATE points SET LON
=ST_X(ST_Transform(geometry,4326));
UPDATE points SET LAT
=ST_Y(ST_Transform(geometry,4326));


No errors in the execution but if I try

select X,Y,LON,LAT from points;


the result is


492051.358020695|4927339.50750624||
488162.133600385|4919734.42606608||
527761.520720489|4906898.57798871||

so, LON and LAT are empty.

Suggestions? Thank you in advance!

Cesare

cesare gerbino

unread,
Apr 18, 2017, 4:38:29 PM4/18/17
to SpatiaLite Users
I've solved! 
The problema was that in geometry_columns my point layer was registered as "0" as srid. 

Changing this to "32632" all work fine.

Sorry for my mistake!
Reply all
Reply to author
Forward
0 new messages