I have a geodataframe that contains positions (point geometries). For each position, we know the individual's id (id_individ), DOY (doy), year (année) and timestamp.
I want to aggregate the geometries (and sort them by timestamp) to reconstitute individual tracks, grouped by id and DOY. The expected result is a geodataframe where the geometry column contains Linestrings. So far, I've tried this python command:
tracks = gpd.GeoDataFrame(df_species.groupby(['id_individ', 'doy', 'year']).geometry.agg(unary_union).reset_index(), geometry="geometry", crs=df_species.crs)
I get :
I can't sort the points by timestamp at aggregation time and then generate a Linestring. I know it's possible to do this in SQL, but I'm looking for a way to do it in Python with Geopandas.


