Skip to main content

Create annimated GIF from GeoTiff

QGIS

An introduction about using QGIS can be found here.

Installation

  • Linux

The script provided here was tested on Ubuntu 22.04:

bash sh.install

This shell script will install all python dependencies using poetry and also install qgis application on Ubuntu, which has a python library need to run the current code. PyQGIS is (normally) at /usr/lib/python3/dist-packages/.

Read more about QGIS installation in quickstart.

  • Windows

You can download the msi installer in this page. I'm using the Latest Release but if you want a more stable version, use Long Term Release. After downloading, just proceed with the installation (next-next-install).

Add Google Maps

  • Open QGIS
  • On the left side, right click on XYZ Tiles, and select New connection
  • Fill in the fields with the appropriate information. It will be similar to the image below.

According to this tutorial, there are different links for the available Google Maps layers:

Layer Link
Roadmap http://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}
Terrain http://mt1.google.com/vt/lyrs=p&x={x}&y={y}&z={z}
Altered roadmap http://mt1.google.com/vt/lyrs=r&x={x}&y={y}&z={z}
Satellite only http://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}
Terrain only http://mt1.google.com/vt/lyrs=t&x={x}&y={y}&z={z}
Hybrid http://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}

Testing

The following line tests the standalone implementation (i.e., you don't need to open QGIS) that reads a set of three geotiff images using pyQGIS, saves them as png files and also output an annimated gif with all three. This set contains the original image, the ground truth and the prediction maps.

Calling it on Windows

& 'C:\Program Files\QGIS 3.36.3\apps\Python312\python.exe' qgis_annimated.py --base images/Greece_2_hsi.tif --gt images/Greece_2_gt.tif --prediction images/Greece_2_prediction.tif

All paths shown here refers to my computer. You must change them accordingly. This example uses the sample image in the images folder.

Check the program parameters issuing:

& 'C:\Program Files\QGIS 3.36.3\apps\Python312\python.exe' qgis_annimated.py  --help
DEBUG:root:adding to sys.path: C:/Program Files/QGIS 3.36.3
Usage: qgis_annimated.py [OPTIONS]

Options:
  --base TEXT        Path to the real geotiff image  [required]
  --gt TEXT          Path to the ground truth geotiff image  [required]
  --prediction TEXT  Path to the predictions geotiff image  [required]
  --output TEXT      Path to save the png and gif images
  --debug / --info   set logging level to debug or info (default)
  --help             Show this message and exit.

The resulting gif is shown here.

Calling PyQGIS on Ubuntu

The code was tested on Ubuntu 22.04 with the default Python 3.10.12 installed. After installing QGIS as described in Debian/Ubuntu Quickstart, you will see that python-qgis is also installed. You can check the version using the following command inside python3 prompt

>>> import qgis.utils
>>> qgis.utils.Qgis.QGIS_VERSION
'3.22.4-Bialowieza'

Create GIF

You can call the program using:

cd moviq_qgis
poetry shell
python3 -m moviq_qgis --base images/Greece_2_hsi.tif --gt images/Greece_2_gt.tif --prediction images/Greece_2_prediction.tif

It will read the 3 images provided in the arguments, convert them to PNG and save these images on results. Those 3 PNG images are them merged in an annimated GIF, which will be also saved on results.

Distribute

You can use poetry to create the distribution (wheel) package to install in another project, e.g., moviq-segmentation.

cd moviq_qgis
poetry build

After running the command above, it will create in the folder dist a package moviq_qgis-0.1.0-py3-none-any.whl that you can install.

Metadata

Release files for moviq-qgis 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moviq-qgis 0.1.0
File Size Uploaded
moviq_qgis-0.1.0.tar.gz 7.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for moviq-qgis 0.1.0
File Interpreter ABI Platform
moviq_qgis-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 15.8 kB

Release files / moviq_qgis-0.1.0.tar.gz

Download URL moviq_qgis-0.1.0.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e00fa47879f81a4b5f1de4d403d2d4814a4bf0d31fa0fcedc281d699c5dd813e
BLAKE2b-256 checksum
How to use checksums
910171b1cbd0919da44a8d9ccc6f9bac894a0ae0c5f86200ad7fcc46926b6792
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.12 Linux/5.15.153.1-microsoft-standard-WSL2

Release files / moviq_qgis-0.1.0-py3-none-any.whl

Download URL moviq_qgis-0.1.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
af836f8ed72695ded5d002c8213ecb684db8a088c986f33a520086e464451272
BLAKE2b-256 checksum
How to use checksums
c1d263d05041cfb3b2a2de3cc9737ad6ac2b943c8bab192d8cc1fba12e12c7bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.10.12 Linux/5.15.153.1-microsoft-standard-WSL2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page