I've been attempting at my first program in Python and have largely been able to find existing answers to my questions, but now I'm really stuck.
The code is as follows:
from shapely import geometry, ops
main_condition = True
line = geometry.LineString(((0,0),(5,5)))
while main_condition:
# do some geometry stuff with line
if second_condition:
return line
main_condition = False
else:
line_parallel = line.parallel_offset(«arg1»,«arg2»)
line = line_parallel
#loop again
So I have a line, that I want to offset until a condition is met. My problem is that the parameters I want to vary are an argument of the shapely line_parallel
function. Now the arguments I want to vary are as follows:
«arg1»: This parameter is a float and is the offset for the new parallel line. I'd like this to be 0.001, 0.001, 0.002, 0.002, 0.003, 0.003, and so on, repeating once and then moving to the next number.
«arg2»: This parameter is a string and is if the offset if to the 'left' or 'right'. I want this to vary between 'left' and 'right' each time the main loop is run.
Hopefully that's not too confusing, but essentially the idea is that the line offsets first 0.001 'left', then 0.001 'right', then 0.002 'left', then 0.002 'right' and so on each time offsetting to a further and further away position to either side of the original line until the condition is met.
Any idea on what might be the best way of having a varying argument to a function inside the while loop?