0

I have a shapely linestring with multiple points and a list with other points, something like this (but with hundreds of points):

    from shapely import geometry
    xy=geometry.LineString([(284013.3168553732, 4929336.870078533),
     (284012.39530582004, 4929324.339915148),
     (284017.5631161644, 4929250.361344838),
     (284022.5080302361, 4929182.366627739),
     (284030.5078563042, 4929110.832004678)])

    pts=[(280800,4894570),(280900,4894620),(295750,4894620)]

What I want to do is to find if the points in pts are on the west or east of the linestring. I found some answer online but using only a simple line and one point. Is there a way to do it with multiple points?

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Italo Lopes
  • 83
  • 1
  • 8
  • if you have a solution for a single point, why don't you iterate over all the points you want to check and apply that solution for each of them? – Sembei Norimaki Apr 18 '23 at 09:25
  • I found answers such as that one: https://stackoverflow.com/questions/3838319/how-can-i-check-if-a-point-is-below-a-line-or-not but using a line with only two points. For a line with mutiple points, I don't think this solution is suitable. – Italo Lopes Apr 18 '23 at 09:31
  • you have to post the code you have. and then ask an specific question, like: `I have this function (post that function in the question) that given a point and a line, returns "west" or "east" as the location of the point respect the line, but I want to run this for several points.` Then you post your attempt to use that function with several points (like a loop as suggested) and what result you are getting that doesn't match the expected results. – Sembei Norimaki Apr 18 '23 at 09:38
  • 1
    btw, there's no such thing as "a line with multiple points" (unless they are redundant colinear points), you might have different consecutive lines, each defined by a starting and ending point, in which case the point will be "west" o "east" for each of the lines in the segment, so you won't have a single answer, but a list of answers. Iterate that point over each line and check if it's west or east (and think what answer should you get when you have horizontal lines) – Sembei Norimaki Apr 18 '23 at 09:43

0 Answers0