def get_process_list(node: Node) -> Tuple[list, list]:
    """Analyse the process node and return the Actinia process chain and the name of the processing result

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_names, process_list = check_node_parents(node=node)
    output_objects = []

    if "data" not in node.arguments:
        raise Exception("Process %s requires parameter <data>" % PROCESS_NAME)

    # Catch the first input
    for data_object in node.get_parent_by_name(
            parent_name="data").output_objects:
        pc = create_process_chain_entry(data_object=data_object)
        process_list.append(pc)
        break

    for data_object in node.get_parent_by_name(
            parent_name="data").output_objects:
        output_objects.append(data_object)
        node.add_output(data_object)

    return output_objects, process_list
Exemple #2
0
def get_process_list(node: Node):
    """Analyse the process node and return the Actinia process chain and the name of the processing result

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    if "data" not in node.arguments:
        raise Exception("Process %s requires parameter data" % PROCESS_NAME)

    input_objects = node.get_parent_by_name(parent_name="data").output_objects

    if not input_objects:
        raise Exception("Process %s requires an input strds" % PROCESS_NAME)

    input_object = list(input_objects)[-1]

    output_object = DataObject(name=create_output_name(input_object.name,
                                                       PROCESS_NAME),
                               datatype=GrassDataType.STRDS)
    output_objects.append(output_object)

    # pc = create_process_chain_entry(input_object, vector_object, output_object)
    # process_list.append(pc)

    return output_objects, process_list
Exemple #3
0
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain
    and the name of the processing result layer
    which is a single raster layer

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    tree, operators = construct_tree(
        node.as_dict()['arguments']['process']['process_graph'])
    # print (operators)
    formula = None
    output_datatype = GrassDataType.RASTER
    formula = serialize_tree(tree)
    # print(formula)
    output_datatype = GrassDataType.STRDS

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    for input_object in node.get_parent_by_name("data").output_objects:

        output_object = DataObject(name=create_output_name(
            input_object.name, PROCESS_NAME),
                                   datatype=output_datatype)
        output_objects.append(output_object)
        node.add_output(output_object=output_object)

        pc = create_process_chain_entry(input_object, formula, operators,
                                        output_object)
        process_list.append(pc)

    return output_objects, process_list
Exemple #4
0
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain
    and the name of the processing result layer
    which is a single raster layer

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    if "percentile" not in node.arguments:
        raise Exception("Parameter percentile is required.")

    for data_object in node.get_parent_by_name("data").output_objects:
        # multiple strds as input ?
        # multiple raster layers as output !
        output_object = DataObject(name=create_output_name(
            data_object.name, node),
                                   datatype=GrassDataType.STRDS)
        output_objects.append(output_object)
        node.add_output(output_object=output_object)

        pc = create_process_chain_entry(data_object,
                                        node.arguments["percentile"],
                                        output_object)
        process_list.append(pc)

    return output_objects, process_list
