Reputation: 608
Even though there is an answer to my question How to create an accurate buffer of 5 miles around a coordinate in python?, but I can not represent it.
I have a Series of locations in standart lat, lon float degrees format, and need to calculate buffer
around them in meters.
The locations are from Portugal, so I picked up the "right" crs
here: https://epsg.io/3763, which is epsg:3763
gdf = gpd.GeoDataFrame(df, geometry=gpd.points_from_xy(df['latitude'], df['longitude']),
crs={'init' :'epsg:3763'})
gdf['radius'] = gdf.geometry.buffer(50)
According to the answer above, that should give me polygons around specified radius in meters, but that actually returns radius in the degrees.
I know, that should be simple, but I am still deeply confused. Thank you!
Upvotes: 2
Views: 5750
Reputation: 757
Your Points in the dataframe are lat/lon. You need to initialize the dataframe with the lat/lon crs, then reproject.
gdf = gpd.GeoDataFrame(df, geometry=gpd.points_from_xy(df['latitude'], df['longitude']),
crs={'init' :'epsg:4326'})
gdf = gdf.to_crs(epsg=3763)
gdf['radius'] = gdf.geometry.buffer(50)
Upvotes: 5