Prototype workflow for adding new attributes to the DEA waterbodies product.
The development of the prototype workflow was funded and supported by Natural Hazards Research Australia through the project Identifying water sources for aerial firefighting. FrontierSI would like to acknowledge the collaborations that have made this project possible, with Natural Hazards Research Australia (NHRA), National Aerial Firefighting Centre (NAFC), Geoscience Australia (GA), AFAC and Country Fire Authority Victoria (CFA).
This repository uses two python files:
src/updatedb.py
src/attribute_functions.py
The first can be run from the command line to update the database. The second contains the utility functions that are used to calculate new attributes. For more information see the src directory.
This repository contains two data files
waterbodies_sample.shp
waterbodies_sample_updated.shp
The first contains NULL
values for the attributes to be calculated. The second has values for each attribute. The first should be used to build the database.
- Start your postgres server
- Create a new database called
waterbodies
- Run
CREATE EXTENSION postgis;
to enable postgis for thewaterbodies
database
- Open your terminal and navigate to this repository
- Create the conda environment for this repository by running
conda env create -f environment.yml
in your terminal - Activate the conda environement by running
conda activate waterbodies
- To add the sample waterbodies shapefile as a table in the database, run the following command, replacing
<host>
with the database host,<username>
with the database username, and<port>
with the database port
ogr2ogr -nln dea_waterbodies -nlt PROMOTE_TO_MULTI -lco GEOMETRY_NAME=geom -lco FID=fid -lco PRECISION=NO -mapFieldType Date=DateTime Pg:"dbname=waterbodies host=<host> user=<username> port=<port>" data/waterbodies_sample.shp
NOTE:
-mapFieldType Date=DateTime
is required to convert from the shapefile's Date type to a time-zone aware DateTime in the database.
- Launch the GeoServer and log in
- Create a workspace
- Add a new "PostGIS - PostGIS Database" store
- Publish the store
- Ensure the server is on
- Activate the conda environement by running
conda activate waterbodies
- Calculate and commit the new attributes by running
python src/updatedb.py --database waterbodies
NOTE: This currently runs on all waterbodies in the database, and is not configured to run on a per waterbody basis. To run on a per waterbody basis, update the script to accept the timeseries file directly, rather than reading it from the database. The script could then be triggered by providing a lifecycle hook for the timeseries file to an AWS Lambda (or eqivalent solution on alternative cloud provider).
Complete instructions for a local install on MacOS are provided in the workflow directory.