Skip to content

Instantly share code, notes, and snippets.

@albertum1
Last active March 23, 2021 19:49
Show Gist options
  • Save albertum1/8c695ac3621fc2d9fe3709f3f583c615 to your computer and use it in GitHub Desktop.
Save albertum1/8c695ac3621fc2d9fe3709f3f583c615 to your computer and use it in GitHub Desktop.
import pandas as pd
import geopandas as gpd
"""
assume train_df, a pandas dataframe, exists with longitude and latitude columns
"""
# create geopandas dataframe
gpd_df = gpd.GeoDataFrame(train_df,
geometry = gpd.points_from_xy(train_df['longitude'], train_df['latitude']))
# approximately 10km radius
gpd_df['geometry_1km'] = gp_df['geometry'].apply(lambda x: x.buffer(0.1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment