This is modified QGIS Automap from VAM HQ and adjusted for RBB Seasonal Monitor products. As RBB countries are spanning from South Asia to the Pacific, we divided the countries into 3 region/window analysis.
Below is the list
- Region 1: TJK, KGZ, AFG and PAK
- Region 2: IND, BTN, NPL, BGD, LKA, MMR, THA, KHM, LAO, VNM, PHL and DPRK
- Region 3: IDN, TLS, PNG and SLB
The code for the automap is written in Python 3. It is recommended to use either the Miniconda3 (minimal Anaconda) or Anaconda3 distribution. The below instructions will be Anaconda specific (although relevant to any Python virtual environment), and assume the use of a bash shell.
-
Download and install Anaconda Python on your machine for macOS or Linux or Windows.
Or you can use Miniconda for macOS or Linux and Windows. And follow the installation guideline for macOS, Linux and Windows
-
Download and install QGIS Long Term Release 3.16.8 on your machine for macOS or Linux or Windows.
-
Download automap_RBB folder and it's content via this link: https://github.com/wfpidn/automap_RBB/archive/refs/heads/main.zip. The folder consist of:
├── csv # List of product, code for ach product and color ramp.
├── maps # Default output folder for maps
├── products # Default input folder with GeoTIFF files
├── scripts # Python scripts
│ ├── __pycache__
│ │ ├── **/*.pyc
│ ├── function.py
│ ├── preProduce.py
│ ├── produce.py
├── templates # Layers, logo, layer styles and qgz templates
│ ├── _layer_styles # Symbology in `*.qml` format
│ │ ├── **/*.qml
│ ├── _layers # World shapefile from GADM, Marine Regions, Global Lake
│ │ ├── **/*.shp
│ │ ├── **/*.dbf
│ │ ├── **/*.shx
│ │ ├── **/*.prj
│ ├── _logos # VAM food security logo in various format
│ │ ├── **/*.svg
│ │ ├── **/*.png
│ │ ├── **/*.jpg
│ ├── _qgz # QGIS project files for all the region
│ │ ├── **/*.qgz
├── automap.py # Main python script to execute (to produce png maps)
├── automapQGIS.yml # yml file for creating the environment
├── README.md # Readme file
- Extract it into your working directory, you will have
automap_RBB
folder. - Download geospatial data from this link: https://www.dropbox.com/s/ptfdp1p9ltrvwwa/_layers.zip?dl=0
- Extract above
zip
file and move the contents toautomap_RBB/templates/_layers
A new Anaconda environment can be created using the conda environment management system that comes packaged with Anaconda.
This step must only be done the first time. Once the environment has been created there is no need to do it again.
-
Navigate to
automap_RBB
folder in your Terminal or Command-Prompt -
Create the environment from the
automapQGIS.yml
file.Type
conda env create -f automapQGIS.yml
then execute. -
Activate the environment by typing
conda activate automapQGIS
then execute.
The environment now has been activated. The python scripts must be run inside this environment in order to work.
You need to get latest seasonal monitoring geospatial data from VAM HQ, contact Giancarlo Pini to get the data. Usually the latest data in IDRISI format (*.rst
) are uploaded in this folder, link: https://drive.google.com/drive/u/0/folders/1kmpsja6_5BYhj7AtxUPou3e6BIOVZTJk.
Then you can easily convert it to GeoTIFF using GDAL. If you does not have GDAL in your machine, pelase install it via conda
.
-
Install GDAL, type in your Terminal or Command-Prompt
conda install -c conda-forge gdal
-
Download latest
*.rst
files from above link, let assume the result are insideDownloads
folder (It can be in~/Downloads
orC:/Download
) and your file isdrive-download-20210811T141722Z-001.zip
. -
Unzip file
drive-download-20210811T141722Z-001.zip
-
Navigate to folder
drive-download-20210811T141722Z-001
, and create a new folder calledTIF
-
Convert
*.rst
to*.tif
by typing below script in your Terminal or Command-Promptfor i in `find *.rst`; do gdal_translate -of GTiff -co COMPRESS=LZW -co PREDICTOR=1 $i ./TIF/$i.tif; done
-
Move all the result (
GeoTIFF
files) insideTIF
folder toautomap_RBB/products
. The files must respect the naming convention.
Alternative way, you can request to VAM HQ all the data in GeoTIFF format, no need to doing conversion as explain in above steps.
In your Terminal or Command-Prompt, navigate to the automap_RBB
folder.
Run the automap.py script by typing python automap.py
By default all *.tif
files in the products folder will be mapped as *.png
maps in the maps
folder. The maps will be stored in 3 different subfolders (Region1
, Region2
and Region3
) for each sub-region.
When running the script, 4 additional flags can be added:
--select # A window with the available product types will appear so that the user can choose which products to map.
# By default all of the products are mapped
--overwrite # All the products will be mapped
# By default, only the products which are not present in the output folder will be mapped
--input # Select input folder with the .tiff files
# Default is automap_RBB/products
--output # Select output folder for the PNG maps
# Default is automap_RBB/maps
Example:
python automap.py –-select --input
or python automap.py --overwrite
The user can add a new product type.
-
Update the
product_types.csv
file inautomap_RBB/csv
You should add the name of the product type (in capital letters), the title and the name of its color-ramp.
-
Create the associated color ramp (
.qml
file) and add it inautomap_RBB/templates/_layer_styles
Region 1
Region 2
Region 3
Thanks to Juliette Holland, Sophia Rosa, Irene Ferrari and Giancarlo Pini
Benny Istanto | UN World Food Programme - Indonesia | benny.istanto@wfp.org