view mean-per-zone.xml @ 1:639192aa63f5 draft default tip

planemo upload for repository https://github.com/NordicESMhub/galaxy-tools/tree/master/tools/mean-per-zone commit a5d176b7d0dc81bae07569d396edced43cfa2702
author climate
date Mon, 24 Jun 2019 02:41:08 -0400
parents 40727a2668d6
children
line wrap: on
line source

<tool id="mean_per_zone" name="zonal statistics" version="0.2.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.5.1.2">netcdf4</requirement>
    </requirements>
    <command detect_errors="exit_code"><![CDATA[
       python3 '$__tool_directory__/zonal_statistics.py'
            '$ifilename'
            '$shapefile.extra_files_path'
            '$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="shp" label="shapefile (shp) 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">minimum</option>
            <option value="max">maximum</option>
            <option value="mean" selected="true">mean</option>
            <option value="count">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.html" ftype="shp" >
                <composite_data value="TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.shp"/>
                <composite_data value="TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.shx"/>
                <composite_data value="TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.dbf"/>
                <composite_data value="TM_WORLD_BORDERS_SIMPL-0.3/TM_WORLD_BORDERS_SIMPL-0.3.prj"/>
            </param>
            <!--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 shapefile 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>