0

I am running a Python Shapely where I have a rotating and translating polygon for which I obtain some probe signals in the following way:

for theta_index, theta in enumerate(thetas):
    rotated = affinity.rotate(polygon, theta, use_radians=True)
    intersection = line.intersection(rotated.boundary)
    dist = intersection.distance(probe_pos)
    signal.append(dist)

What I do here is I rotate/translate the polygon, then calculate an intersection of a line from the probe with the polygon, then obtain the distance of the intersection point from the probe and store it.

The polygon consists of more than 10 000 points and I need more than 10 000 samples. The calculation takes almost 20 ms for each sample, which is too long in this case.

What seems to take the most time here is calculating the intersection. What ways would exist in Shapely to speed up this calculation?

Getting rid of the intersection and using the closest polygon point directly is not an option for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.