def get_process_list(node: Node) -> Tuple[list, list]:
    """Analyse the process node and return the Actinia process chain and the name of the processing result

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    if "data" not in node.arguments or \
            "min" not in node.arguments or \
            "max" not in node.arguments:
        raise Exception("Process %s requires parameter data, min, max" %
                        PROCESS_NAME)

    newmin = node.arguments["min"]
    newmax = node.arguments["max"]

    # for each raster separately
    for input_object in node.get_parent_by_name("data").output_objects:

        output_object = DataObject(name=create_output_name(
            input_object.name, PROCESS_NAME),
                                   datatype=GrassDataType.RASTER)
        output_objects.append(output_object)
        node.add_output(output_object=output_object)

        pc = create_process_chain_entry(input_object, newmin, newmax,
                                        output_object)
        process_list.append(pc)

    # TODO: create strds from output raster maps

    return output_objects, process_list
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain and the name of the processing result layer
    which is a single raster layer

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    options = {}
    if "options" in node.arguments:
        options = node.arguments["options"]

    # Pipe the inputs to the outputs
    for input_object in node.get_parent_by_name("data").output_objects:
        output_objects.append(input_object)
        node.add_output(output_object=input_object)

        pc = create_process_chain_entry(input_object=input_object,
                                        options=options)
        process_list.extend(pc)

    return output_objects, process_list
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain and the name of the processing result layer
    which is a single raster layer

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    for input_object in input_objects:

        output_objects.append(input_object)
        node.add_output(output_object=input_object)

        if "polygons" in node.arguments:
            polygons = node.arguments["polygons"]
        else:
            raise Exception(
                "The vector polygon is missing in the process description")

        pc = create_process_chain_entry(input_object=input_object,
                                        polygons=polygons)
        process_list.extend(pc)

    return output_objects, process_list
Exemple #8
0
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain
    and the name of the processing result layer
    which is a single raster layer

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    if "method" not in node.arguments:
        raise Exception("Parameter method is required.")

    for input_object in node.get_parent_by_name("data").output_objects:

        output_object = DataObject(
            name=create_output_name(input_object.name, PROCESS_NAME),
            datatype=GrassDataType.RASTER)
        output_objects.append(output_object)
        node.add_output(output_object=output_object)

        pc = create_process_chain_entry(
            input_object, node.arguments["method"], output_object)
        process_list.append(pc)

    return output_objects, process_list
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain and the name of the processing result layer
    which is a single raster layer

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    for input_object in input_objects:

        output_objects.append(input_object)
        node.add_output(output_object=input_object)

        geometries = None
        if "geometries" in node.arguments:
            geometries = node.arguments["geometries"]
        else:
            raise Exception(
                "The vector geometries are missing in the process description")

        # TODO: support a reducer
        # reducer = node.arguments["reducer"]

        pc = create_process_chain_entry(input_object=input_object,
                                        geometries=geometries)
        process_list.extend(pc)

    return output_objects, process_list
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain
    and the name of the processing result layer which is a single raster layer

    :param args: The process description
    :return: (output_names, actinia_process_list)
    """

    # Get the input description and the process chain to attach this process
    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    input_objects = node.get_parent_by_name(parent_name="data").output_objects

    python_file_url = node.arguments["udf"]
    udf_runtime = None
    if "runtime" in node.arguments:
        udf_runtime = node.arguments["runtime"]
    udf_version = None
    if "version" in node.arguments:
        udf_version = node.arguments["version"]

    for input_object in input_objects:

        output_object = DataObject(name=create_output_name(
            input_object.name, PROCESS_NAME),
                                   datatype=GrassDataType.STRDS)
        output_objects.append(output_object)

        pc = create_process_chain_entry(input_object, python_file_url,
                                        udf_runtime, udf_version,
                                        output_object)
        process_list.append(pc)

    return output_objects, process_list
