2

I have a very specific set of circumstances under which I need to break a parallelogram into 2 pieces. The parallelogram obviously always have 4 vertices and the intersecting line intersects the polygon exactly 2 times. In the order in which the intersecting line points are given, the polygon area to the right of the line is the area of interest. I feel this could be solved using a linked list implementation in code but am unsure where to start. Additionally, if there is a simply geometry function to get the job done, that is acceptable too (I've tried intersection and difference but neither applies to the situation). An example is attached below.

Notes:

  • Polygon vertices are given in clockwise order starting from the upper-right-most point.

  • The intersecting line can have 2 or more points. (In the case of 2, that means that the same intersecting ling segments intersects 2 of the parallelogram's sides.

  • It's possible the intersecting line only intersects one side of the polygon.

The area of interest is the upper-right area of the polygon that is closed off by the line. This implies that in this case, the intersecting lines' vertex order is 1) the point to the right, 2) the point in the center, 3) the point at the top.

These are a few more possible cases where the area of interest is shaded (please excuse my poor drawings!).

enter image description here

B. Schmidt
  • 151
  • 2
  • 6
  • Aside from very complex gerrymandering in North Dakota, what is the point of the exercise? – Andrew Tice Jan 06 '15 at 11:31
  • 1
    The US SPC (Storm Prediction Center) issues severe weather watches initially as parallelograms of arbitrary size (representative of geographic area). Over time, they are trimmed by area as storms move through. Thus, as time progresses, it only makes sense to display the valid portion rather than the entire polygon. For this I need to cut the polygon down to size manually as only the initial boxes' and update lines' lat/lon coordinates are given. – B. Schmidt Jan 06 '15 at 19:39
  • Ok - thanks for that (and sorry if the comment was a little sarcastic!). Its always useful to know a little about the data. The problem as I see it is that trimming of the original polygons is essentially arbitrary - or it is at least from your drawings. Are you thinking that the path of the storm could essentially trim the original polygon to the right or the left of the path? If so that really makes things complex as its a subjective decision. You could derive a minimum bounding box based on the path of the storm and then clip the polygon - or you could just buffer the path to an (see below) – Andrew Tice Jan 07 '15 at 21:12
  • arbitrary distance (possibly based on the strength of the storm - this would be trial and error on your part) and use that to clip the original polygons. These are just a few suggestions - and not an answer (sorry). I've voted the question up as its a tricky one and should get more attention! – Andrew Tice Jan 07 '15 at 21:14
  • Not the best analogy but one that works; imagine you are cutting the grass in a square yard. You make progress in rows roughly halfway and decide to take a break. If you walk the line of your progress in the right order, everything to the right of your path within the yard is left. The yard represents the polygon and your path is the line. The order of the coordinates is know and in "to the right of a line" order. You have given me an idea though. My potential solution is listed below...I'll try it out and update with results. – B. Schmidt Jan 08 '15 at 01:46
  • Currently I'm thinking this algorithm will work...I'd be interested in your opinion. (the coordinates of each intersection point are known) 1) walk the polygon coordinates in clockwise order until an intersection is found on the current segment. If it is the first intersection coordinate, remove all subsequent polygon vertices until the next intersection is found. If not, turn around and execute the algorithm in the anti-clockwise direction. From there, one simply only needs to join the remaining segments to form the resultant polygon. – B. Schmidt Jan 08 '15 at 01:52
  • I've had to draw this out on a piece of paper ... but logically, this might just work! How are you thinking of implementing it (i.e. Python?). Sticking point would be how to define "clockwise". As the storms could enter from any side of the polygon there is going to have to be a bit of (difficult) logic to represent "left of this point". – Andrew Tice Jan 08 '15 at 08:02
  • A thought struck me, which is something along the lines of attempting to merge the two files together - and I've just found this question from earlier this year: http://gis.stackexchange.com/questions/86308/how-to-identify-line-intersection-in-qgis-when-i-have-more-than-2-lines – Andrew Tice Jan 08 '15 at 08:04

0 Answers0