I have one polygon layer "polygons" and one line layer "lines". I would like to create a layer with all line parts that are inside the polygon layer. First I cut the lines in the intersection of the polygon layer. I can see that all lines are cut in the intersection of the polygons. then I would like to select the line parts inside the polygon that has a length longer than approximate the double width of the polygon (buffer). First image shows the cutted lines, I've highlighted one line for you to see. the black area is the polygons (buffer).
I use the following sql to select the "inside"-lines:
CREATE TABLE public."insidelines" AS SELECT l.* FROM "lines" l LEFT JOIN "polygons" p ON ST_Contains(p.the_geom, l.the_geom) WHERE p.the_geom IS NOT NULL AND ST_Length(l.the_geom) > 2000; ALTER TABLE public."insidelines" ALTER COLUMN the_geom TYPE geometry(LINESTRING, 32633) USING ST_SetSRID(the_geom, 32633);
the result is:
It is only the yellow line that was found! Any idea why?
Both layers are in UTM 33 (32633). I'm using PostGIS ver 2.5