SELECT sum(st_length(st_intersection(POLY.geom, LINE.geom))) AS sum_line_length... Is this function OK to calculate the sum of lines length? Wonder if it do the clip line where one line go from one polgon to another or it just sum the line length to polygon from witch the line started? Thanks for answer. Best regards.
? if Postgis tag missing?
geometry ST_Intersection( geometry geomA , geometry geomB ); Description Returns a geometry that represents the point set intersection of the Geometries.
boolean ST_Intersects(geom, geom)
SELECT sum(st_length(LINE.geom))) AS sum_line_length from LINE as LINE , poly as poly WHERE poly.id =1 AND ST_Intersects(poly.geom, LINE.geom)
That would return sum of all lines which intersect polygon in poly table with id 1
If you want to clip line with polygon and get sum of those lines code would be something like yours. im not sure if st_intersections returns line or point collection containing intersection points