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
How can I do this?
Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked Nov 22, 2018 at 13:09
-
What have you tried? gis.stackexchange.com/questions/95670/… would seem to answer the question/John Powell– John Powell2018年11月22日 13:39:47 +00:00Commented Nov 22, 2018 at 13:39
1 Answer 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(...)
answered Nov 22, 2018 at 14:03
Explore related questions
See similar questions with these tags.
lang-py