Skip to content

This repository includes algorithms for processing mosaics generated from images of Unmanned Aerial Vehicles (UAVs)

License

Notifications You must be signed in to change notification settings

Harmonize-Brazil/mosaic_utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mosaic_utils

Software License Documentation Status Software Life Cycle Release

About

This repository provides a set of scripts to process GeoTiFF (mosaics) from drones images.

Installation

Dependencies

Python 3.12.1, Geopandas and GDAL

Build Steps

Clone repository and create Virtual Environment:

git https://github.com/Harmonize-Brazil/mosaic_utils.git
cd mosaic_utils
python -m venv venv
source venv/bin/activate
pip3 install --upgrade pip setuptools wheel

Ensure you have GDAL installed on the host (Linux):

Using a Makefile, run this command at the terminal:

make

Or make step-by-step typing these commands below:

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install -y g++ && sudo apt-get install -y libgdal-dev gdal-bin python3-gdal
sudo apt-get install build-essential ##This one solves some bugs sometimes
pip3 install "numpy<2.0"
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
pip3 install GDAL==`gdal-config --version`
python -c "from osgeo import gdal; print(gdal.__version__)"

Problems with GDAL import, please see these related issues and solutions!

Tip

For Windows users, make sure you have created a virtual environment and have activated it before starting the next steps:

  1. Download a .whl file for the GDAL library, and install using that file. Select the desired version here.
  2. The command to install is pip install <path_to_whl_file>.

Source:

https://medium.com/@spatsel.cci/using-gdal-with-python-pip-and-windows-10-618d773d8926

Alternative:

Install dependencies and requirements:

pip3 install geopandas

Usage

Run crop_mosaic.py to crop a raster file based on the convex hull of the negative buffer from the mapped area:

python crop_mosaic.py  --mosaic_image /home/user/Desktop/HARMONIZE-Br_Project/src/FieldWorkCampaigns/Mocajuba2023/EscolaOficina_20231107/Mosaic/EscolaOficina_7nov-orthophoto.tif --threshold_area 0.005

The Region of Interest (ROI) is delimited by a polygon resulting from vectorizing the valid pixel values ​​of the raster, after that, the algorithm creates a negative buffer based on threshold_area that is a percentage of area mapped in meters. Finally, create a cropped raster using the convex hull of the negative buffer, which aims to create the final cropped mosaic without the serrated edges.

Or --help for further information about script options:

python crop_mosaic.py --help

License

About

This repository includes algorithms for processing mosaics generated from images of Unmanned Aerial Vehicles (UAVs)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published