def get_process_list(node: Node) -> Tuple[list, list]:
    """Analyse the process node and return the Actinia process chain and the name of the processing result

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    if "data" not in node.arguments or \
            "min" not in node.arguments or \
            "max" not in node.arguments:
        raise Exception("Process %s requires parameter data, min, max" %
                        PROCESS_NAME)

    vmin = node.arguments["min"]
    vmax = node.arguments["max"]

    for data_object in input_objects:

        output_object = DataObject(name=create_output_name(
            data_object.name, node),
                                   datatype=GrassDataType.STRDS)
        output_objects.append(output_object)
        node.add_output(output_object=output_object)

        pc = create_process_chain_entry(data_object, vmin, vmax, output_object)
        process_list.append(pc)

    return output_objects, process_list
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain and the name of the processing result
    strds that was filtered by start and end date

    :param node: The process node
    :return: (output_names, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    for data_object in node.get_parent_by_name(
            parent_name="data").output_objects:

        # Skip if the datatype is not a strds and put the input into the output
        if data_object.is_strds() is False:
            output_objects.append(data_object)
            continue

        if "dimension" not in node.arguments or \
                node.arguments["dimension"] != "bands":
            raise Exception(
                "Process %s requires dimension to be set to bands" %
                PROCESS_NAME)

        output_object = DataObject(name=create_output_name(
            data_object.name, node),
                                   datatype=GrassDataType.STRDS)
        output_objects.append(output_object)
        node.add_output(output_object=output_object)

        if not isinstance(node.arguments["target"], list):
            raise Exception("Process %s requires target to be a list" %
                            PROCESS_NAME)
        target = node.arguments["target"]
        source = None
        if "source" in node.arguments:
            if not isinstance(node.arguments["source"], list):
                raise Exception("Process %s requires source to be a list" %
                                PROCESS_NAME)
            source = node.arguments["source"]
            if len(source) != len(target):
                raise Exception(
                    "Process %s requires source and target to have the same number of items"
                    % PROCESS_NAME)
        else:
            if len(target) != 1:
                raise Exception(
                    "Process %s requires one item in target if source is not given"
                    % PROCESS_NAME)

        pc = create__process_chain_entry(input_object=data_object,
                                         target=target,
                                         source=source,
                                         output_object=output_object)
        process_list.extend(pc)

    return output_objects, process_list
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain
    and the name of the processing result layer
    which is a single raster layer

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    if "nf" not in node.arguments:
        raise Exception("Parameter nf is required.")
    nf = int(node.arguments["nf"])
    dod = 0
    if "dod" in node.arguments:
        dod = int(node.arguments["dod"])
    fet = 1.7977e308
    if "fet" in node.arguments:
        fet = float(node.arguments["fet"])
    range_low = -1.7977e308
    if "range_low" in node.arguments:
        range_low = float(node.arguments["range_low"])
    range_high = 1.7977e308
    if "range_high" in node.arguments:
        range_high = float(node.arguments["range_high"])
    reject_low = False
    if "reject_low" in node.arguments:
        reject_low = bool(node.arguments["reject_low"])
    reject_high = False
    if "reject_high" in node.arguments:
        reject_high = bool(node.arguments["reject_high"])

    for data_object in node.get_parent_by_name("data").output_objects:

        # Skip if the datatype is not a strds and put the input into the output
        if data_object.is_strds() is False:
            output_objects.append(data_object)
            continue

        # multiple strds as input ?
        output_object = DataObject(name=create_output_name(
            data_object.name, PROCESS_NAME),
                                   datatype=GrassDataType.STRDS)
        output_objects.append(output_object)
        node.add_output(output_object=output_object)

        pc = create_process_chain_entry(data_object, nf, dod, fet, range_low,
                                        range_high, reject_low, reject_high,
                                        output_object)
        process_list.append(pc)

    return output_objects, process_list
Exemple #14
0
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain and the name of the processing result

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    if "result" not in node.arguments:
        raise Exception("The result name must be specified as parameter")
    if "expression" not in node.arguments:
        raise Exception("The expression must be specified as parameter")
    if "basename" not in node.arguments:
        raise Exception("The basename must be specified as parameter")

    result = DataObject(
        name=node.arguments["result"],
        datatype=GrassDataType.STRDS)

    expression = node.arguments["expression"]
    basename = node.arguments["basename"]

    if "a" in node.arguments:
        a = list(node.get_parent_by_name(parent_name="a").output_objects)[-1]
        expression = expression.replace("$a", a.grass_name())
    if "b" in node.arguments:
        b = list(node.get_parent_by_name(parent_name="b").output_objects)[-1]
        expression = expression.replace("$b", b.grass_name())
    if "c" in node.arguments:
        c = list(node.get_parent_by_name(parent_name="c").output_objects)[-1]
        expression = expression.replace("$c", c.grass_name())
    if "d" in node.arguments:
        d = list(node.get_parent_by_name(parent_name="d").output_objects)[-1]
        expression = expression.replace("$d", d.grass_name())
    if "e" in node.arguments:
        e = list(node.get_parent_by_name(parent_name="e").output_objects)[-1]
        expression = expression.replace("$e", e.grass_name())
    if "f" in node.arguments:
        f = list(node.get_parent_by_name(parent_name="f").output_objects)[-1]
        expression = expression.replace("$f", f.grass_name())

    expression = expression.replace("$result", result.grass_name())

    output_objects.append(result)
    node.add_output(output_object=result)

    pc = create_process_chain_entry(expression=expression, basename=basename)
    process_list.extend(pc)

    return output_objects, process_list
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain and the name of the processing result

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    # Get the input data
    input_objects = node.get_parent_by_name(parent_name="data").output_objects

    input_strds = list(input_objects)[-1]

    nir_band = "nir"
    red_band = "red"
    if "nir" in node.arguments and \
       node.arguments["nir"] is not None and \
       node.arguments["nir"] != "null":
        nir_band = node.arguments["nir"]
    if "red" in node.arguments and \
       node.arguments["red"] is not None and \
       node.arguments["red"] != "null":
        red_band = node.arguments["red"]

    target_band = None
    if "target_band" in node.arguments and \
       node.arguments["target_band"] is not None and \
       node.arguments["target_band"] != "null":
        target_band = node.arguments["target_band"]

    output_objects.extend(list(input_objects))

    output_object = DataObject(
        name=create_output_name(input_strds.name, node),
        datatype=GrassDataType.STRDS)
    if target_band is None:
        output_objects.append(output_object)
        node.add_output(output_object=output_object)
    else:
        # if target band is given, extend the input strds
        output_objects.append(input_strds)
        node.add_output(output_object=input_strds)

    pc = create_process_chain_entry(
        input_strds, nir_band, red_band, target_band, output_object)
    process_list.extend(pc)

    return output_objects, process_list
Exemple #16
0
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process
       chain and the name of the processing result

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    # First analyse the data entry
    if "id" not in node.arguments:
        raise Exception("Process %s requires parameter <id>" % PROCESS_NAME)

    input_object = DataObject.from_string(node.arguments["id"])

    spatial_extent = None
    if "spatial_extent" in node.arguments:
        spatial_extent = node.arguments["spatial_extent"]
    temporal_extent = None
    if "temporal_extent" in node.arguments:
        temporal_extent = node.arguments["temporal_extent"]
    bands = None
    if "bands" in node.arguments:
        bands = node.arguments["bands"]

    if input_object.is_strds() and \
       (temporal_extent is not None or bands is not None):
        output_object = DataObject(
            name=create_output_name(input_object.name, node),
            datatype=input_object.datatype)
    elif input_object.is_stac():
        output_object = DataObject(
            name=create_output_name(input_object.name, node),
            datatype=input_object.datatype)
    else:
        output_object = input_object

    output_objects.append(output_object)
    node.add_output(output_object)

    pc = create_process_chain_entry(input_object,
                                    spatial_extent,
                                    temporal_extent,
                                    bands,
                                    output_object)
    process_list.extend(pc)

    return output_objects, process_list
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain and the name of the processing result

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    # First analyse the data entries
    if "band1" not in node.arguments:
        raise Exception("Process %s requires parameter <band1>" % PROCESS_NAME)

    if "band2" not in node.arguments:
        raise Exception("Process %s requires parameter <band2>" % PROCESS_NAME)

    # Get the red and nir data separately
    band1_input_objects = node.get_parent_by_name(
        parent_name="band1").output_objects
    band2_input_objects = node.get_parent_by_name(
        parent_name="band2").output_objects

    if not band1_input_objects:
        raise Exception(
            "Process %s requires an input strds for band 1" %
            PROCESS_NAME)

    if not band2_input_objects:
        raise Exception(
            "Process %s requires an input strds for band 2" %
            PROCESS_NAME)

    band1_strds = list(band1_input_objects)[-1]
    band2_strds = list(band2_input_objects)[-1]

    output_objects.extend(list(band1_input_objects))
    output_objects.extend(list(band2_input_objects))

    output_object = DataObject(
        name=create_output_name(band1_strds.name, node),
        datatype=GrassDataType.STRDS)
    output_objects.append(output_object)
    node.add_output(output_object=output_object)

    pc = create_process_chain_entry(band1_strds, band2_strds, output_object)
    process_list.extend(pc)

    return output_objects, process_list
Exemple #18
0
def get_process_list(node: Node) -> Tuple[list, list]:
    """Analyse the process node and return the Actinia process chain and the name of the processing result

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    if "data" not in node.arguments or \
            "extent" not in node.arguments or \
            "north" not in node.arguments["extent"] or \
            "south" not in node.arguments["extent"] or \
            "east" not in node.arguments["extent"] or \
            "west" not in node.arguments["extent"] or \
            "crs" not in node.arguments["extent"]:
        raise Exception(
            "Process %s requires parameter data and extent with north, south, east, west, "
            "crs" % PROCESS_NAME)

    north = node.arguments["extent"]["north"]
    south = node.arguments["extent"]["south"]
    west = node.arguments["extent"]["west"]
    east = node.arguments["extent"]["east"]
    if "crs" in node.arguments["extent"]:
        crs = str(node.arguments["extent"]["crs"])
    else:
        crs = "4326"

    if crs.isnumeric():
        crs = "EPSG:" + crs

    pc = create_process_chain_entry(north=north,
                                    south=south,
                                    east=east,
                                    west=west,
                                    crs=crs)
    process_list.append(pc)

    for data_object in node.get_parent_by_name(
            parent_name="data").output_objects:
        output_objects.append(data_object)
        node.add_output(data_object)

    return output_objects, process_list
Exemple #19
0
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain
    and the name of the processing result layer
    which is a single raster layer

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """
    # get dimension type
    dimtype = get_dimension_type(node.arguments["dimension"])
    if dimtype is None:
        raise Exception(
            'Unable to determine dimension type for dimension <%s>.' %
            (node.arguments["dimension"]))

    tree, operators = construct_tree(
        node.as_dict()['arguments']['reducer']['process_graph'])
    # print (operators)
    formula = None
    output_datatype = GrassDataType.STRDS
    if dimtype == 'bands':
        formula = serialize_tree(tree)
        # print (formula)
        output_datatype = GrassDataType.STRDS
    elif dimtype == 'temporal':
        if len(operators) != 1:
            raise Exception(
                'Only one method is supported by reduce process on the temporal dimension.'
            )

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    for input_object in node.get_parent_by_name("data").output_objects:

        output_object = DataObject(name=create_output_name(
            input_object.name, node),
                                   datatype=output_datatype)
        output_objects.append(output_object)
        node.add_output(output_object=output_object)

        pc = create_process_chain_entry(input_object, dimtype, formula,
                                        operators, output_object)
        process_list.extend(pc)

    return output_objects, process_list
def get_process_list(node: Node):
    """Analyse the process node and return the Actinia process chain and the name of the processing result

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    if "cube1" not in node.arguments or \
            "cube2" not in node.arguments:
        raise Exception(
            "Process %s requires parameter cube1, cube2" %
            PROCESS_NAME)

    cube1_objects = node.get_parent_by_name(parent_name="cube1").output_objects
    cube2_objects = node.get_parent_by_name(parent_name="cube2").output_objects

    if "overlap_resolver" in node.arguments and \
        (node.arguments["overlap_resolver"] is not None or
            node.arguments["overlap_resolver"] != "null"):
        raise Exception(
            "Process %s does not support yet the parameter \"overlap_resolver\"" %
            PROCESS_NAME)

    if not cube1_objects:
        raise Exception("Process %s requires two input strds's, cube1 is missing" % PROCESS_NAME)

    if not cube2_objects:
        raise Exception("Process %s requires two input strds's, cube2 is missing" % PROCESS_NAME)

    cube1_object = list(cube1_objects)[-1]
    cube2_object = list(cube2_objects)[-1]

    output_object = DataObject(
        name=create_output_name(cube1_object.name, node),
        datatype=GrassDataType.STRDS)
    output_objects.append(output_object)
    node.add_output(output_object=output_object)

    pc = create_process_chain_entry(cube1_object, cube2_object, output_object)
    process_list.append(pc)

    return output_objects, process_list
