6

I have imported a CSV containing points with coordinates specified in columns named Latitude and Longitude. How do tell spatialite that these columns are the coordinates of of my points?

1 Answer 1

10

Add first a geometry column into your table with SQL

SELECT AddGeometryColumn('your_table','geometry',4326,'POINT',2);

Then populate the new geometry column by constructing point geometries from your Latitude and Longitude fields with SQL

UPDATE your_table SET geometry = GeomFromText('POINT('||"Longitude"||' '||"Latitude"||')',4326);
3
  • I would never guess this one!
    – fccoelho
    Jul 4, 2014 at 14:14
  • 1
    It is the same in PostGIS (which do have also other alternatives which are easier to write) bostongis.com/postgis_pointfromtext_linefromtext_etc.snippet and the same idea works also with Oracle Spatial so keep it in your mind.
    – user30184
    Jul 4, 2014 at 17:09
  • adding a column with a select statement is a bit counter-intuitive, that's all.
    – fccoelho
    Jul 5, 2014 at 18:39

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.