SlideShare ist ein Scribd-Unternehmen logo
1 von 20
MOVINGPANDAS
https://github.com/anitagraser/movingpandas
Anita Graser
@underdarkGIS
Unfortunately not this kind of Panda …
MOVINGPANDAS
… but this:
MOVINGPANDAS
https://pandas.pydata.org
MOTIVATION
https://anitagraser.com/2016/09/18/movement-data-in-gis-issues-ideas/
Movement data is …
… geographic
… temporal
 Geographic features with
timestamps?
 Timeseries with geometries?
MOTIVATION
e.g.
id,x,y,t,state,type_code
a,11.0,2.0,2012-01-17T12:33:51Z,walking,1
a,12.0,3.0,2012-01-17T12:36:11Z,walking,1
a,10.0,3.0,2012-01-17T12:36:51Z,walking,2
b,10.0,2.0,2012-01-17T12:33:51Z,walking,2
b,11.0,3.0,2012-01-17T12:36:51Z,walking,2
c,12.0,1.0,2012-01-17T12:33:51Z,vehicle,1
c,10.0,2.0,2012-01-17T12:35:21Z,vehicle,1
c,11.0,3.0,2012-01-17T12:36:51Z,vehicle,1
...
https://anitagraser.com/2017/10/15/movement-data-in-gis-9-trajectory-data-models/
GIS – AN OBVIOUS CHOICE?
704/05/2019
Simple Features
 Points
 No built-in logic @ chronological order & moving object identity
 Lines
 Only attributes for whole trajectory (segment)
 No timestamp for each location
GIS – AN OBVIOUS CHOICE?
Pandas
… developed in the context of financial modeling
 extensive set of tools for working with dates, times,
and time-indexed data
GeoPandas
… extends the datatypes used by pandas to allow spatial
operations on geometric types
 http://geopandas.org
