movingpandas / qgis-processing-trajectory

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

"IndexError: list index out of range" Error applying "Split Trajectories at Time Intervals" to filtered layer #23

Closed benparkergit closed 4 months ago

benparkergit commented 4 months ago

I hope I am doing this right... The tool is super-useful for my work, thank you.

I filtered a point layer of AIS ship data, to reduce it to three MMSI numbers.

Then I ran the "Split Trajectories at Time Intervals" on the filtered layer and I get this error:

QGIS version: 3.34.3-Prizren
Qt version: 5.15.8
Python version: 3.10.13
GDAL version: 3.8.3
GEOS version: 3.12.1-CAPI-1.18.1
PROJ version: Rel. 9.3.1, December 1st, 2023
PDAL version: 2.6.2 (git-version: Release)
Algorithm started at: 2024-02-27T13:28:43
Algorithm 'Split trajectories at time intervals' starting…
Input parameters:
{ 'INPUT' : QgsProcessingFeatureSourceDefinition('file:///C:/Users/BPARKER2/OneDrive%20-%20United%20Nations/Documents/JCC/BSISO-2024/Data/UNGM/NOVO1.csv?type=csv&trimFields=Yes&maxFields=10000&detectTypes=no&xField=longitude&yField=latitude&crs=EPSG:4326&spatialIndex=no&subsetIndex=no&watchFile=no&field=dt_pos_utc:datetime&field=heading:double&subset=%22mmsi%22%20%20%20LIKE%20%20229084000%20OR%20%22mmsi%22%20%20%20LIKE%20%20636020581%20OR%20%22mmsi%22%20LIKE%20314733000', selectedFeaturesOnly=False, featureLimit=-1, flags=QgsProcessingFeatureSourceDefinition.FlagCreateIndividualOutputPerInputFeature, geometryCheck=QgsFeatureRequest.GeometryAbortOnInvalid), 'OUTPUT_PTS' : 'TEMPORARY_OUTPUT', 'OUTPUT_TRAJS' : 'TEMPORARY_OUTPUT', 'SPEED_UNIT' : 'km/h', 'SPLIT_MODE' : 2, 'TIME_FIELD' : 'dt_pos_utc', 'TRAJ_ID_FIELD' : 'mmsi' }

Executing iteration 1/593…
Traceback (most recent call last):
File "C:\Users/BPARKER2/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\processing_trajectory\qgis_processing\trajectoriesAlgorithm.py", line 161, in processAlgorithm
QgsField(tc.get_speed_col(), QVariant.Double),
File "C:\Users\BPARKER2\AppData\Local\miniforge3\lib\site-packages\movingpandas\trajectory_collection.py", line 281, in get_speed_col
return self.trajectories[0].get_speed_col()
IndexError: list index out of range
anitagraser commented 4 months ago

Thank you for the report. Can you share the data sample to reproduce the error?

anitagraser commented 4 months ago

I've tested applying a filter to the AIS sample shipped with the plugin but I cannot reproduce the issue this way.

anitagraser commented 4 months ago

@benparkergit Can you test with the new development version to see if you get the new and improved error message?

Algorithm 'Split trajectories at observation gaps' starting…
Input parameters:
{ 'INPUT' : 'memory://Point?crs=EPSG:4326&field=id:integer(0,0)&field=sog:double(0,0)&field=cog:double(0,0)&field=heading:double(0,0)&field=rot:double(0,0)&field=basedatetime:string(255,0)&field=status:integer(0,0)&field=voyageid:string(0,0)&field=mmsi:string(0,0)&field=speed:double(0,0)&field=direction:double(0,0)&uid={7fd8c223-ad86-4a51-a1b2-e7a567703d09}', 'OUTPUT_PTS' : 'TEMPORARY_OUTPUT', 'OUTPUT_TRAJS' : 'TEMPORARY_OUTPUT', 'SPEED_UNIT' : 'km/h', 'TIME_FIELD' : 'basedatetime', 'TIME_GAP' : '100 hours', 'TRAJ_ID_FIELD' : 'id' }

Traceback (most recent call last):
File "C:\Users/anita/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\processing_trajectory\qgis_processing\trajectoriesAlgorithm.py", line 161, in processAlgorithm
File "C:\Users/anita/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\processing_trajectory\qgis_processing\trajectoriesAlgorithm.py", line 115, in create_tc
raise ValueError(
ValueError: The resulting trajectory collection is empty. Check that the trajectory ID and timestamp fields have been configured correctly.

Execution failed after 0.09 seconds
benparkergit commented 4 months ago

I am very sorry I cannot reproduce the error. I will keep trying and report back.

anitagraser commented 4 months ago

No worries. Let's reopen this issue when you find something.