Mercurial > repos > climate > mean_per_zone
diff mean-per-zone.xml @ 0:40727a2668d6 draft
planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/mean-per-zone commit 24f20e7459e275c14376680f9bb91cd8ac26d9a5
| author | climate |
|---|---|
| date | Thu, 25 Apr 2019 14:31:54 -0400 |
| parents | |
| children | 639192aa63f5 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mean-per-zone.xml Thu Apr 25 14:31:54 2019 -0400 @@ -0,0 +1,102 @@ +<tool id="mean_per_zone" name="zonal statistics" version="0.1.0"> + <description>over each area</description> + <requirements> + <requirement type="package" version="3">python</requirement> + <requirement type="package" version="0.13.1">rasterstats</requirement> + <requirement type="package" version="0.4.1">geopandas</requirement> + <requirement type="package" version="0.11.3">xarray</requirement> + <requirement type="package" version="1.4.3.2">netcdf4</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ + mkdir -p shp_tmp && + ln -s '$shapefile' 'shp_tmp/temp.shp' && + ln -s '$shapefilex' 'shp_tmp/temp.shx' && + python3 '$__tool_directory__/zonal_statistics.py' + '$ifilename' + 'shp_tmp' + '$variable' + '$ofilename' + --stat '$stat_type' + #if str($title).strip() != '' + --title '$title' + #end if + ]]></command> + <inputs> + <param name="ifilename" type="data" format="netcdf,h5" label="input with geographical coordinates (netCDF format)"/> + <param name="shapefile" type="data" format="binary" label="shapefile (shp) with polygons for which statistics will be computed"/> + <param name="shapefilex" type="data" format="binary" label="shapefile (shx) with polygons for which statistics will be computed"/> + <!--param name="name" type="text" value="" label="Shapefile name" /--> + <param name="variable" type="text" value="TS" label="variable name as given in the netCDF file" /> + <param name="title" type="text" value="" label="Title of the generated plot" /> + <param name="stat_type" type="select"> + <option value="min" selected="true">minimum</option> + <option value="max" selected="true">maximum</option> + <option value="mean" selected="true">mean</option> + <option value="count" selected="true">count</option> + </param> + </inputs> + <outputs> + <data name="ofilename" format="png"></data> + </outputs> + <tests> + <test> + <param name="ifilename" value="TS.f2000.T31T31.control.cam.h0.0014-12.180.nc" /> + <param name="variable" value="TS" /> + <param name="title" value="Mean Surface Temperature per country" /> + <param name="shapefile" value="TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.shp" /> + <param name="shapefilex" value="TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.shx" /> + <param name="name" value="TM_WORLD_BORDERS_SIMPL-0.3" /> + <output name="ofilename" ftype="png" file="TS.f2000.T31T31.control.cam.h0.0014-12.180.png" compare="sim_size" delta="1500"/> + </test> + </tests> + <help><![CDATA[ + +**Plot statistics** +================================================ + +This tool wraps the functionality of ``zonal-statistics.py``. + + +.. class:: infomark + + The wrapper aims at providing a utility to extract information + from geospatial raster data based on vector geometries (shapefile). + The raster input file must be in netCDF format with geographical coordinates + (latitudes, longitudes) with the same coordinate reference system as the + shapefile. + +**What it does** +---------------- + +This tools creates a png image showing statistic over areas as defined in the +vector file. + +**Usage** + +:: + + usage: zonal-statistics.py [-h] [-v] [-t] raster vector variable output + + +Positional arguments: +~~~~~~~~~~~~~~~~~~~~~ + +- **raster**: input raster filename with geographical coordinates (netCDF format) +- **vector**: input raster filename with polygons +- **variable**: variable used from raster file to compute statistics +- **output**: output filename for png file containing the resulting plot. + +Optional arguments: +~~~~~~~~~~~~~~~~~~~~~ + + -h, --help show this help message and exit + -v, --verbose switch on verbose mode + -t, --type statistic type [min, max, mean, count] + +It uses ``rasterstats`` python package to compute zonal statistics. +More information about ``rasterstats`` can be found at https://pythonhosted.org/rasterstats + + ]]></help> + <citations> + </citations> +</tool>
