1

So I want to create a LineString and get the length of the LineString from two sets of LatLon coordinates (points) in each row in a Pandas Dataframe, and store in a new column

Blockquote

How can I do this?

1
1

You can use apply to create the output column like this:

import shapely.geometry as geom
your_df['geometry'] = your_df.apply(lambda x: geom.LineString([(x['startlat'], x['startlon']) , (x['endlat'], x['endlon'])]), axis = 1)

If your coordinates columns aren't float make sure to parse them first with float(...)

0

Your Answer

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

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