def get_process_list(node: Node):
    """Analyse the process node and return the Actinia process chain and the name of the processing result

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    if "data" not in node.arguments or \
            "mask" not in node.arguments:
        raise Exception("Process %s requires parameter data, polygons" %
                        PROCESS_NAME)

    if "replacement" in node.arguments:
        mask_value = node.arguments["replacement"]
    else:
        mask_value = "null"

    inside = False
    if "inside" in node.arguments:
        if node.arguments["inside"] == "true":
            inside = True

    input_objects = node.get_parent_by_name(parent_name="data").output_objects
    vector_object = node.arguments["mask"]

    if not input_objects:
        raise Exception("Process %s requires an input strds" % PROCESS_NAME)

    input_object = list(input_objects)[-1]

    output_object = DataObject(name=create_output_name(input_object.name,
                                                       PROCESS_NAME),
                               datatype=GrassDataType.STRDS)
    output_objects.append(output_object)

    pc = create_process_chain_entry(input_object, vector_object, mask_value,
                                    inside, output_object)
    process_list.extend(pc)

    return output_objects, process_list
Exemple #22
0
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain
    and the name of the processing result layer
    which is a single raster layer

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    if "mask" not in node.arguments:
        raise Exception("Parameter mask is required.")

    nmasks = len(node.get_parent_by_name("mask").output_objects)
    ninputs = len(node.get_parent_by_name("data").output_objects)

    if nmasks > 1 and nmasks != ninputs:
        raise Exception(
            "Either a single mask or a separate mask for each layer is required."
        )

    mask_object = None
    if nmasks == 1:
        mask_object = node.get_parent_by_name("mask").output_objects[0]

    for i in range(len(node.get_parent_by_name("data").output_objects)):
        input_object = node.get_parent_by_name("data").output_objects[i]
        if nmasks > 1:
            mask_object = node.get_parent_by_name("mask").output_objects[i]

        output_object = DataObject(name=create_output_name(
            input_object.name, node),
                                   datatype=GrassDataType.RASTER)
        output_objects.append(output_object)
        node.add_output(output_object=output_object)

        pc = create_process_chain_entry(input_object, mask_object,
                                        output_object)
        process_list.append(pc)

    return output_objects, process_list
Exemple #23
0
def get_process_list(node: Node) -> Tuple[list, list]:
    """Analyse the process node and return the Actinia process chain and the name of the processing result

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    # at least one of bands, common_names, wavelengths must be given
    if "data" not in node.arguments or \
            ("bands" not in node.arguments and
             "wavelengths" not in node.arguments):
        raise Exception(
            "Process %s requires parameter data and at least one of "
            "bands, wavelengths" %
            PROCESS_NAME)

    bands = None
    if "bands" in node.arguments:
        bands = node.arguments["bands"]
    wavelengths = None
    if "wavelengths" in node.arguments:
        wavelengths = node.arguments["wavelengths"]

    data_object = list(node.get_parent_by_name(
        parent_name="data").output_objects)[-1]

    output_object = DataObject(
        name=create_output_name(data_object.name, PROCESS_NAME),
        datatype=GrassDataType.STRDS)
    output_objects.append(output_object)
    node.add_output(output_object=output_object)

    pc = create_process_chain_entry(data_object, bands, wavelengths,
                                    output_object)
    process_list.append(pc)

    return output_objects, process_list
