0

I have a list of coordinates in a 2D plane (black dots)

enter image description here.

They represent the path on the map. I need to get the coordinates (x,y) of the red tunnel polygon based on this list (red dots). The red dot coordinates must not be mixed up. They must follow each other along the border of the polygon like on image. The width of the tunnel is set by me myself.

I searched for a solution in many Python libraries but did not find it. I'm going to use the result in mpltPath.Path to count the number of occurrences of coordinates in the red polygon.

So, how can I solve this problem using python?

Ian Turton
  • 10,018
  • 1
  • 28
  • 47
  • I don't know about special package, but you can calculate the coordinates. At the end (1, 8, 4, 5) you need to shift the original points with `+/- tunnel width * unit normal vector`. The other points are intersections of two lines. To get one point of the shifted line you need to shift one of the points of the original line similarly. https://stackoverflow.com/questions/1243614/how-do-i-calculate-the-normal-vector-of-a-line-segment/1243676#1243676 – Arpad Horvath -- Слава Україні Mar 17 '22 at 06:25
  • Link for calculating unit normal vector. https://stackoverflow.com/a/7470098/813946 – Arpad Horvath -- Слава Україні Mar 17 '22 at 06:35
  • something like https://stackoverflow.com/questions/10384971/rectangles-from-points-using-python or https://gis.stackexchange.com/questions/2207/programmable-buffers-using-gdal-and-python?rq=1 – Ian Turton Mar 17 '22 at 08:15
  • I did it by shapely buffer method. https://shapely.readthedocs.io/en/latest/manual.html#object.buffer – user18485961 Mar 18 '22 at 15:33

0 Answers0