SpatiaLite GeomFromText() For Linestrings

This is how to create a Linestring connecting two coordinate pairs in SpatiaLite:

spatialite> SELECT AddGeometryColumn ('tablename','line_geom',4326,'LINESTRING',2);
spatialite> UPDATE tablename SET line_geom = LineFromText('LINESTRING('||startx||' '||starty||','||endx||' '||endy||')', 4326);

For a quick test, let’s calculate the length:

spatialite> SELECT GLength(line_geom) FROM tablename LIMIT 5;

Comments are closed.

%d bloggers like this: