Skip to content

PyQGIS script tool to aid manual review of satellite images/ground truth

License

Notifications You must be signed in to change notification settings

96francesco/pyqgis-raster-inspection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raster inspection with QGIS

About

During my thesis work at Wageningen University & Research, I realized I had to manually review my ground truth data. I needed a way to quickly inspect the raster data and see if the ground truth data was correct. If not, I wanted to manually edit it or, if the discrepancy was too big, remove the ground truth - satellite image pair from my dataset. I discovered the QGIS plugin Serval, which allows to easily change the value of a raster layer with one click. However, I needed a way to quickly switch to the next raster layer and mark images to be removed from the dataset. That's why I created this Python script tool to ease this process.

Installation

Prerequisites

  • You need to install QGIS and launch it.
  • At the moment, the script asumes a specific naming convention for the images: - Ground truth images should be prefixed with gt_. For example, if you have a satellite image named image_0.tif, its corresponding ground truth image should be named image_gt_0.tif. - Both ground truth and corresponding satellite images must have a numeric index at the end of their names. This index is used by the script to determine the order of the images and switch to the next pair.

Download the script

  1. Clone the repository or download the ZIP file and extract it.
git clone https://github.com/your-github-username/pyqgis-raster-inspector.git
  1. Navigate to the downloaded/cloned directory

Setting up

  1. Place the satellite images and ground truth images in separate folders (you can use the example images provided in the repository to test the tool)
  2. Also create a folder for the excluded images.

Usage

  1. In QGIS, open the Python console (Plugins > Python Console)
  2. In the console pane, click on 'Show Editor' (the icon with the pencil). This will open the Python editor.
  3. Click on 'Open script' and select the 'main.py' file fro the downloaded/cloned repository.
  4. Modify the following lines with the correct paths to your folders:
image_folder = 'your\\image\\folder\\path'
gt_folder = 'your\\ground\\truth\\folder\\path'
exclusion_folder = 'your\\exclusion\\folder\\path'

You can also edit the following line, depending from which image yo want to start:

start_index = 0
  1. Run the script. The first pair of images will be loaded. You can use these methods:
    • 'load_next()' to load the next pair of images
    • 'handler.mark_image()' to mark the current pair of images to be excluded from the dataset. The images will be moved to the exclusion folder.

Example data

In the folder 'example_data' you can find some example images to test the tool. There are 5 Planet-NICFI images around the Democratic Republic of Congo, and their corresponding ground truth images. The ground truth images are binary masks, where 1 represents artisanal and small scale maning (ASM) and 0 represents anything else. The images are named according to the naming convention described above.

Contributing

Feel free to fork the repository, make changes, and submit pull requests. If you encounter any issues or have suggestions for improvements, please submit them as issues in the repository.

About

PyQGIS script tool to aid manual review of satellite images/ground truth

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages