I am a complete newbie to this as you will see. I would like to create a LINESTRING from two POINT geometries and then determine the mid-POINT. So, from my original pandas dataframe, with x and y columns, I created the following geopandas dataframe:
zone_short_edges =
id vertex_id from \
1 A1 2 POINT (119.79008 28.35047)
3 A1 4 POINT (122.85067 44.85106)
5 A2 1 POINT (138.79141 26.48802)
7 A2 3 POINT (141.73386 44.89716)
to seg_length
1 POINT (122.85067 28.08433) 3.072140
3 POINT (119.92314 44.71798) 2.930553
5 POINT (141.92247 26.26168) 3.139230
7 POINT (138.79141 44.89716) 2.942450
where fr_point
and to_point
are dtype = geomtry
.
Now, I am facing two choices:
- Create a LINESTRING for each pair and then finding that linestrings midpoint.
- Finding the midpoint (what I actually want to the possibility to find all the POINT(s) that divide the segment into
N
segments of equal length).
I tried doing this:
geometry = [xy for xy in zip(zone_short_edges.fr_point, zone_short_edges.to_point)]
LineString([geometry]).wkt
I also tried the solution provided here: https://stackoverflow.com/a/66494934/5363686
But, both failed.
Any ideas that might put me in the right direction or do I really need to go to my original dataframe?