In this chapter, we will use the Brazil GPS Trajectories dataset from UCI. It contains GPS points (latitude and longitude) with timestamps. It also contains unique track_id for each trajectory.
Here is what the first five rows of the data look like:
GPS trajectory: first five rows
We create a GeoDataFrame using a function we created in Chapter 4, Making Sense of Humongous Location Datasets:
def create_gdf(df, lat, lon):
""" Convert pandas dataframe into a Geopandas GeoDataFrame"""
crs = {'init': 'epsg:4326'}
geometry = [Point(xy) for xy in zip(df[lon], df[lat])]
gdf = gpd.GeoDataFrame(df, crs=crs, geometry=geometry)
return gdf
traj_gdf = create_gdf(trajectories, "latitude", "longitude")
aracaju_city_points = traj_gdf[(traj_gdf['latitude']<...