WaterPix is a hydrologic data-based model used to perform water balances at a pixel scale.
There are two software options to run WaterPix on python:
The two options are equivalent, the only difference is about the underlying library to process the geospatial data.
- Python 2.7, preferably the Anaconda 64-bit distribution
- Python libraries:
- scipy (https://pypi.python.org/pypi/scipy)
- netCDF4 (https://pypi.python.org/pypi/netCDF4)
- pandas (https://pypi.python.org/pypi/pandas)
- rpy2 (https://pypi.python.org/pypi/rpy2)
- R 3.2.5 (https://cran.r-project.org/)
- R packages:
- Additional:
- gdal option
- Python GDAL package (https://pypi.python.org/pypi/GDAL)
- arcpy option
- ArcMap software (http://desktop.arcgis.com/en/arcmap/)
- gdal option
- Identify a folder in your computer that is recognized by python (e.g. ...\Lib\site-packages). You can check which folders are recognized by python with the following commands:
>>> import sys >>> sys.path ['', 'C:\\Program Files\\Anaconda2\\lib\\site-packages', ...
- Download or clone the waterpix module from the online repository and place it into the folder recognized by python.
- Check that waterpix works and that all the required modules are installed.
- gdal
>>> from waterpix import wp_gdal >>> wa_gdal.__all__ ['create_input_nc', 'run', 'output_nc_to_tiffs']
- arcpy
>>> from waterpix import wp_arcpy >>> wa_gdal.__all__ ['create_input_nc', 'run', 'output_nc_to_tiffs']
install the required modules, restart the python console, and repeat this step.ImportError: No module named ...
- gdal
from waterpix import wp_gdal
# Create input netcdf file
wp_gdal.create_input_nc(start_date='2010-01-01',
years=7, # 2010 - 2016
cellsize=0.01078
basin_shp = r'C:\Temp\Basin_A.shp',
p_path = r'C:\Precipitation\chirps-v2.0_monthly_{yyyy}{mm}.tif',
et_path = r'C:\Evapotranspiration\L1_AET_{yyyy}{mm}.tif',
eto_path = r'C:\ReferenceET\ETref_mm-month-1_monthly_{yyyy}.{mm}.01.tif',
lai_path = r'C:\LeafAreaIndex\LAI_{yyyy}{mm}.tif',
swi_path = r'C:\Soil Moisture\MonthlyMean\SWI_{yyyy}{mm}.tif',
swio_path = r'C:\Soil Moisture\FirstDay\SWI_{yyyy}{mm}.tif',
swix_path = r'C:\Soil Moisture\LastDay\SWI_{yyyy}{mm}.tif',
qratio_path = r'C:\Runoff Ratio\Qr_{yyyy}.tif',
rainydays_path = r'C:\Rainy days\chirps-v2.0.{yyyy}.{mm}_rainydays.tif',
thetasat_ras = r'C:\Saturated water content\wcsat_topsoil.tif',
rootdepth_ras = r'C:\Root depth\rd_mm.tif',
input_nc = r'C:\input_file_basin_A.nc')
# Run WaterPix
input_nc = r'C:\input_file_basin_A.nc'
output_nc=r'C:\output_file_basin_A.nc'
wp_gdal.run(input_nc, output_nc)
# Export rasters
output_path = r'C:\output_rasters'
wp_gdal.output_nc_to_tiffs(output_nc, output_path)
Espinoza-Dávalos, G. E., & Bastiaanssen, W. G. M. (2017). WaterPix: A Data Based Water Balance Model for Water Accounting. http://doi.org/10.5281/zenodo.1045574
Gonzalo E. Espinoza, PhD, MSc
Integrated Water Systems and Governance
IHE Delft Institute for Water Education
T: +31 15 2152313
E: [email protected]
I: un-ihe.org | wateraccounting.org | gespinoza.org