Vortex Sanitizer Example - HydrologicEngineeringCenter/Vortex GitHub Wiki
The Vortex API is written in java allowing access via jython scripting. The following example demonstrates how to mask data below a specified threshold.
This batch script example uses two scripting files:
- A *.py file that contains the scripting logic
- A *.bat file that sets the environment and executes the python script
In addition to the script files, two jars were used:
The batch script filter_no_data.bat sets the environment and executes the script:
set "VORTEX_HOME=C:\workspace\git_clones\vortex-0.10.20-win-x64\vortex-0.10.20"
set "PATH=%VORTEX_HOME%\bin;%VORTEX_HOME%\bin\gdal;%PATH%"
set "GDAL_DRIVER_PATH=%VORTEX_HOME%\bin\gdal\gdalplugins"
set "GDAL_DATA=%VORTEX_HOME%\bin\gdal\gdal-data"
set "PROJ_LIB=%VORTEX_HOME%\bin\gdal\projlib"
set "CLASSPATH=%VORTEX_HOME%\lib\*"
C:\jython2.7.2\bin\jython.exe -J-Xmx10g -Djava.library.path=%VORTEX_HOME%\bin;%VORTEX_HOME%\bin\gdal C:\workspace\git_clones\Vortex\examples\src\main\jython\filter_no_data.py
cmd /k
The python script filter_no_data.py masks all grid cells less than 0:
from mil.army.usace.hec.vortex.math import BatchSanitizer
from mil.army.usace.hec.vortex import Options
import os
from glob import glob
d_files = glob(r"G:\UA\*.dss")
for dss_file in d_files:
basin = 'MISSOURI RIVER BASIN'
ds = 'UA_sanitized'
output_dss = dss_file[:-4] + '_noData.dss'
write_options = Options.create()
write_options.add('partF', ds )
write_options.add('partA', 'SHG')
write_options.add('partB', basin)
myImport = BatchSanitizer.builder()\
.pathToInput(dss_file)\
.selectAllVariables()\
.minimumThreshold(-0.1)\
.destination(output_dss)\
.writeOptions(write_options).build()
myImport.process()