Firstly, we already have a dataframe, and there is a column of geometry. But this column is in the format of the string, therefore, we should change the data format from the string to the polygon.
There are two ways to implement this method.
The first method,
df = pd.DataFrame(
{
"City": ["Buenos Aires", "Brasilia", "Santiago", "Bogota", "Caracas"],
"Country": ["Argentina", "Brazil", "Chile", "Colombia", "Venezuela"],
"Coordinates": [
"POINT(-58.66 -34.58)",
"POINT(-47.91 -15.78)",
"POINT(-70.66 -33.45)",
"POINT(-74.08 4.60)",
"POINT(-66.86 10.48)",
],
}
)
from shapely import wkt
df["Coordinates"] = wkt.loads(df["Coordinates"])
gdf = geopandas.GeoDataFrame(df, geometry="Coordinates")
The second method,
df["Coordinates"] = geopandas.GeoSeries.from_wkt(df["Coordinates"])
gdf = geopandas.GeoDataFrame(df, geometry="Coordinates")
<iframe class="ginger-extension-definitionpopup" style="left: 44px; top: 100px; z-index: 2147483646; display: none"></iframe>
标签:847,POINT,df,create,Coordinates,method,dataframe,wkt From: https://www.cnblogs.com/alex-bn-lee/p/17515684.html