WHY PANDAS?
https://anitagraser.com/2018/11/18/movement-data-in-gis-16-towards-pure-python-trajectories-using-geopandas/
Trajectory
id: string
df: GeoDataFrame
crs: string
parent: Trajectory
__str__()
set_crs(crs)
has_parent(): boolean
to_linestring(): shapely.geometry.LineString
to_linestringm_wkt(): string
get_start_location(): shapely.geometry.Point
get_end_location(): shapely.geometry.Point
get_bbox(): (minx, miny, maxx, maxy) tuple
get_start_time(): datetime
get_end_time(): datetime
get_duration(): timedelta
get_length(): float
get_direction(): float
get_row_at(timestamp, method='nearest'):
pandas.Series
get_position_at(timestamp, method='nearest'):
shapely.geometry.Point
get_linestring_between(timestamp1,
timestamp2): shapely.geometry.LineString
get_segment_between(timestamp1, timestamp2):
Trajectory
add_direction()
add_speed()
make_line(df): shapely.geometry.LineString
clip(shapely.geometry.polygon): Trajectory
intersection(fiona.feature): Trajectory
MOVINGPANDAS TRAJECTORY CLASS
Graser (in press) MovingPandas: Efficient Structures for Movement Data in Python. GI_Forum ‒ Journal of Geographic Information Science
>>> import pandas as pd
>>> from geopandas import read_file
>>> from shapely.geometry import Polygon
>>> from trajectory import Trajectory
>>> df = read_file('demodata_geolife.gpkg')
>>> df['t'] = pd.to_datetime(df['t'])
>>> df = df.set_index('t')
>>> print("Finished reading {} rows".format(len(df)))
Finished reading 5908 rows
EXAMPLE:
READING TRAJECTORY DATA FROM GEOPACKAGE
Graser (in press) MovingPandas: Efficient Structures for Movement Data in Python. GI_Forum ‒ Journal of Geographic Information Science
>>> trajectories = []
>>> for key, values in df.groupby(['trajectory_id']):
>>> trajectory = Trajectory(key, values)
>>> print(trajectory)
>>> trajectories.append(trajectory)
>>> print("Finished creating {} trajectories".format(len(trajectories)))
Trajectory 1 (2008-12-11 04:42:14 to 2008-12-11 05:15:46) | Size: 466 | Length: 6210.1m
LINESTRING (116.391305 39.898573, 116.391317 39.898617, 116.390928 39.898613, ...
Trajectory 2 (2009-06-29 07:02:25 to 2009-06-29 11:13:12) | Size: 897 | Length: 38728.7m
LINESTRING (116.590957 40.071961, 116.590905 40.072007, 116.590879 40.072027, ...
Trajectory 3 (2009-02-04 04:32:53 to 2009-02-04 11:20:12) | Size: 1810 | Length: 12739.2m
LINESTRING (116.385689 39.899773, 116.385654 39.899651, 116.385548 39.899699, ...
...
Finished creating 5 trajectories
EXAMPLE:
READING TRAJECTORY DATA FROM GEOPACKAGE
Graser (in press) MovingPandas: Efficient Structures for Movement Data in Python. GI_Forum ‒ Journal of Geographic Information Science
>>> xmin, xmax, ymin, ymax = 116.3685035,116.3702945,39.904675,39.907728
>>> polygon = Polygon([(xmin,ymin), (xmin,ymax), (xmax,ymax), (xmax,ymin), (xmin,ymin)])
>>> intersections = []
>>> for key, values in df.groupby(['trajectory_id']):
>>> traj = Trajectory(key, values)
>>> for intersection in traj.clip(polygon):
>>> intersections.append(intersection)
>>> print("Found {} intersections".format(len(intersections)))
Found 3 intersections
EXAMPLE:
… AND CLIPPING BY POLYGON
Graser (in press) MovingPandas: Efficient Structures for Movement Data in Python. GI_Forum ‒ Journal of Geographic Information Science
EXAMPLE:
TIME SERIES USE CASE IN AGRICULTURE
04/05/2019
Offset function
keep time/location & shift value
def apply_offset_seconds(self, column, offset):
self.df[column] = self.df[column]
.shift(offset, freq='1s’)
https://anitagraser.com/2019/01/27/dealing-with-delayed-measurements-in-geopandas/
LIVE DEMO ON MYBINDER.ORG
https://anitagraser.com/2018/11/18/movement-data-in-gis-16-towards-pure-python-trajectories-using-geopandas/
Trajectools plugin
for Processing toolbox
MOVINGPANDAS INTEGRATION IN QGIS
https://anitagraser.com/2019/02/02/movement-data-in-gis-20-trajectools-v1-released/
1704/05/2019
https://anitagraser.com/2019/01/26/movement-data-in-gis-19-splitting-trajectories-by-date/
1804/05/2019
https://anitagraser.com/2019/01/26/movement-data-in-gis-19-splitting-trajectories-by-date/
 Looking for contributors  talks & workshops to spread the word
 More features & tests
 Create a MovingPandas Python package
NEXT STEPS
anita.graser@ait.ac.at
@underdarkGIS
anitagraser.com
ANITA GRASER

Weitere ähnliche Inhalte

Mehr von Anita Graser

Trajectory Visualization in Notebook Environments @ GI_Salzburg 2022
Trajectory Visualization in Notebook Environments @ GI_Salzburg 2022Trajectory Visualization in Notebook Environments @ GI_Salzburg 2022
Trajectory Visualization in Notebook Environments @ GI_Salzburg 2022Anita Graser
 
Movement Data in GIS - Geobeer Lightning Talk, 2021-03-08
Movement Data in GIS - Geobeer Lightning Talk, 2021-03-08Movement Data in GIS - Geobeer Lightning Talk, 2021-03-08
Movement Data in GIS - Geobeer Lightning Talk, 2021-03-08Anita Graser
 
Exploratory Analysis of Massive Movement Data (RGS-IBG GIScience Research Gro...
Exploratory Analysis of Massive Movement Data (RGS-IBG GIScience Research Gro...Exploratory Analysis of Massive Movement Data (RGS-IBG GIScience Research Gro...
Exploratory Analysis of Massive Movement Data (RGS-IBG GIScience Research Gro...Anita Graser
 
From Simple Features to Moving Features and Beyond? at OGC Member Meeting, Se...
From Simple Features to Moving Features and Beyond? at OGC Member Meeting, Se...From Simple Features to Moving Features and Beyond? at OGC Member Meeting, Se...
From Simple Features to Moving Features and Beyond? at OGC Member Meeting, Se...Anita Graser
 
Data-driven Trajectory Prediction in Maritime LBS
Data-driven Trajectory Prediction in Maritime LBSData-driven Trajectory Prediction in Maritime LBS
Data-driven Trajectory Prediction in Maritime LBSAnita Graser
 
QGIS das Opensource GIS at Linuxwochen Wien 2019
QGIS das Opensource GIS at Linuxwochen Wien 2019QGIS das Opensource GIS at Linuxwochen Wien 2019
QGIS das Opensource GIS at Linuxwochen Wien 2019Anita Graser
 
GIScience for Dynamic Transportation Systems, GIScience Colloquium, Universit...
GIScience for Dynamic Transportation Systems, GIScience Colloquium, Universit...GIScience for Dynamic Transportation Systems, GIScience Colloquium, Universit...
GIScience for Dynamic Transportation Systems, GIScience Colloquium, Universit...Anita Graser
 
QGIS Neuigkeiten @ AGIT2017
QGIS Neuigkeiten @ AGIT2017QGIS Neuigkeiten @ AGIT2017
QGIS Neuigkeiten @ AGIT2017Anita Graser
 
Landmark-based instructions for pedestrian navigation systems using OSM
Landmark-based instructions for pedestrian navigation systems using OSMLandmark-based instructions for pedestrian navigation systems using OSM
Landmark-based instructions for pedestrian navigation systems using OSMAnita Graser
 
QGIS Processing at Linuxwochen Wien / PyDays 2017
QGIS Processing at Linuxwochen Wien / PyDays 2017QGIS Processing at Linuxwochen Wien / PyDays 2017
QGIS Processing at Linuxwochen Wien / PyDays 2017Anita Graser
 
Integrating Open Spaces into OSM Routing Graphs for Realistic Crossing Behavi...
Integrating Open Spaces into OSM Routing Graphs for Realistic Crossing Behavi...Integrating Open Spaces into OSM Routing Graphs for Realistic Crossing Behavi...
Integrating Open Spaces into OSM Routing Graphs for Realistic Crossing Behavi...Anita Graser
 
Neuigkeiten vom QGIS-Projekt - AGIT 2016
Neuigkeiten vom QGIS-Projekt - AGIT 2016Neuigkeiten vom QGIS-Projekt - AGIT 2016
Neuigkeiten vom QGIS-Projekt - AGIT 2016Anita Graser
 
Spatial Data Analysis & Visualization with QGIS - Vienna Data Science Meetup
Spatial Data Analysis & Visualization with QGIS - Vienna Data Science MeetupSpatial Data Analysis & Visualization with QGIS - Vienna Data Science Meetup
Spatial Data Analysis & Visualization with QGIS - Vienna Data Science MeetupAnita Graser
 
Better Urban Travel Time Estimates Using Street Network Centrality #Eurocarto15
Better Urban Travel Time Estimates Using Street Network Centrality #Eurocarto15Better Urban Travel Time Estimates Using Street Network Centrality #Eurocarto15
Better Urban Travel Time Estimates Using Street Network Centrality #Eurocarto15Anita Graser
 
Time Manager Vortrag vom QGIS-DE Anwendertreffen 2015
Time Manager Vortrag vom QGIS-DE Anwendertreffen 2015Time Manager Vortrag vom QGIS-DE Anwendertreffen 2015
Time Manager Vortrag vom QGIS-DE Anwendertreffen 2015Anita Graser
 
Time Manager Workshop vom QGIS-DE Anwendertreffen 2015
Time Manager Workshop vom QGIS-DE Anwendertreffen 2015Time Manager Workshop vom QGIS-DE Anwendertreffen 2015
Time Manager Workshop vom QGIS-DE Anwendertreffen 2015Anita Graser
 
Improving Navigation: Automated Name Extraction for Separately Mapped Pedestr...
Improving Navigation: Automated Name Extraction for Separately Mapped Pedestr...Improving Navigation: Automated Name Extraction for Separately Mapped Pedestr...
Improving Navigation: Automated Name Extraction for Separately Mapped Pedestr...Anita Graser
 
Routing mit OSM - #AGIT2015
Routing mit OSM - #AGIT2015Routing mit OSM - #AGIT2015
Routing mit OSM - #AGIT2015Anita Graser
 
QGIS jenseits von zwei Dimensionen - KAGIS-Fachtagung 2015
QGIS jenseits von zwei Dimensionen - KAGIS-Fachtagung 2015QGIS jenseits von zwei Dimensionen - KAGIS-Fachtagung 2015
QGIS jenseits von zwei Dimensionen - KAGIS-Fachtagung 2015Anita Graser
 
Time Manager Workshop at #QGIS2015 Conference in Nodebo
Time Manager Workshop at #QGIS2015 Conference in NodeboTime Manager Workshop at #QGIS2015 Conference in Nodebo
Time Manager Workshop at #QGIS2015 Conference in NodeboAnita Graser
 

Mehr von Anita Graser (20)

Trajectory Visualization in Notebook Environments @ GI_Salzburg 2022
Trajectory Visualization in Notebook Environments @ GI_Salzburg 2022Trajectory Visualization in Notebook Environments @ GI_Salzburg 2022
Trajectory Visualization in Notebook Environments @ GI_Salzburg 2022
 
Movement Data in GIS - Geobeer Lightning Talk, 2021-03-08
Movement Data in GIS - Geobeer Lightning Talk, 2021-03-08Movement Data in GIS - Geobeer Lightning Talk, 2021-03-08
Movement Data in GIS - Geobeer Lightning Talk, 2021-03-08
 
Exploratory Analysis of Massive Movement Data (RGS-IBG GIScience Research Gro...
Exploratory Analysis of Massive Movement Data (RGS-IBG GIScience Research Gro...Exploratory Analysis of Massive Movement Data (RGS-IBG GIScience Research Gro...
Exploratory Analysis of Massive Movement Data (RGS-IBG GIScience Research Gro...
 
From Simple Features to Moving Features and Beyond? at OGC Member Meeting, Se...
From Simple Features to Moving Features and Beyond? at OGC Member Meeting, Se...From Simple Features to Moving Features and Beyond? at OGC Member Meeting, Se...
From Simple Features to Moving Features and Beyond? at OGC Member Meeting, Se...
 
Data-driven Trajectory Prediction in Maritime LBS
Data-driven Trajectory Prediction in Maritime LBSData-driven Trajectory Prediction in Maritime LBS
Data-driven Trajectory Prediction in Maritime LBS
 
QGIS das Opensource GIS at Linuxwochen Wien 2019
QGIS das Opensource GIS at Linuxwochen Wien 2019QGIS das Opensource GIS at Linuxwochen Wien 2019
QGIS das Opensource GIS at Linuxwochen Wien 2019
 
GIScience for Dynamic Transportation Systems, GIScience Colloquium, Universit...
GIScience for Dynamic Transportation Systems, GIScience Colloquium, Universit...GIScience for Dynamic Transportation Systems, GIScience Colloquium, Universit...
GIScience for Dynamic Transportation Systems, GIScience Colloquium, Universit...
 
QGIS Neuigkeiten @ AGIT2017
QGIS Neuigkeiten @ AGIT2017QGIS Neuigkeiten @ AGIT2017
QGIS Neuigkeiten @ AGIT2017
 
Landmark-based instructions for pedestrian navigation systems using OSM
Landmark-based instructions for pedestrian navigation systems using OSMLandmark-based instructions for pedestrian navigation systems using OSM
Landmark-based instructions for pedestrian navigation systems using OSM
 
QGIS Processing at Linuxwochen Wien / PyDays 2017
QGIS Processing at Linuxwochen Wien / PyDays 2017QGIS Processing at Linuxwochen Wien / PyDays 2017
QGIS Processing at Linuxwochen Wien / PyDays 2017
 
Integrating Open Spaces into OSM Routing Graphs for Realistic Crossing Behavi...
Integrating Open Spaces into OSM Routing Graphs for Realistic Crossing Behavi...Integrating Open Spaces into OSM Routing Graphs for Realistic Crossing Behavi...
Integrating Open Spaces into OSM Routing Graphs for Realistic Crossing Behavi...
 
Neuigkeiten vom QGIS-Projekt - AGIT 2016
Neuigkeiten vom QGIS-Projekt - AGIT 2016Neuigkeiten vom QGIS-Projekt - AGIT 2016
Neuigkeiten vom QGIS-Projekt - AGIT 2016
 
Spatial Data Analysis & Visualization with QGIS - Vienna Data Science Meetup
Spatial Data Analysis & Visualization with QGIS - Vienna Data Science MeetupSpatial Data Analysis & Visualization with QGIS - Vienna Data Science Meetup
Spatial Data Analysis & Visualization with QGIS - Vienna Data Science Meetup
 
Better Urban Travel Time Estimates Using Street Network Centrality #Eurocarto15
Better Urban Travel Time Estimates Using Street Network Centrality #Eurocarto15Better Urban Travel Time Estimates Using Street Network Centrality #Eurocarto15
Better Urban Travel Time Estimates Using Street Network Centrality #Eurocarto15
 
Time Manager Vortrag vom QGIS-DE Anwendertreffen 2015
Time Manager Vortrag vom QGIS-DE Anwendertreffen 2015Time Manager Vortrag vom QGIS-DE Anwendertreffen 2015
Time Manager Vortrag vom QGIS-DE Anwendertreffen 2015
 
Time Manager Workshop vom QGIS-DE Anwendertreffen 2015
Time Manager Workshop vom QGIS-DE Anwendertreffen 2015Time Manager Workshop vom QGIS-DE Anwendertreffen 2015
Time Manager Workshop vom QGIS-DE Anwendertreffen 2015
 
Improving Navigation: Automated Name Extraction for Separately Mapped Pedestr...
Improving Navigation: Automated Name Extraction for Separately Mapped Pedestr...Improving Navigation: Automated Name Extraction for Separately Mapped Pedestr...
Improving Navigation: Automated Name Extraction for Separately Mapped Pedestr...
 
Routing mit OSM - #AGIT2015
Routing mit OSM - #AGIT2015Routing mit OSM - #AGIT2015
Routing mit OSM - #AGIT2015
 
QGIS jenseits von zwei Dimensionen - KAGIS-Fachtagung 2015
QGIS jenseits von zwei Dimensionen - KAGIS-Fachtagung 2015QGIS jenseits von zwei Dimensionen - KAGIS-Fachtagung 2015
QGIS jenseits von zwei Dimensionen - KAGIS-Fachtagung 2015
 
Time Manager Workshop at #QGIS2015 Conference in Nodebo
Time Manager Workshop at #QGIS2015 Conference in NodeboTime Manager Workshop at #QGIS2015 Conference in Nodebo
Time Manager Workshop at #QGIS2015 Conference in Nodebo
 

Kürzlich hochgeladen

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 

Kürzlich hochgeladen (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 

MovingPandas at PyDays Vienna 2019

  • 2.
  • 3. Unfortunately not this kind of Panda … MOVINGPANDAS
  • 6. Movement data is … … geographic … temporal  Geographic features with timestamps?  Timeseries with geometries? MOTIVATION e.g. id,x,y,t,state,type_code a,11.0,2.0,2012-01-17T12:33:51Z,walking,1 a,12.0,3.0,2012-01-17T12:36:11Z,walking,1 a,10.0,3.0,2012-01-17T12:36:51Z,walking,2 b,10.0,2.0,2012-01-17T12:33:51Z,walking,2 b,11.0,3.0,2012-01-17T12:36:51Z,walking,2 c,12.0,1.0,2012-01-17T12:33:51Z,vehicle,1 c,10.0,2.0,2012-01-17T12:35:21Z,vehicle,1 c,11.0,3.0,2012-01-17T12:36:51Z,vehicle,1 ... https://anitagraser.com/2017/10/15/movement-data-in-gis-9-trajectory-data-models/
  • 7. GIS – AN OBVIOUS CHOICE? 704/05/2019
  • 8. Simple Features  Points  No built-in logic @ chronological order & moving object identity  Lines  Only attributes for whole trajectory (segment)  No timestamp for each location GIS – AN OBVIOUS CHOICE?
  • 9. Pandas … developed in the context of financial modeling  extensive set of tools for working with dates, times, and time-indexed data GeoPandas … extends the datatypes used by pandas to allow spatial operations on geometric types  http://geopandas.org WHY PANDAS? https://anitagraser.com/2018/11/18/movement-data-in-gis-16-towards-pure-python-trajectories-using-geopandas/
  • 10. Trajectory id: string df: GeoDataFrame crs: string parent: Trajectory __str__() set_crs(crs) has_parent(): boolean to_linestring(): shapely.geometry.LineString to_linestringm_wkt(): string get_start_location(): shapely.geometry.Point get_end_location(): shapely.geometry.Point get_bbox(): (minx, miny, maxx, maxy) tuple get_start_time(): datetime get_end_time(): datetime get_duration(): timedelta get_length(): float get_direction(): float get_row_at(timestamp, method='nearest'): pandas.Series get_position_at(timestamp, method='nearest'): shapely.geometry.Point get_linestring_between(timestamp1, timestamp2): shapely.geometry.LineString get_segment_between(timestamp1, timestamp2): Trajectory add_direction() add_speed() make_line(df): shapely.geometry.LineString clip(shapely.geometry.polygon): Trajectory intersection(fiona.feature): Trajectory MOVINGPANDAS TRAJECTORY CLASS Graser (in press) MovingPandas: Efficient Structures for Movement Data in Python. GI_Forum ‒ Journal of Geographic Information Science
  • 11. >>> import pandas as pd >>> from geopandas import read_file >>> from shapely.geometry import Polygon >>> from trajectory import Trajectory >>> df = read_file('demodata_geolife.gpkg') >>> df['t'] = pd.to_datetime(df['t']) >>> df = df.set_index('t') >>> print("Finished reading {} rows".format(len(df))) Finished reading 5908 rows EXAMPLE: READING TRAJECTORY DATA FROM GEOPACKAGE Graser (in press) MovingPandas: Efficient Structures for Movement Data in Python. GI_Forum ‒ Journal of Geographic Information Science
  • 12. >>> trajectories = [] >>> for key, values in df.groupby(['trajectory_id']): >>> trajectory = Trajectory(key, values) >>> print(trajectory) >>> trajectories.append(trajectory) >>> print("Finished creating {} trajectories".format(len(trajectories))) Trajectory 1 (2008-12-11 04:42:14 to 2008-12-11 05:15:46) | Size: 466 | Length: 6210.1m LINESTRING (116.391305 39.898573, 116.391317 39.898617, 116.390928 39.898613, ... Trajectory 2 (2009-06-29 07:02:25 to 2009-06-29 11:13:12) | Size: 897 | Length: 38728.7m LINESTRING (116.590957 40.071961, 116.590905 40.072007, 116.590879 40.072027, ... Trajectory 3 (2009-02-04 04:32:53 to 2009-02-04 11:20:12) | Size: 1810 | Length: 12739.2m LINESTRING (116.385689 39.899773, 116.385654 39.899651, 116.385548 39.899699, ... ... Finished creating 5 trajectories EXAMPLE: READING TRAJECTORY DATA FROM GEOPACKAGE Graser (in press) MovingPandas: Efficient Structures for Movement Data in Python. GI_Forum ‒ Journal of Geographic Information Science
  • 13. >>> xmin, xmax, ymin, ymax = 116.3685035,116.3702945,39.904675,39.907728 >>> polygon = Polygon([(xmin,ymin), (xmin,ymax), (xmax,ymax), (xmax,ymin), (xmin,ymin)]) >>> intersections = [] >>> for key, values in df.groupby(['trajectory_id']): >>> traj = Trajectory(key, values) >>> for intersection in traj.clip(polygon): >>> intersections.append(intersection) >>> print("Found {} intersections".format(len(intersections))) Found 3 intersections EXAMPLE: … AND CLIPPING BY POLYGON Graser (in press) MovingPandas: Efficient Structures for Movement Data in Python. GI_Forum ‒ Journal of Geographic Information Science
  • 14. EXAMPLE: TIME SERIES USE CASE IN AGRICULTURE 04/05/2019 Offset function keep time/location & shift value def apply_offset_seconds(self, column, offset): self.df[column] = self.df[column] .shift(offset, freq='1s’) https://anitagraser.com/2019/01/27/dealing-with-delayed-measurements-in-geopandas/
  • 15. LIVE DEMO ON MYBINDER.ORG https://anitagraser.com/2018/11/18/movement-data-in-gis-16-towards-pure-python-trajectories-using-geopandas/
  • 16. Trajectools plugin for Processing toolbox MOVINGPANDAS INTEGRATION IN QGIS https://anitagraser.com/2019/02/02/movement-data-in-gis-20-trajectools-v1-released/
  • 19.  Looking for contributors  talks & workshops to spread the word  More features & tests  Create a MovingPandas Python package NEXT STEPS

Hinweis der Redaktion

  1. https://anitagraser.com/2019/01/26/movement-data-in-gis-19-splitting-trajectories-by-date/