view pca_raster.xml @ 0:0931c98270c9 draft

planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
author ecology
date Mon, 09 Jan 2023 13:38:09 +0000
parents
children 21e21363a8b4
line wrap: on
line source

<tool id="srs_pca" name="Compute a PCA raster" version="@VERSION@" profile = "20.01">
    <description>from remote sensing data</description>
    <macros>
        <import>macro.xml</import>
    </macros>
    <expand macro="SRS_requirements"/>
    <command detect_errors="exit_code"><![CDATA[ 
        #import re 
        #if $method.origin == 'envi_bil': 
          #set input_raster = $method.input_raster
          #set input_raster_identifier = re.sub('[^\s\w\-]', '_', str($input_raster.element_identifier)) 
          #set input_header = $method.input_header
          #set input_header_identifier = re.sub('[^\s\w\-]+[^.hdr]', '_', str($input_header.element_identifier)) 
          cp '${input_raster}' '${input_raster_identifier}' &&
          cp '${input_header}' '${input_header_identifier}' &&
        #end if
        Rscript
            '$__tool_directory__/pca_raster.r'
             #if $method.origin == 'envi_bil':
              '$input_raster_identifier' 
              '$input_header_identifier'
              ''
            #else:
              ''
              ''
              '$method.input'
            #end if
            '$type'
            '$__tool_directory__/functions.r'
            '$output_raster'
            '$output_pca'
            '$plots'
        ]]>
    </command>
    <inputs>
        <conditional name="method">
            <param name="origin" type="select" label="In which format are your data ?">
                <option value="zipper">The data you are using are in a zip folder Reflectance</option>
                <option value="envi_bil">Your already have the files ENVI BIL</option>
            </param>
            <when value="zipper">
                <param name="input" type="data" format="zip" multiple="true" label="Input data"/>
            </when>
            <when value="envi_bil">
                <param name="input_raster" type="data" format="bil" label="Input raster"/>
                <param name="input_header" type="data" format="hdr" label="Input raster header"/>
            </when>
        </conditional>
        <param name="type" type="select" label="Do you want to do a PCA or a SPCA ?" display="radio" help="If you choose PCA there is no rescaling of the data as oppposed as if you choose SPCA">
            <option value="SPCA">SPCA</option>
            <option value="PCA">PCA</option>
        </param>
    </inputs>
    <outputs>
        <collection type="list" name="output_raster" label="PCA raster">
            <discover_datasets pattern="(?P&lt;designation&gt;.+)" directory="RESULTS/" visible="false" recurse="true" format="bil,hdr"/>
        </collection>
        <data name="output_pca" from_work_dir="PCA.tabular" format="tabular" label="PCA tabular"/>
        <collection type="list" name="plots" label="PCA plot">
            <discover_datasets pattern="(?P&lt;designation&gt;.+)\.png" visible="false" format="png"/>
        </collection>
    </outputs>
    <tests>
        <test>
            <param name="origin" value="envi_bil"/>
            <param name="input_raster" value="S2A_Subset"/>
            <param name="input_header" value="S2A_Subset.hdr"/>
            <param name="type" value="PCA"/>
            <output_collection name="output_raster" type="list" count="5"/>
            <output name="output_pca">
                <assert_contents>
                    <has_n_lines n="960435"/>
                </assert_contents>
            </output>
            <output_collection name="plots" type="list" count="1"/>
        </test>
    </tests>
    <help><![CDATA[
========================================================================
Process satellite remote sensing data to produce biodiversity indicators
========================================================================


**What it does**

FĂ©ret and Asner (2014) developed a method for **tropical forest** diversity mapping based on very high spatial resolution airborne imaging spectroscopy.

The goal of this tool using the package biodivMapR is to produce a Principal Components Analysis (PCA) based on (optical) images. Principal component analysis prepares for feature extraction in order to reduce noise in the image. It is performed on a random subset of the image to ensure computational efficiency for large images.

**Input description**

It expects an image file as input, with a specific data format. ENVI HDR image with BIL interleave required.
The image is an ENVI raster including :

- A binary file (which has no extension here).

- A header file (with .hdr extension).

The header file is a text file including all necessary metadata which can be read with a text editor. It includes image dimensions, projection, and the name and central wavelength for each spectral band.

In order to get such input we advise to use the tool preprocessing sentinel 2 data. 

+--------------+----------+
|      BIL     | ENVI HDR |
+==============+==========+
| raster stack | Metadata |
+--------------+----------+
|      ...     |    ...   |
+--------------+----------+

**Output**

- One tabular with 3 columns : longitude, latitude and pca.

- One png graph.

- One  ENVI BIL files with the one file for the bil raster and one file for the hdr header.
    ]]>    </help>
        <expand macro="SRS_BDMRref"/>
</tool>