Exemple #24
0
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain and the name of the processing result
    strds that was filtered by start and end date

    :param node: The process node
    :return: (output_names, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    for data_object in node.get_parent_by_name(
            parent_name="data").output_objects:

        # Skip if the datatype is not a strds and put the input into the output
        if data_object.is_strds() is False:
            output_objects.append(data_object)
            continue

        output_object = DataObject(name=create_output_name(
            data_object.name, PROCESS_NAME),
                                   datatype=GrassDataType.STRDS)
        output_objects.append(output_object)
        node.add_output(output_object=output_object)

        start_time = None
        end_time = None

        if "extent" in node.arguments:
            start_time = node.arguments["extent"][0]
            end_time = node.arguments["extent"][1]

        pc = create__process_chain_entry(input_object=data_object,
                                         start_time=start_time,
                                         end_time=end_time,
                                         output_object=output_object)
        process_list.append(pc)

    return output_objects, process_list
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain
    and the name of the processing result layer
    which is a single raster layer

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    data_object = list(input_objects)[-1]
    output_object = DataObject(name=create_output_name(data_object.name, node),
                               datatype=GrassDataType.RASTER)
    output_objects.append(output_object)
    node.add_output(output_object=output_object)

    pc = create_process_chain_entry(data_object, output_object)
    process_list.append(pc)

    return output_objects, process_list
Exemple #26
0
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain and the name of the processing result layer
    which is a single raster layer

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    # Pipe the inputs to the outputs
    for data_object in node.get_parent_by_name("data").output_objects:

        # Export raster maps
        if data_object.is_raster():
            output_objects.append(data_object)
            node.add_output(output_object=data_object)

            pc = create_process_chain_entry(data_object=data_object)
            process_list.extend(pc)

    return output_objects, process_list
def get_process_list(node: Node) -> Tuple[list, list]:
    """Analyse the process node and return the Actinia process chain and the name of the processing result

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    if "data" not in node.arguments or \
            "mask" not in node.arguments:
        raise Exception("Process %s requires parameter data, mask" %
                        PROCESS_NAME)

    if "replacement" in node.arguments:
        mask_value = node.arguments["replacement"]
    else:
        mask_value = "null"

    # Get the input and mask data separately
    data_object = list(
        node.get_parent_by_name(parent_name="data").output_objects)[0]
    mask_object = list(
        node.get_parent_by_name(parent_name="mask").output_objects)[0]

    output_object = DataObject(name=create_output_name(data_object.name,
                                                       PROCESS_NAME),
                               datatype=GrassDataType.STRDS)
    output_objects.append(output_object)
    node.add_output(output_object=output_object)

    pc = create_process_chain_entry(data_object, mask_object, mask_value,
                                    output_object)
    process_list.append(pc)

    return output_objects, process_list
def get_process_list(node: Node):
    """Analyse the process node and return the Actinia process chain and the name of the processing result

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    input_objects = node.get_parent_by_name(parent_name="data").output_objects

    if not input_objects:
        raise Exception("Process %s requires an input strds" % PROCESS_NAME)

    for data_object in input_objects:
        output_objects.append(data_object)
        node.add_output(data_object)

    # dummy process, does nothing
    # pc = create_process_chain_entry(input_object, output_object)
    # process_list.append(pc)

    return output_objects, process_list
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain and the name of the processing result

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    # First analyse the data entries
    if "red" not in node.arguments:
        raise Exception("Process %s requires parameter <red>" % PROCESS_NAME)
    if "green" not in node.arguments:
        raise Exception("Process %s requires parameter <green>" % PROCESS_NAME)
    if "blue" not in node.arguments:
        raise Exception("Process %s requires parameter <blue>" % PROCESS_NAME)

    # Get the red, green and blue data separately
    red_input_objects = node.get_parent_by_name(
        parent_name="red").output_objects
    green_input_objects = node.get_parent_by_name(
        parent_name="green").output_objects
    blue_input_objects = node.get_parent_by_name(
        parent_name="blue").output_objects

    if not red_input_objects:
        raise Exception(
            "Process %s requires an input raster for band <red>" %
            PROCESS_NAME)
    if not green_input_objects:
        raise Exception(
            "Process %s requires an input raster for band <green>" %
            PROCESS_NAME)
    if not blue_input_objects:
        raise Exception(
            "Process %s requires an input raster for band <blue>" %
            PROCESS_NAME)

    red_object = list(red_input_objects)[-1]
    green_object = list(green_input_objects)[-1]
    blue_object = list(blue_input_objects)[-1]

    output_objects.extend(list(red_input_objects))
    output_objects.extend(list(green_input_objects))
    output_objects.extend(list(blue_input_objects))

    rn = randint(0, 1000000)

    output_object = DataObject(
        name="red_green_blue_composite_%i" %
        rn, datatype=GrassDataType.STRDS)
    output_objects.append(output_object)
    node.add_output(output_object=output_object)

    pc = create_process_chain_entry(
        output_object=output_object,
        red_object=red_object,
        green_object=green_object,
        blue_object=blue_object)
    process_list.extend(pc)

    return output_objects, process_list
Exemple #30
0
def get_process_list(node: Node):
    """Analyse the process description and return the Actinia process chain and the name of the processing result

    :param node: The process node
    :return: (output_objects, actinia_process_list)
    """

    input_objects, process_list = check_node_parents(node=node)
    output_objects = []

    # First analyse the data entries
    if "red" not in node.arguments:
        raise Exception("Process %s requires parameter <red>" % PROCESS_NAME)

    if "nir" not in node.arguments:
        raise Exception("Process %s requires parameter <nir>" % PROCESS_NAME)

    if "blue" not in node.arguments:
        raise Exception("Process %s requires parameter <blue>" % PROCESS_NAME)

    # Get the red and nir data separately
    red_input_objects = node.get_parent_by_name(
        parent_name="red").output_objects
    nir_input_objects = node.get_parent_by_name(
        parent_name="nir").output_objects
    blue_input_objects = node.get_parent_by_name(
        parent_name="blue").output_objects

    if not red_input_objects:
        raise Exception(
            "Process %s requires an input strds for band <red>" %
            PROCESS_NAME)

    if not nir_input_objects:
        raise Exception(
            "Process %s requires an input strds for band <nir>" %
            PROCESS_NAME)

    if not blue_input_objects:
        raise Exception(
            "Process %s requires an input strds for band <blue>" %
            PROCESS_NAME)

    scale = 1.0
    if "scale" in node.arguments:
        scale = float(node.arguments["scale"])

    red_strds = list(red_input_objects)[-1]
    nir_strds = list(nir_input_objects)[-1]
    blue_strds = list(blue_input_objects)[-1]

    output_objects.extend(list(red_input_objects))
    output_objects.extend(list(nir_input_objects))
    output_objects.extend(list(blue_input_objects))

    output_object = DataObject(
        name=create_output_name(red_strds.name, node),
        datatype=GrassDataType.STRDS)
    output_objects.append(output_object)
    node.add_output(output_object=output_object)

    pc = create_process_chain_entry(
        nir_strds,
        red_strds,
        blue_strds,
        scale,
        output_object)
    process_list.extend(pc)

    return output_objects, process_list