Blog d’Anita Graser

https://anitagraser.com

  • Movement data in GIS #24: MovingPandas hands-on tutorials 11 septembre 2019
    Last week, I had the pleasure to give a movement data analysis workshop at the OpenGeoHub summer school at the University of Münster in Germany. The workshop materials consist of three Jupyter notebooks that have been designed to also support self-study outside of a workshop setting. So you can try them out as well! All materials are available on Github: Tutorial 0 provides an introduction to the MovingPandas Trajectory class. Tutorials 1 and 2 provide examples with real-world datasets covering one day of ship movement near Gothenburg and multiple years of gull migration, respectively. Here’s a quick preview of the bird migration data analysis tutorial (click for full size): Tutorial 2: Bird migration data analysis You can run all three Jupyter notebooks online using MyBinder (no installations required). Alternatively or if you want to dig deeper: installation instructions are available on movingpandas.org The OpenGeoHub summer school this year had a strong focus on spatial analysis with R and GRASS (sometimes mixing those two together). It was great to meet @mdsumner (author of R trip) and @edzerpebesma (author of R trajectories) for what might have well been the ultimate movement …
  • Five QGIS network analysis toolboxes for routing and isochrones 7 juillet 2019
    In the past, network analysis capabilities in QGIS were rather limited or not straight-forward to use. This has changed! In QGIS 3.x, we now have a wide range of network analysis tools, both for use case where you want to use your own network data, as well as use cases where you don’t have access to appropriate data or just prefer to use an existing service. This blog post aims to provide an overview of the options: Based on local network data Default QGIS Processing network analysis tools QNEAT3 plugin Based on web services Hqgis plugin (HERE) ORS Tools plugin (openrouteservice.org) TravelTime platform plugin (TravelTime platform) All five options provide Processing toolbox integration but not at the same level. If you are a regular reader of this blog, you’re probably also aware of the pgRoutingLayer plugin. However, I’m not including it in this list due to its dependency on PostGIS and its pgRouting extension. Processing network analysis tools The default Processing network analysis tools are provided out of the box. They provide functionality to compute least cost paths and service areas (distance or time) based on your own network data. Inputs can be individual points or layer …
  • Movement data in GIS #23: trajectories in context 22 mai 2019
    Today’s post continues where “Why you should be using PostGIS trajectories” leaves off. It’s the result of a collaboration with Eva Westermeier. I had the pleasure to supervise her internship at AIT last year and also co-supervised her Master’s thesis [0] on the topic of enriching trajectories with information about their geographic context. Context-aware analysis of movement data is crucial for different domains and applications, from transport to ecology. While there is a wealth of data, efficient and user-friendly contextual trajectory analysis is still hampered by a lack of appropriate conceptual approaches and practical methods. (Westermeier, 2018) Part of the work was focused on evaluating different approaches to adding context information from vector datasets to trajectories in PostGIS. For example, adding land cover context to animal movement data or adding information on anchoring and harbor areas to vessel movement data. Classic point-based model vs. line-based model The obvious approach is to intersect the trajectory points with context data. This is the classic point data model of contextual trajectories. It’s straightforward to add context information in the point-base …
  • Flow maps in QGIS – no plugins needed! 3 mai 2019
    If you’ve been following my posts, you’ll no doubt have seen quite a few flow maps on this blog. This tutorial brings together many different elements to show you exactly how to create a flow map from scratch. It’s the result of a collaboration with Hans-Jörg Stark from Switzerland who collected the data. The flow data The data presented in this post stems from a survey conducted among public transport users, especially commuters (available online at: https://de.surveymonkey.com/r/57D33V6). Among other questions, the questionnair asks where the commuters start their journey and where they are heading. The answers had to be cleaned up to correct for different spellings, spelling errors, and multiple locations in one field. This cleaning and the following geocoding step were implemented in Python. Afterwards, the flow information was aggregated to count the number of nominations of each connection between different places. Finally, these connections (edges that contain start id, destination id and number of nominations) were stored in a text file. In addition, the locations were stored in a second text file containing id, location name, and co-ordinates. Why was this data collected? …
  • Movement data in GIS and the AI hype 1 mai 2019
    This post looks into the current AI hype and how it relates to geoinformatics in general and movement data analysis in GIS in particular. This is not an exhaustive review but aims to highlight some of the development within these fields. There are a lot of references in this post, including some to previous work of mine, so you can dive deeper into this topic on your own. I’m looking forward to reading your take on this topic in the comments! Introduction to AI The dream of artificial intelligence (AI) that can think like a human (or even outsmart one) reaches back to the 1950s (Fig. 1, Tandon 2016). Machine learning aims to enable AI. However, classic machine learning approaches that have been developed over the last decades (such as: decision trees, inductive logic programming, clustering, reinforcement learning, neural networks, and Bayesian networks) have failed to achieve the goal of a general AI that would rival humans. Indeed, even narrow AI (technology that can only perform specific tasks) was mostly out of reach (Copeland 2018). However, recent increases in computing power (be it GPUs, TPUs or CPUs) and algorithmic advances, particularly those based on neural networks, hav …
  • Movement data in GIS #21: new interactive notebook to get started with MovingPandas 25 avril 2019
    MovingPandas is my attempt to provide a pure Python solution for trajectory data handling in GIS. MovingPandas provides trajectory classes and functions built on top of GeoPandas.  To lower the entry barrier to getting started with MovingPandas, there’s now an interactive iPython notebook hosted on MyBinder. This notebook provides all the necessary imports and demonstrates how to create a Trajectory object. Launch MyBinder for MovingPandas to get started! …
  • Stand-alone PyQGIS scripts with OSGeo4W 3 mars 2019
    PyQGIS scripts are great to automate spatial processing workflows. It’s easy to run these scripts inside QGIS but it can be even more convenient to run PyQGIS scripts without even having to launch QGIS. To create a so-called “stand-alone” PyQGIS script, there are a few things that need to be taken care of. The following steps show how to set up PyCharm for stand-alone PyQGIS development on Windows10 with OSGeo4W. An essential first step is to ensure that all environment variables are set correctly. The most reliable approach is to go to C:\OSGeo4W64\bin (or wherever OSGeo4W is installed on your machine), make a copy of qgis-dev-g7.bat (or any other QGIS version that you have installed) and rename it to pycharm.bat: Instead of launching QGIS, we want that pycharm.bat launches PyCharm. Therefore, we edit the final line in the .bat file to start pycharm64.exe: In PyCharm itself, the main task to finish our setup is configuring the project interpreter: First, we add a new “system interpreter” for Python 3.7 using the corresponding OSGeo4W Python installation. To finish the interpreter config, we need to add two additional paths pointing to QGIS\python and QGIS\python\plugins: That’s it …
  • Easy Processing scripts comeback in QGIS 3.6 2 mars 2019
    When QGIS 3.0 was release, I published a Processing script template for QGIS3. While the script template is nicely pythonic, it’s also pretty long and daunting for non-programmers. This fact didn’t go unnoticed and Nathan Woodrow in particular started to work on a QGIS enhancement proposal to improve the situation and make writing Processing scripts easier, while – at the same time – keeping in line with common Python styles. While the previous template had 57 lines of code, the new template only has 26 lines – 50% less code, same functionality! (Actually, this template provides more functionality since it also tracks progress and ensures that the algorithm can be cancelled.) from qgis.processing import alg from qgis.core import QgsFeature, QgsFeatureSink @alg(name= »ex_new », label=alg.tr(« Example script (new style) »), group= »examplescripts », group_label=alg.tr(« Example Scripts »)) @alg.input(type=alg.SOURCE, name= »INPUT », label= »Input layer ») @alg.input(type=alg.SINK, name= »OUTPUT », label= »Output layer ») def testalg(instance, parameters, context, feedback, inputs): «  » » Description goes here. (Don’t delete this! Removing this comment will cause errors.) «  » » source = instance.paramete …
  • Movement data in GIS #20: Trajectools v1 released! 2 février 2019
    In previous posts, I already wrote about Trajectools and some of the functionality it provides to QGIS Processing including: Creating trajectories from points Clipping trajectories by extent Splitting trajectories by date There are also tools to compute heading and speed which I only talked about on Twitter. Trajectools is now available from the QGIS plugin repository. The plugin includes sample data from MarineCadastre downloads and the Geolife project. Under the hood, Trajectools depends on GeoPandas! If you are on Windows, here’s how to install GeoPandas for OSGeo4W: OSGeo4W installer: install python3-pip Environment variables: add GDAL_VERSION = 2.3.2 (or whichever version your OSGeo4W installation currently includes) OSGeo4W shell: call C:\OSGeo4W64\bin\py3_env.bat OSGeo4W shell: pip3 install geopandas (this will error at fiona) From https://www.lfd.uci.edu/~gohlke/pythonlibs/#fiona: download Fiona-1.7.13-cp37-cp37m-win_amd64.whl OSGeo4W shell: pip3 install path-to-download\Fiona-1.7.13-cp37-cp37m-win_amd64.whl OSGeo4W shell: pip3 install geopandas (optionally) From https://www.lfd.uci.edu/~gohlke/pythonlibs/#rtree: download Rtree-0.8.3-cp37-cp37m-win_amd64.whl and pip3 instal …
  • Dealing with delayed measurements in (Geo)Pandas 27 janvier 2019
    Yesterday, I learned about a cool use case in data-driven agriculture that requires dealing with delayed measurements. As Bert mentions, for example, potatoes end up in the machines and are counted a few seconds after they’re actually taken out of the ground: Yield mapping in agriculture, there’s a delay of ~10 – 15 seconds in data logging between intake of potato and the measurement which is at the ‘end’ of the processing in the machine, during which the machine drives forward. pic.twitter.com/Bo60oUIH2e — Bert Rijk (@BertRijk) January 26, 2019 https://platform.twitter.com/widgets.js Therefore, in order to accurately map yield, we need to take this temporal offset into account. We need to make sure that time and location stay untouched, but need to shift the potato count value. To support this use case, I’ve implemented apply_offset_seconds() for trajectories in movingpandas: def apply_offset_seconds(self, column, offset): self.df[column] = self.df[column].shift(offset, freq=’1s’) The following test illustrates its use: you can see how the value column is shifted by 120 second. Geometry and time remain unchanged but the value column is shifted accordingly. In this test, we look at …