movingpandas / qgis-processing-trajectory

Trajectory tools for the QGIS Processing toolbox
GNU General Public License v3.0
45 stars 16 forks source link

Trajectory dataframe must have at least two rows #11

Closed k1th closed 3 years ago

k1th commented 4 years ago

Should this be added? (skipping single point data frames)

In qgisUtils.py

    for key, value in df_by_id.items():
        if len(value) < 2:
            continue
        traj = Trajectory(key, value)
        trajectories.append(traj)

and in splitOnDayBreakAlgorithm.py:

    def split(self, mode='daybreak'):
        result = []
        if mode == 'daybreak':
            dfs = [group[1] for group in self.df.groupby(self.df.index.date)]
            for i, df in enumerate(dfs):
                if len(df) < 2:
                    continue
anitagraser commented 4 years ago

Yes, it should. Feel free to submit a pull request.

I'm planning to replace most of the current data handling implementation with http://movingpandas.org which is considerably further developed than the current Trajectools code base.

alibama commented 4 years ago

probably related, just reporting it here for posterity { 'INPUT' : '/Users/ansonparker/Desktop/david-library.geojson|layername=david-library', 'OBJECT_ID_FIELD' : 'unique', 'OUTPUT' : 'TEMPORARY_OUTPUT', 'TIMESTAMP_FIELD' : 'Time', 'TIMESTAMP_FORMAT' : '%Y-%m-%d %H:%M:%S+00' }

Traceback (most recent call last): File "/Users/ansonparker/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/processing_trajectory/qgis_processing/trajectoriesFromPointLayerAlgorithm.py", line 147, in processAlgorithm trajectories = trajectories_from_qgis_point_layer(input_layer, timestamp_field, traj_id_field, timestamp_format) File "/Users/ansonparker/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/processing_trajectory/qgis_processing/qgisUtils.py", line 56, in trajectories_from_qgis_point_layer traj = Trajectory(key, value) File "/Users/ansonparker/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/processing_trajectory/trajectory.py", line 42, in init raise ValueError("Trajectory dataframe must have at least two rows!") ValueError: Trajectory dataframe must have at least two rows!

Execution failed after 9.84 seconds