I am writing an SQL query to calculate the length of lines inside a polygon.
SELECT r.*, st_length(st_intersection(r.geometry,b.geometry)) AS Length_Inside
FROM Gen_Line as r, Buffered as b
WHERE st_intersects(r.geometry,b.geometry)
The line file here is 'Gen_Line' and Buffer file is 'Buffered'. The line file has 7 features and polygon file has 1 feature. I am not sure as to why this is not working.
I am writing is query in Virtual Layer, after adding both the files there. The Layer CRS is same for both files as well as output file and is meters based.
The Virtual Layer attribute table is empty, and the line intersects with the polygon. I am attaching a photo below for reference.