# Calculating distance between two Linestring using Python

I have two linestring, each linestring represents a rail road. I am trying to calculate minimum distance between these two linestrings. Which function is efficient to do this?

I have only come across distance function that takes a point and linestring but not 2 linestring.

For e.g.:

``````l1 = LineString([(42.073407, -87.806245), (42.0752508,-87.8080299)])
l2 = LINESTRING(35.442827 -79.470579, 35.444889 -79.469465, 35.445829 -79.468907, 35.446608 -79.468294, 35.447893 -79.46687)
``````

I need the distance between these two shapely objects.

In The Shapely User Manual -> `object.distance(other)`

Returns the minimum distance (float) to the other geometric object.

``````from shapely.geometry import LineString
l1 = LineString([(42.073407, -87.806245), (42.0752508,-87.8080299)])
• Use , `shapely.ops.transform() ` as in Transforming Shapely Polygon and MultiPolygon objects for example, but there are many other examples in GIS SE