Blog d’Anita Graser

https://anitagraser.com

  • 21 janvier 2023PyQGIS Jupyter notebooks on Windows using Conda
    The QGIS conda packages have been around for a while. One of their use cases, for example, is to allow Linux users to easily install multiple versions of QGIS. Similarly, we’ve seen posts on using PyQGIS in Jupyter notebooks. However, I find the setup with *.bat files rather tricky. This post presents a way to set up a conda environment with QGIS that is ready to be used in Jupyter notebooks. The first steps are to create a new environment and install QGIS. I use mamba for the installation step because it is faster than conda but you can use conda as well: (base) PS C:\Users\anita> conda create -n qgis python=3.9 (base) PS C:\Users\anita> conda activate qgis (qgis) PS C:\Users\anita> mamba install -c conda-forge qgis=3.28.2 (qgis) PS C:\Users\anita> qgis If we now try to import the qgis module in Python, we get an error: (qgis) PS C:\Users\anita> python Python 3.9.15 | packaged by conda-forge | (main, Nov 22 2022, 08:41:22) [MSC v.1929 64 bit (AMD64)] on win32 Type « help », « copyright », « credits » or « license » for more information. >>> import qgis Traceback (most recent call last): File «  », line 1, in ModuleNotFoundError: No module named ‘qgis’ To fix this error, we need to get the p …
  • 29 décembre 2022MovingPandas v0.13 & v0.14 released!
    December has been busy with two new MovingPandas releases: v0.13 and v0.14. The latest v0.14 release is now available from conda-forge. These releases are a huge step forward towards making MovingPandas easier to install with fewer mandatory dependencies. All interactive plotting libraries are now optional. So if you are using MovingPandas for trajectory data processing in the background and don’t need the interactive visualization features, the number of necessary libraries is now much lower. This (and the fact that GeoPandas is now shipped with OSGeo4W) will also make it easier to use MovingPandas in QGIS plugins. New features: #268 New add_angular_difference method Includes fixes and enhancements for: #267 Improved documentation: direction values are [0, 360) Behind the scenes: #269 Fixed read the docs build #261 Made interactive plotting libraries optional #257 Fixed broken pre-commit Created a Mastodon account As always, all tutorials are available from the movingpandas-examples repository and on MyBinder: If you have questions about using MovingPandas or just want to discuss new ideas, you’re welcome to join our discussion forum. …
  • 19 novembre 2022Visualizing trajectories with QGIS & MobilityDB
    In the previous post, we — creatively 😉 — used MobilityDB to visualize stationary IOT sensor measurements. This post covers the more obvious use case of visualizing trajectories. Thus bringing together the MobilityDB trajectories created in Detecting close encounters using MobilityDB 1.0 and visualization using Temporal Controller. Like in the previous post, the valueAtTimestamp function does the heavy lifting. This time, we also apply it to the geometry time series column called trip: SELECT mmsi, valueAtTimestamp(trip, ‘2017-05-07 08:55:40’) geom, valueAtTimestamp(SOG, ‘2017-05-07 08:55:40’) SOG FROM « public ». »ships » Using this SQL query, we again set up a — not yet Temporal Controller-controlled — QueryLayer. To configure Temporal Controller to update the timestamp in our SQL query, we again need to run the Python script from the previous post. With this done, we are all set up to animate and explore the movement patterns in our dataset: This post is part of a series. Read more about movement data in GIS. …
  • 16 novembre 2022MovingPandas v0.12 released!
    The latest v0.12 release is now available from conda-forge. This release contains some really cool new features, including: New function to add an acceleration column #253 We have further improved our repo setup by adding an action that automatically creates and publishes packages from releases, heavily inspired by the work of the GeoPandas team. Last but not least, we’ve created a Twitter account for the project. (And might soon add a Mastodon account as well.) As always, all tutorials are available from the movingpandas-examples repository and on MyBinder: If you have questions about using MovingPandas or just want to discuss new ideas, you’re welcome to join our discussion forum. …
  • 1 octobre 2022Visualizing IOT time series with QGIS & MobilityDB
    Today’s post presents an experiment in modelling a common scenario in many IOT setups: time series of measurements at stationary sensors. The key idea I want to explore is to use MobilityDB’s temporal data types, in particular the tfloat_inst and tfloat_seq for instances and sequences of temporal float values, respectively. For info on how to set up MobilityDB, please check my previous post. Setting up our DB tables As a toy example, let’s create two IOT devices (in table iot_devices) with three measurements each (in table iot_measurements) and join them to create the tfloat_seq (in table iot_joined): CREATE TABLE iot_devices ( id integer, geom geometry(Point, 4326) ); INSERT INTO iot_devices (id, geom) VALUES (1, ST_SetSRID(ST_MakePoint(1,1), 4326)), (2, ST_SetSRID(ST_MakePoint(2,3), 4326)); CREATE TABLE iot_measurements ( device_id integer, t timestamp, measurement float ); INSERT INTO iot_measurements (device_id, t, measurement) VALUES (1, ‘2022-10-01 12:00:00’, 5.0), (1, ‘2022-10-01 12:01:00’, 6.0), (1, ‘2022-10-01 12:02:00’, 10.0), (2, ‘2022-10-01 12:00:00’, 9.0), (2, ‘2022-10-01 12:01:00’, 6.0), (2, ‘2022-10-01 12:02:00’, 1.5); CREATE TABLE iot_joined AS SELECT dev.id, dev.ge …
  • 30 septembre 2022Detecting close encounters using MobilityDB 1.0
    It’s been a while since we last talked about MobilityDB in 2019 and 2020. Since then, the project has come a long way. It joined OSGeo as a community project and formed a first PSC, including the project founders Mahmoud Sakr and Esteban Zimányi as well as Vicky Vergara (of pgRouting fame) and yours truly. This post is a quick teaser tutorial from zero to computing closest points of approach (CPAs) between trajectories using MobilityDB. Setting up MobilityDB with Docker The easiest way to get started with MobilityDB is to use the ready-made Docker container provided by the project. I’m using Docker and WSL (Windows Subsystem Linux on Windows 10) here. Installing WLS/Docker is out of scope of this post. Please refer to the official documentation for your operating system. Once Docker is ready, we can pull the official container and fire it up: docker pull mobilitydb/mobilitydb docker volume create mobilitydb_data docker run –name « mobilitydb » -d -p 25432:5432 -v mobilitydb_data:/var/lib/postgresql mobilitydb/mobilitydb psql -h localhost -p 25432 -d mobilitydb -U docker Currently, the container provides PostGIS 3.2 and MobilityDB 1.0: Loading movement data into MobilityDB Once the c …
  • 14 août 2022Forget label buffers! Better maps with selective label masks in QGIS
    Cartographers use all kind of tricks to make their maps look deceptively simple. Yet, anyone who has ever tried to reproduce a cartographer’s design using only automatic GIS styling and labeling knows that the devil is in the details. This post was motivated by Mika Hall’s retro map style. New print designs on the way: these are some snippets from a project I began last year to map the provinces of Spain in a retro style, which I’ve decided to revisit this summer.Prints will be available later in the year! pic.twitter.com/gUJirBFv0x— Mike Hall (@thisismikehall) July 22, 2022https://platform.twitter.com/widgets.js There are a lot of things going on in this design but I want to draw your attention to the labels – and particularly their background: Detail of Mike’s map (c) Mike Hall. You can see that the rail lines stop right before they would touch the A in Valencia (or any other letters in the surrounding labels). This kind of effect cannot be achieved by good old label buffers because no matter which color we choose for the buffer, there will always be cases when the chosen color is not ideal, for example, when some labels are on land and some over water: Ordinary label buffers are …
  • 12 août 2022MovingPandas v0.11 released!
    The latest v0.11 release is now available from conda-forge. This release contains some really cool new algorithms: New minimum and Hausdorff distance measures #37New functions to add a timedelta column and get the trajectory sampling interval #233  As always, all tutorials are available from the movingpandas-examples repository and on MyBinder: The new distance measures are covered in tutorial #11: Computing distances between trajectories, as illustrated in tutorial #11 Computing distances between a trajectory and other geometry objects, as illustrated in tutorial #11 But don’t miss the great features covered by the other notebooks, such as outlier cleaning and smoothing: Trajectory cleaning and smoothing, as illustrated in tutorial #10 If you have questions about using MovingPandas or just want to discuss new ideas, you’re welcome to join our discussion forum. …
  • 9 juillet 2022Official Austrian basemap and cadastre vector tiles
    The BEV (Austrian Bundesamt für Eich- und Vermessungswesen) has recently published the Austrian cadastre as open data: #BundesamtfuerEichundVermessungswesen presents the online service of the #austrian #cadastre! That is HUGE news for the #geospatial #geoinfomatics community! #GISalzburg22 @GI_Salzburg pic.twitter.com/XT69l5KXRn— Johannes Scholz (@Joe_GISc) July 6, 2022https://platform.twitter.com/widgets.js The URLs for vector tiles and styles can be found on https://kataster.bev.gv.at under Guide – External The vector tile URL is: https://kataster.bev.gv.at/tiles/{kataster | symbole}/{z}/{x}/{y}.pbf There are 4 different style variations: https://kataster.bev.gv.at/styles/{kataster | symbole}/style_{vermv | ortho | basic | gis}.json When configuring the vector tiles in QGIS, we specify the desired tile and style URLs, for example: For example, this is the “gis” style: And this is the “basic” style: The second vector tile source I want to mention is basemap.at. It has been around for a while, however, early versions suffered from a couple of issues that have now been resolved. The basemap.at project provides extensive documentation on how to use the dataset in QGIS and other GIS, …
  • 19 juin 2022MovingPandas v0.10 released!
    The latest v0.10 release is now available from conda-forge. This release contains some really cool new algorithms: First initial MovingFeatures JSON (MF-JSON) supportImproved handling of local non-geographic coordinates, incl a new tutorial on this topicSpeed and direction column names can now be customized If you have questions about using MovingPandas or just want to discuss new ideas, you’re welcome to join our recently opened discussion forum. As always, all tutorials are available from the movingpandas-examples repository and on MyBinder: Besides others examples, the movingpandas-examples repo contains the following tech demo: an interactive app built with Panel that demonstrates different MovingPandas stop detection parameters To start the app, open the stopdetection-app.ipynb notebook and press the green Panel button in the Jupyter Lab toolbar: …