Skip to content


Repository files navigation

ICNF Fire Data Retriever

This project aims to provide a way of downloading and structuring data about wildfires in Portugal, in a manner that is easy to use. It downloads data from ICNF webservice at and inserts in a PostgreSQL/PostGIS db.
Main inspiration: VOSTPT


  • This was created to work on Linux (some adjustments must be done of other OS)
  • Python3 (libs: pandas, psycopg2)
  • PostgreSQL and PostGIS
  • GDAL

Database connection

Both and assume you have a PostgreSQL database (named e.g. icnf_fire_data) and a db.ini file with the following content:

host = HOST
port = PORT (default 5432)
dbname = DB_NAME
password = PASSWORD


This is the way to build what this project needs to run on your machine:

Retrieve data will download data from the webservice and transform it into CSV files (separator is |), one per year.
There is data from 2001.
If you just need old data in CSV, you do not need to run anything, just use the files under /data (the one for the current year is not updated)

  • Retrieve since 2001: python3 all
  • Retrieve a certain year (e.g. 2017): python3 2017
  • Retrieve last x days (e.g. 10): python3 ndays 10

From CSV to PostgreSQL reads the files under data/ and writes the data to the database.

  • Write everything in data/ to the db: python3
  • Write the last x days in data/ to the db (e.g. 10 days): python3 ndays 10

Polygons fetches geographical data from files referenced by the data and creates a multipolygon for each fire (that has referenced accessible files).
This is an experimental feature that lacks reliability because many links are dead and there seems to be no classification of the actual files.

  • Fetch polygons for the whole data set (this can take a lot of time to run): python3
  • Fetch polygons for fires in the last x days (e.g. 10 days): python3 ndays 10

Update utilities

There are utilities to update data regularly, in order to get new data and also update recent entries:

  • and is meant to be run daily and overwrites data from the last 5 days
  • and is meant to be run weekly and overwrites data from the last 30 days
  • and is meant to be run monthly and overwrites data from the last 730 days


Build from scratch (~30min)

  1. Create a db.ini file
  2. createdb DB_NAME ...
  3. python3 all
  4. ./

crontab for daily updates at 1 am

0 1 * * * /path/to/project/

crontab for weekly updates every sunday at 1 am

0 1 * * SUN /path/to/project/

crontab for monthly updates day 1 at 1 am

0 1 1 * * /path/to/project/


If you do not have an accessible PostgreSQL server and do not wish to install it in your machine, you can use a docker container to run it.

cd docker
./  #might need to use sudo


cd docker
./ --with-polygons #might need to use sudo

This will start a container on your machine with a PostgreSQL db containing the ICNF fire data.
You can check db connection params in docker/db.ini
./ --with-polygons will take a lot of time to run!
After build, you can start and stop your container with:
docker container start icnf_fire_data_container
docker container stop icnf_fire_data_container

You can also ssh to the running container with the following:
ssh-keygen -f ~/.ssh/known_hosts -R "[localhost]:8022" ; ssh fire@localhost -p8022
password: fire_pw


A way to fetch data about wild fires from the Portuguese Forest Authority







No releases published