Geographic Information Systems Asked on September 26, 2021
I have two shapes of lines: one A with exploded red lines, the other B with closed black lines.
In a virtual layer I want to select the yellow ones (A) i.e. those having only 2 points in common with B.
I try to find a way to count the number of intersections between 2 lines without success.
Or maybe there is a better way to do it.
@JGH There is something weird when I work with my data. I can’t get the result you show on your screenshot. When I run the query to get the same result as you:
SELECT poly.*
FROM input1 as poly, input2 AS ouverture
WHERE st_intersects(poly.geometry, ouverture.geometry)
AND st_dimension(st_intersection(poly.geometry, ouverture.geometry)) = 0
Then the result is the red lines :
The green polygons (poly) have only 4 nodes and topology is correct with black lines. It runs from a model so green polygon file converted to lines is not visible.
The strangest are the two red lines at the bottom which are the opposite of the expected result.
@Taras : result is empty.
EDIT : sample of data
shp and comments inside.
You need to select the line that intersect the box, then you compute the intersection and keep only the ones who have an intersection composed of points (i.e. exclude the intersection made of lines)
SELECT tg.*
FROM target_layer AS tg, closes_line_layer AS cl
WHERE st_intersects(tg.geometry, cl.geometry)
AND ST_Dimension(st_intersection(tg.geometry, cl.geometry)) = 0
Correct answer by JGH on September 26, 2021
SELECT r.*
FROM "red_lines" AS r, "black_lines" AS b
WHERE st_within(start_point(r.geometry), b.geometry)
AND st_within(end_point(r.geometry), b.geometry)
AND st_length(st_intersection(r.geometry, b.geometry)) = 0
Answered by Taras on September 26, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP