I want to draw two or many curved lines from fixed start point to another fixed end point on map. So, I started with geodesic but it draws overlapping lines. Then I tried to draw trajectory but not very useful as points could be any where in the world. How can I achieve this? I am using python and javascript. The below image is something I am aiming for (map is not added but imagine as if it is there :)). Also, is there any way to add directional arrow? Please help.

enter image description here


1 Answer 1


This could be done with Bézier curves. Here is the python library to create Bézier curves.

enter image description here

import bezier
import numpy
import matplotlib

x1 = [0.0, 1.0, 2.0]
y1 = [0.0, 1.0, 0.0]

x2 = [0.0, 1.0, 2.0]
y2 = [0.1, 2.0, 0.1]

nodes1 = numpy.asfortranarray([x1, y1])
nodes2 = numpy.asfortranarray([x2, y2])

curve1 = bezier.Curve(nodes1, degree=2)
ax = curve1.plot(100, color='r', alpha=None, ax=None)

curve2 = bezier.Curve(nodes2, degree=2)
curve2.plot(100, color='g', alpha=None, ax=ax)

number_of_point = 15
s_vals = numpy.linspace(0.0, 1.0, number_of_point)
[curve2_values_x, curve2_values_y] = curve2.evaluate_multi(s_vals)

print('curve2_values_x=', curve2_values_x, end='\n'*2)
print('curve2_values_y=', curve2_values_y)

matplotlib.pyplot.plot(x1, y1, 'ro')
matplotlib.pyplot.plot(x2, y2, 'go')
matplotlib.pyplot.plot(curve2_values_x, curve2_values_y, 'b+')
  • Thanks Mr. Che! Can I give map's lat-long as points in your code?
    – Surya
    Commented Oct 31, 2019 at 7:36
  • Thanks @Mr.Che. Will try your code and update you.
    – Surya
    Commented Oct 31, 2019 at 10:40
  • This is really helpful. Do you know how to densify the curve. My main goal is to use the list of (x,y) geometry and pass to create polyline.
    – Surya
    Commented Oct 31, 2019 at 10:56
  • @Surya See update Commented Oct 31, 2019 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.