I have a GeoSeries as below.
u v key
5863596387 5863593976 0 POINT (585155.331 4507719.832)
7480515814 7787627737 0 POINT (585156.356 4507160.458)
8309479770 8309479778 0 POINT (585008.639 4509646.314)
1205714997 1764647101 0 POINT (590176.344 4524086.390)
7604384203 7604384200 0 POINT (589636.237 4522156.767)
7924346623 7924346668 0 POINT (589841.836 4516372.368)
1774037211 1792517013 0 POINT (587815.517 4517574.111)
8279851489 8279851474 0 POINT (583614.400 4507554.406)
7580661034 4024142484 0 POINT (583284.669 4506201.572)
3900961247 3900964258 0 POINT (589095.692 4515465.756)
7924099735 7924099740 0 POINT (588136.098 4514814.989)
60918736 60925795 0 POINT (589377.465 4522528.968)
42445215 3858909357 0 POINT (588907.958 4517605.588)
61271527 61272997 0 POINT (585439.051 4514947.585)
5815643321 5813259923 0 POINT (583241.942 4507490.863)
42456831 371337197 0 POINT (589885.624 4518773.023)
8309479036 8309479035 0 POINT (584918.567 4509003.683)
7925258675 7926756848 0 POINT (590145.751 4517162.307)
I would like to convert this into list of points, for example:
[(585155.331, 4507719.832), (585156.356, 4507160.458), ...]
How can I accomplish this in python? I am not sure how to get the POINT column because unlike the u,v, key columns, they are not indexed.
I have seen How to convert a GeoSeries of points to a list of tuples (lat, lon) using GeoPandas this answer, but I get an error in their solution (KeyError: 'geometry') and am not sure what "geometry" refers to here.
Use accessors x
and y
:
# Ensure you have a GeoDataFrame
>>> type(gdf)
geopandas.geodataframe.GeoDataFrame
>>> list(zip(gdf.x.astype(float), plugs.y.astype(float)))
[(837345.1, 6502334.7),
(837344.9, 6502334.8),
(837262.6, 6502120.7),
(837262.4, 6502120.6),
(837331.0, 6501996.9),
(837331.2, 6501996.7)]