Skip to content

input track data #6

Description

@wendellwt

What is the best way to input lots of track data into PyMEOS?

I have a pandas dataframe with columns of id, lat, lon, and timestamp. The lat and lon are both numpy.float64 and the timestamp is a 'pandas._libs.tslibs.timestamps.Timestamp'.

The following code works, but takes about 8 minutes to create TGeomPointInst for 3,600,000 points (but only 3 seconds to make TGeomPointSeq elements of the 26,000 resulting tracks).

Would making the conversion function into a vectorized numpy function help?

Thank you,
Wendell

from postgis import Point
from pymeos import TGeomPointInst, TGeomPointSeq

def make_tgp(lat, lon, tstamp):
    return TGeomPointInst(point=Point(lon, lat), timestamp=tstamp)

df['tgp'] = df.apply( lambda row: \
           make_tgp(row['lat'], row['lon'], row['posit_time']), axis=1)

grouped_df = df \
    .groupby('flight_index',as_index=False ) \
        .agg( {'fid' : 'first',
               'tgp' : list })

grouped_df['tgps'] = grouped_df['tgp'].apply( lambda t: TGeomPointSeq(instant_list=t))

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions