Giter Site home page Giter Site logo

qgis-processing-trajectory's Introduction

MovingPandas

pypi Conda Version Conda Downloads Conda Recipe Conda Platforms Project Status: Active – The project has reached a stable, usable state and is being actively developed. Tests docs status codecov DOI pyOpenSci Code style: black StandWithUkraine

Mastodon Follow

SWUbanner

MovingPandas implements a Trajectory class and corresponding methods based on GeoPandas.

Visit movingpandas.org for details!

You can run MovingPandas examples on MyBinder - no installation required: Binder (These examples use the latest MovingPandas release version.)

To try the cutting-edge dev version, use this MyBinder link.

Documentation

We recommend starting your MovingPandas journey with the tutorial notebooks on the official homepage

The official API documentation is hosted on ReadTheDocs

Examples

Trajectory plots View Jupyter Notebook

Create interactive trajectory plots, including multiple linked plots with ease

movingpandas_animated

For all types of tracking data, e.g. video-based trajectories

Bicycle tracks from object tracking in videos

Including plots in custom projections View Jupyter Notebook

MovingPandas Iceberg trajectory in custom SouthPolarStereo projection

Stop detection View Jupyter Notebook

Detect stops in trajectories, extract them as points or segments, and use them to split trajectories

movingpandas_stop_detection

Trajectory generalization View Jupyter Notebook

Generalize trajectories using spatial, temporal, and spatiotemporal methods

movingpandas_generalize

Trajectory cleaning & smoothing View Jupyter Notebook

Clean and sooth trajectories by removing outliers and applying Kalman filters

movingpandas smooth

Trajectory aggregation View Jupyter Notebook

Aggregate trajectories to explore larger patterns

movingpandas_ais

Installation

MovingPandas for Python >= 3.7 and all its dependencies are available from conda-forge and can be installed using

conda install -c conda-forge movingpandas

or faster using

mamba install -c conda-forge movingpandas

Note that it is NOT recommended to install MovingPandas from PyPI! If you are using Windows or Mac, many GeoPandas / MovingPandas dependencies may not install correctly with pip (for details see the corresponding notes in the GeoPandas documentation). On Ubuntu, pip install may fail, e.g. on cartopy with "Proj 4.9.0 must be installed".

Development installation

Use the following steps to run the notebooks using the current development version:

Using conda / mamba

conda env create -f environment.yml

Develop mode

To install MovingPandas in "develop" or "editable" mode you may use:

python setup.py develop

Contributing to MovingPandas GitHub contributors

All contributions, bug reports, bug fixes, documentation improvements, enhancements and ideas are welcome.

A detailed overview on how to contribute can be found in the contributing guide on GitHub.

Related Python packages

For a more comprehensive list, including non-Python solutions, check https://github.com/anitagraser/movement-analysis-tools

scikit-mobility is a similar package which also deals with movement data. It implements TrajectoryDataFrames and FlowDataFrames on top of Pandas instead of GeoPandas. There is little overlap in the covered use cases and implemented functionality (comparing MovingPandas tutorials and scikit-mobility tutorials). MovingPandas focuses on spatio-temporal data exploration with corresponding functions for data manipulation and analysis. scikit-mobility on the other hand focuses on computing human mobility metrics, generating synthetic trajectories and assessing privacy risks. Plotting is based on Folium.

Traja extends the capabilitis of Pandas DataFrames specific for animal trajectory analysis in 2D. Plots (static) are based on seaborn.

PyMove provides functionality similar to MovingPandas. It implements PandasMoveDataFrames and DaskMoveDataFrame on top of Pandas and Dask DataFrames. Plotting is based on Folium.

Tracktable is a related Python package with its core data structures and algorithms implemented in C++, i.e. it is not based on Pandas. Plotting is based on Cartopy (for still images) and Folium (for interactive rendering).

Citation information

Please cite [0] when using MovingPandas in your research and reference the appropriate release version. All releases of MovingPandas are listed on Zenodo where you will find citation information, including DOIs.

Publications

About MovingPandas

