Categories
Mastering Development

geopandas: from a column of coordinate list to geometry

I have a DataFrame which has a column of coordinates list looks like the following:

enter image description here

I want to make this DataFrame a GeoPandas DataFrame with a geometry column. One way for doing this is to create two lists representing latitude and longitude and store the first and second element from the coors column to latitude and longitude, respectively. Then sue gpd.points_from_xy to build the geometry column. But this approach adds extra steps for building GeoPandas DataFrame. My question is how to build geometry directly from the coors list.

I add some test data here:

import pandas ad pd
import geopandas as gpd

data = {'id':[0,1,2,3], 'coors':[[41,-80],[40,-76],[35,-70],[35,-87]]}
df = pd.DataFrame.from_dict(data)

Leave a Reply

Your email address will not be published. Required fields are marked *