Closed fmemuir closed 1 day ago
Trying to implement a function which finds the cross products of the reference line and flips the line if the cross product is positive (the line is running clockwise AKA the sea is on the left): e5d3c9ab0543bfbcfd725505cf14b61110039770
Tested with this line (sea on right) in EPSG 32630: LINESTRING (512247.63337779173 6244396.362876395, 512163.2849808907 6244437.704613125, 512058.2838757301 6244433.135600944, 511983.2828838362 6244472.621631555, 512024.28892718116 6244615.023834913, 511992.2377964711 6244782.397023182, 511898.52302363666 6245116.712967976, 511783.2014286905 6245579.062207323, 511677.463369295 6246061.296348392, 511614.5082025027 6246317.076070224, 511522.3710200235 6246542.81292483, 511391.1810765303 6246738.363408613, 511272.0075582388 6246821.317948645, 511233.7948897691 6246909.468112542, 511183.3131699248 6246960.080223709, 511103.3599302105 6247003.768391534)
And this line (sea on right) in EPSG 32647: LINESTRING (762447.0431072162 200764.20560869278, 762430.6661061295 200730.20187231898, 762428.0019008198 200674.467298661, 762384.5216312804 200436.53386147527, 762376.441908123 200335.93538193672, 762367.0025053704 200228.5386068344, 762375.3369354308 200133.398582787, 762357.630161594 200069.48853360693, 762353.618434032 199997.44047963092, 762335.8798090485 199957.99776055847, 762324.9940043648 199910.40814696296, 762323.6785021096 199869.62745223034, 762334.6755059415 199831.581331971)
And this line (sea on left) in EPSG 32756: LINESTRING (544934.2581639017 7011006.449319134, 544397.3484109668 7010603.76700443, 544112.1151047158 7010385.647417299, 543826.8817984705 7010133.97097061, 543373.8641944256 7009999.7435323745)
Line 1 returned correct orientation ✅ Line 2 was flipped ✅ Line 3 returned correct orientation ✅
Sent by @IdhamN: some Transects are orientated incorrectly in cross-shore validation plots:
In this example, the later lines are seaward but in the transect validation plot they are negatively positioned i.e. landward of validation.
This is due to an incorrect orientation of the reference line, which gets fed into
Transects.PrduceTransects()
to create aCoast
object. If the line is oriented a certain way, the transects get drawn in the direction of travel and assigned offshore to the right node and onshore to the left node. All other transect-based calculations (intersections, distances, rates of change) get calculated based off this orientation, so if the reference line traverses the coast with the sea on the left, everything will be backwards.Fasted solution is just to ensure that a user draws their reference line with the sea on their right. For a shore with the sea to the east, this means drawing south-north. For a shore with the sea to the north, this means drawing the line east-west. However, there should be an easier/mathematical way to automatically figure out the drawing direction of a line (e.g. cross products)