[0] Graser, A. (2019). MovingPandas: Efficient Structures for Movement Data in Python. GI_Forum ‒ Journal of Geographic Information Science 2019, 1-2019, 54-68. doi:10.1553/giscience2019_01_s54.

@article{graser_movingpandas_2019,
	title = {{MovingPandas}: {Efficient} {Structures} for {Movement} {Data} in {Python}},
	volume = {7},
	number = {1},
	issn = {2308-1708, 2308-1708},
	shorttitle = {{MovingPandas}},
	url = {https://hw.oeaw.ac.at?arp=0x003aba2b},
	doi = {10.1553/giscience2019_01_s54},
	language = {en},
	urldate = {2023-04-19},
	journal = {GI\_Forum ‒ Journal of Geographic Information Science},
	author = {Graser, Anita},
	year = {2019},
	pages = {54--68},
}

[1] Graser, A. & Dragaschnig, M. (2020). Exploring movement data in notebook environments. Presented at MoVIS 2020, IEEE VIS 2020.

[2] Graser, A. (2021). Exploratory Movement Data Analysis. GeoPython 2021. – 🎬 video

Scientific publications using MovingPandas

Full Google Scholar list

Platforms using MovingPandas

Teaching materials referencing MovingPandas

Workshop videos

WorkshopVideo ogh2023

qgis-processing-trajectory's People

Contributors

anitagraser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

qgis-processing-trajectory's Issues

Couldn't load plugin 'processing_trajectory'

I am attempting to install the Trajectools plugin on macOS with QGIS 3.10, however, am currently faced with the following error:

ModuleNotFoundError: No module named 'geopandas'

I have tried installing geopandas using both pip install geopandas and conda install geopandas but to no avail. I am able to import geopandas when working from within Python 3 without any issues.

I'd appreciate any insights into this issue!

Screen Shot 2020-04-10 at 5 39 51 PM

loading error on startup

Hi,

I've got this error on startup:

ModuleNotFoundError: No module named 'processing_trajectory'
Traceback (most recent call last):
File "/home/toni/FLOSS/qgis/apps_r34/share/qgis/python/qgis/utils.py", line 309, in loadPlugin
import(packageName)
File "/home/toni/FLOSS/qgis/apps_r34/share/qgis/python/qgis/utils.py", line 672, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/home/toni/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgis-processing-trajectory/init.py", line 28, in
from .qgis_processing.trajectoryProviderPlugin import TrajectoryProviderPlugin
File "/home/toni/FLOSS/qgis/apps_r34/share/qgis/python/qgis/utils.py", line 672, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/home/toni/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgis-processing-trajectory/qgis_processing/trajectoryProviderPlugin.py", line 26, in
from .trajectoryProvider import TrajectoryProvider
File "/home/toni/FLOSS/qgis/apps_r34/share/qgis/python/qgis/utils.py", line 672, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/home/toni/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgis-processing-trajectory/qgis_processing/trajectoryProvider.py", line 30, in
from .trajectoriesFromPointLayerAlgorithm import TrajectoriesFromPointLayerAlgorithm
File "/home/toni/FLOSS/qgis/apps_r34/share/qgis/python/qgis/utils.py", line 672, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "/home/toni/.local/share/QGIS/QGIS3/profiles/default/python/plugins/qgis-processing-trajectory/qgis_processing/trajectoriesFromPointLayerAlgorithm.py", line 52, in
from processing_trajectory.trajectory import Trajectory
File "/home/toni/FLOSS/qgis/apps_r34/share/qgis/python/qgis/utils.py", line 672, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'processing_trajectory'

Python verzió: 3.7.2 (default, Jan 3 2019, 02:55:40) [GCC 8.2.0]
QGIS verzió 3.4.4-Madeira Madeira, 20cd215435

Cannot install QGIS trajectools

I am trying to install Trajectools but have an error even if I have followed (nearly) all the installation protocol (see below).

Two differences:

  • I have not done defined the GDAL version in the environment variables. I don't know how to do it (can you help on this ?)
  • The version of Fiona is different from what was indicated in your protocol

In the OSGeo (seems all went well)

OSGeoShell

In QGIS while trying to install Trajectools

QGISerror

couldn't load plugin 'processing_trajectory' on startup

Hi,

I've got this error on startup:

Konnte Erweiterung 'processing_trajectory' nicht laden

ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
Traceback (most recent call last):
File "C:/OSGEO41/apps/qgis/./python\qgis\utils.py", line 312, in loadPlugin
import(packageName)
File "C:/OSGEO4
1/apps/qgis/./python\qgis\utils.py", line 792, in _import
mod = builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/chhi/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\processing_trajectory_init
.py", line 28, in
from .qgis_processing.trajectoryProviderPlugin import TrajectoryProviderPlugin
File "C:/OSGEO41/apps/qgis/./python\qgis\utils.py", line 792, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/chhi/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\processing_trajectory\qgis_processing\trajectoryProviderPlugin.py", line 26, in
from .trajectoryProvider import TrajectoryProvider
File "C:/OSGEO4
1/apps/qgis/./python\qgis\utils.py", line 792, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/chhi/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\processing_trajectory\qgis_processing\trajectoryProvider.py", line 30, in
from .trajectoriesFromPointLayerAlgorithm import TrajectoriesFromPointLayerAlgorithm
File "C:/OSGEO41/apps/qgis/./python\qgis\utils.py", line 792, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:/Users/chhi/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\processing_trajectory\qgis_processing\trajectoriesFromPointLayerAlgorithm.py", line 25, in
from geopandas import GeoDataFrame
File "C:/OSGEO4
1/apps/qgis/./python\qgis\utils.py", line 792, in import
mod = builtin_import(name, globals, locals, fromlist, level)
File "C:\OSGEO4~1\apps\Python37\lib\site-packages\geopandas_init
.py", line 5, in
from geopandas.io.file import read_file # noqa
File "C:/OSGEO41/apps/qgis/./python\qgis\utils.py", line 792, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:\OSGEO4
1\apps\Python37\lib\site-packages\geopandas\io\file.py", line 6, in
import fiona
File "C:/OSGEO41/apps/qgis/./python\qgis\utils.py", line 792, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:\OSGEO4
1\apps\Python37\lib\site-packages\fiona_init
.py", line 84, in
from fiona.collection import BytesCollection, Collection
File "C:/OSGEO41/apps/qgis/./python\qgis\utils.py", line 792, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
File "C:\OSGEO4
1\apps\Python37\lib\site-packages\fiona\collection.py", line 9, in
from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
File "C:/OSGEO4~1/apps/qgis/./python\qgis\utils.py", line 792, in _import
mod = _builtin_import(name, globals, locals, fromlist, level)
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.

Python-Version: 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]
QGIS-Version: 3.16.2-Hannover Hannover, f1660f9da5

