Exemplo n.º 1
0
def recompose_image(layer, working_directory):
    bands = layer.bands
    image_in = layer.get_source()
    num_band_pir = bands['pir']
    num_band_red = bands['red']
    num_band_green = bands['green']
    band_pir = gdal_translate_get_one_band(image_in, num_band_pir,
                                           working_directory)
    band_red = gdal_translate_get_one_band(image_in, num_band_red,
                                           working_directory)
    band_green = gdal_translate_get_one_band(image_in, num_band_green,
                                             working_directory)

    logger.debug("pir" + band_pir)
    logger.debug("red" + band_red)
    logger.debug("green" + band_green)

    output_filename = os.path.join(
        working_directory,
        os.path.splitext(os.path.basename(image_in))[0] + "pir_red_green" +
        os.path.splitext(os.path.basename(image_in))[1])
    logger.debug("recomposed image" + output_filename)
    if not os.path.isfile(output_filename):
        OTBApplications.concatenateImages_cli([band_pir, band_red, band_green],
                                              output_filename, "uint16")
    return output_filename
Exemplo n.º 2
0
def threshold(layer, working_directory, forms):
    logger.debug("threshold {}".format(forms))
    image_in = layer.get_source()
    temp = []
    i = 1

    if len(forms) == 1:
        output_filename = os.path.join(
            working_directory,
            os.path.basename(os.path.splitext(image_in)[0]) + "_threshold" +
            os.path.splitext(image_in)[1])
        OTBApplications.bandmath_cli([image_in], forms[0], output_filename)
    else:
        for formula in forms:
            output_filename = os.path.join(
                working_directory,
                os.path.basename(os.path.splitext(image_in)[0]) +
                "_threshold" + str(i) + os.path.splitext(image_in)[1])
            OTBApplications.bandmath_cli([image_in], formula, output_filename)
            i += 1
            temp.append(output_filename)
        output_filename = os.path.join(
            working_directory,
            os.path.basename(os.path.splitext(image_in)[0]) + "_threshold" +
            os.path.splitext(image_in)[1])

        OTBApplications.concatenateImages_cli(temp, output_filename)

    return output_filename
Exemplo n.º 3
0
def recompose_image(layer, working_directory):
    bands = layer.bands
    image_in = layer.get_source()
    num_band_pir = bands['pir']
    num_band_red = bands['red']
    num_band_green = bands['green']
    band_pir = gdal_translate_get_one_band(image_in, num_band_pir, working_directory)
    band_red = gdal_translate_get_one_band(image_in, num_band_red, working_directory)
    band_green = gdal_translate_get_one_band(image_in, num_band_green, working_directory)

    logger.debug("pir" + band_pir)
    logger.debug("red" + band_red)
    logger.debug("green" + band_green)

    output_filename = os.path.join(working_directory, os.path.splitext(os.path.basename(image_in))[0] + "pir_red_green" + os.path.splitext(os.path.basename(image_in))[1])
    logger.debug("recomposed image" + output_filename)
    if not os.path.isfile(output_filename):
        OTBApplications.concatenateImages_cli([band_pir, band_red, band_green], output_filename, "uint16")
    return output_filename
Exemplo n.º 4
0
def threshold(layer, working_directory, forms):
    logger.debug("threshold" + str(forms))
    image_in = layer.get_source()
    temp = []
    i = 1

    if len(forms) == 1:
        output_filename = os.path.join(working_directory,
                                       os.path.basename(os.path.splitext(image_in)[0]) + "_threshold" + os.path.splitext(image_in)[1])
        OTBApplications.bandmath_cli([image_in], forms[0], output_filename)
    else:
        for formula in forms:
            output_filename = os.path.join(working_directory,
                                           os.path.basename(os.path.splitext(image_in)[0]) + "_threshold" + str(i) + os.path.splitext(image_in)[1])
            OTBApplications.bandmath_cli([image_in], formula, output_filename)
            i += 1
            temp.append(output_filename)
        output_filename = os.path.join(working_directory, os.path.basename(os.path.splitext(image_in)[0]) + "_threshold" + os.path.splitext(image_in)[1])

        OTBApplications.concatenateImages_cli(temp, output_filename)

    return output_filename