I have a big csv (12Go) that contains this informations of trip data for each point in 1s interval: lon, lat, timestamp and street_id. My aim is to segment street to 10m long segments and assign a unique segment id to each point based on its position.

Here is an example of what my data looks like using df.head():

    timestamp           Lat       Lon       street_id
0   4/1/2014 0:11:00    40.7690   -73.9549  140
1   4/1/2014 0:17:00    40.7267   -74.0345  50

I'm using goepandas as follows to get a spatial dataframe:

from geopandas import GeoDataFrame
from shapely.geometry import Point

geometry = [Point(xy) for xy in zip(df.Lon, df.Lat)]
df = df.drop(['Lon', 'Lat'], axis=1)
gdf = GeoDataFrame(df, crs="EPSG:4326", geometry=geometry)

I just dont know how to begin, I know I have to group by street_id then calculate the distance between each point and the begining of the street, but Ive failed to find how to find how to do so

The expected result should look like:

    timestamp           Lat       Lon       street_id segment_id
0   4/1/2014 0:11:00    40.7690   -73.9549  140          5
1   4/1/2014 0:17:00    40.7267   -74.0345  50           1

Segment_id should be a unique identifier for each street segment of 10m long



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.