Paul
Paul

Reputation: 326

LineString - get coordinates as DataFrame

I have a geopandas Dataframe with one GeoSeries.

There is only one entry for this column, a shapely.geometry.linestring.LineString.

LineString (first_lon first_lat, second_lon second_lat, ...)

I could not find an easy way to get the coordinates of this LineString as a DataFrame like

LON           LAT
first_lon     first_LAT
second_lon    second_LAT
...

Is there a build in function for this?

Thx

Upvotes: 3

Views: 10299

Answers (1)

Paul
Paul

Reputation: 326

x,y = LineStringObject.coords.xy
pd.DataFrame(list(zip(x,y)), columns=['LAT', 'LON'])

seem to do the job ok.

[EDIT]

x,y = LineStringObject.coords.xy
pd.DataFrame({'LAT':x,'LON':y})

Upvotes: 5

Related Questions