I have some coordinates from Lng and lat, that I combined to a Linestring.
The Linestring is made of 2 Points. From one point starting=origin
and from one point ending = destination
.
This is the code for the Linestring column
erg2['Linestring'] = erg2.apply(lambda x: LineString([(x['latitude_origin'], x['longitude_origin']), (x['latitude_destination'], x['longitude_destination'])]), axis = 1)
I am trying everything to plot the Linestring from origin to destination without any good results..\
You would help me out a lot!\
This is the dataframe erg2
with lng and lat and the combined Linestrings...
How can I plot them over a map. The numbers in the columns of origin and destination are location ids of a city..
What would you as an experienced programmer plot. The two points with scatter or the combined Linestrings?? Following I am putting in my dataframe.head().
Usually the df has [19600 rows x 8 columns]
origin | destination | move | longitude_origin | latitude_origin |
---|---|---|---|---|
88 | 88 | 20 | 13.481016 | 52.457055 |
88 | 89 | 0 | 13.481016 | 52.457055 |
88 | 110 | 0 | 13.481016 | 52.457055 |
88 | 111 | 0 | 13.481016 | 52.457055 |
88 | 112 | 0 | 13.481016 | 52.457055 |
87 | 83 | 0 | 13.479667 | 52.479600 |
longitude_destination | latitude_destination | Linestring |
---|---|---|
13.481016 | 52.457055 | LINESTRING (52.45705489204205 13.4810161067992... |
13.504075 | 52.443923 | LINESTRING (52.45705489204205 13.4810161067992... |
13.613772 | 52.533194 | LINESTRING (52.45705489204205 13.4810161067992... |
13.586891 | 52.523562 | LINESTRING (52.45705489204205 13.4810161067992... |
13.559341 | 52.507418 | LINESTRING (52.45705489204205 13.4810161067992... |
13.481016 | 52.457055 | LINESTRING (52.45705489204205 13.4810161067992... |
I am trying out to plot the Lines with the sample code from geopandas from @RobRaymond
The result shows lines which dont make sense.. This is the output:
All the lines have this description in the hover all start at 87-... In my dataframe you see that we have origin 88 etc...
It is also important to plot the Lines depending on the movements. Since zero movements don't need to be plotted... I really hope that I am making the question clear. It is really getting above my head a bit.