Python-Pfad:
C:/OSGEO41/apps/qgis/./python
C:/Users/chhi/AppData/Roaming/QGIS/QGIS3\profiles\default/python
C:/Users/chhi/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins
C:/OSGEO4
1/apps/qgis/./python/plugins
C:\OSGEO41\apps\Python37
C:\OSGEO4
1\apps\Python37\Scripts
C:\OSGeo4W64\bin\python37.zip
C:\OSGEO41\apps\Python37\DLLs
C:\OSGEO4
1\apps\Python37\lib
C:\OSGeo4W64\bin
C:\OSGEO41\apps\Python37\lib\site-packages
C:\OSGEO4
1\apps\Python37\lib\site-packages\win32
C:\OSGEO41\apps\Python37\lib\site-packages\win32\lib
C:\OSGEO4
1\apps\Python37\lib\site-packages\Pythonwin
C:/Users/chhi/AppData/Roaming/QGIS/QGIS3\profiles\default/python

Trajectories from point layer: not ordered by time?

For example with an input layer of bus stops, ordered by id (not by the time field that gets used as an input for the algorithm), the trajectory points end up being ordered as they were in the input layer and not ordered by time.
Is this intended ("ordered by time" in the description only referring to the "list" of trajectories being ordered) or an error ("ordered by time" in the description actually referring to the trajectories' contents)?

Day trajectories from point layer not working

Hi Anita,

I'm having a problem with creating daily trajectories.
The error that comes up is:
ValueError: Trajectory dataframe must have at least two rows!
My points layer has a column for ID and timestamp and I have stipulated the timestamp format correctly according to my data.
I have managed to create the normal 'Trajectories from point layer' just not the day trajectories.
Any help will be most appreciated!! Thanks

Timestamp format

Hi @anitagraser
I initially have timestamp on my trajectory data in this format 'yyyy-mm-dd hh:mm:ss.ss+00' however when running the "Trajectories from Point Layer" it always failed and saying that the timestamp is incorrect.
I tried to create a new field that contains on the time in this format 'hh:mm:ss" and put '%H:%M:%S' on the parameter but it returned another error that mentioned ValueError: time data '-01-04 1' does not match format '%H:%M:%S'

Can help on this?

Thank you

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

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



Add option to add stops from the stop detection algorithm?

Hi,

I used MovingPandas to create a trajectory from a given series of GPS points, both in Python & QGIS. And added the stops detected in the trajectory in Python.

I wanted to let some co-workers experiment with the data, so tried this plug-in, but from what I could tell this plug-in can only create the trajectory. Are there plans to add the option to also add detected stops too?

Thanks!
Bruno

p.s.: I haven't tried the smooth trajectory yet, but having that in the plug-in would be nice as well

TypeError: <class 'PyQt5.QtCore.QDateTime'> is not convertible to datetime, at position 0

Happens if the datetime column is QDateTime instead of string

Traceback (most recent call last):
File "C:\Users/GraserA/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis-processing-trajectory-main\qgis_processing\trajectoriesAlgorithm.py", line 120, in processAlgorithm
tc = tc_from_pt_layer(
File "C:\Users/GraserA/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qgis-processing-trajectory-main\qgis_processing\qgisUtils.py", line 43, in tc_from_pt_layer
tc = TrajectoryCollection(
File "C:\Users\GraserA\AppData\Local\miniconda3\envs\qgis\lib\site-packages\movingpandas\trajectory_collection.py", line 86, in __init__
self.trajectories = self._df_to_trajectories(
File "C:\Users\GraserA\AppData\Local\miniconda3\envs\qgis\lib\site-packages\movingpandas\trajectory_collection.py", line 189, in _df_to_trajectories
trajectory = Trajectory(
File "C:\Users\GraserA\AppData\Local\miniconda3\envs\qgis\lib\site-packages\movingpandas\trajectory.py", line 132, in __init__
df[t] = to_datetime(df[t])
File "C:\Users\GraserA\AppData\Local\miniconda3\envs\qgis\lib\site-packages\pandas\core\tools\datetimes.py", line 1112, in to_datetime
values = convert_listlike(arg._values, format)
File "C:\Users\GraserA\AppData\Local\miniconda3\envs\qgis\lib\site-packages\pandas\core\tools\datetimes.py", line 490, in _convert_listlike_datetimes
result, tz_parsed = objects_to_datetime64ns(
File "C:\Users\GraserA\AppData\Local\miniconda3\envs\qgis\lib\site-packages\pandas\core\arrays\datetimes.py", line 2346, in objects_to_datetime64ns
result, tz_parsed = tslib.array_to_datetime(
File "tslib.pyx", line 403, in pandas._libs.tslib.array_to_datetime
File "tslib.pyx", line 552, in pandas._libs.tslib.array_to_datetime
File "tslib.pyx", line 541, in pandas._libs.tslib.array_to_datetime
TypeError: <class 'PyQt5.QtCore.QDateTime'> is not convertible to datetime, at position 0

Execution failed after 20.69 seconds

Loading resulting layers
Algorithm 'Create trajectories' finished

CRS issue in Trajectools

I wish to use Trajectools in QGIS, but CRS handling in Geopandas has changed. When will Trajectools also be updated?

Assign unique trajectory IDs after splits

The split trajectory results need unique trajectory IDs.

If we split by a polygon layer, the IDs are not unique because each polygon is treated independently and the ID counter resets in between.

Trajectory dataframe must have at least two rows

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.