def add_with_valid_mask(a_path, b_path, output_path, valid_mask_path, ndv):
    def op(a, b, valid_mask):
        return np.where(valid_mask == 1, a + b, ndv)

    hb.raster_calculator_af_flex([a_path, b_path, valid_mask_path],
                                 op,
                                 output_path,
                                 ndv=ndv)
    return hb.ArrayFrame(output_path)
def add_smart(a, b, a_valid_mask, b_valid_mask, output_ndv, output_path):
    def op(a, b, a_valid_mask, b_valid_mask, output_ndv):
        return np.where((a_valid_mask == 1 & b_valid_mask == 1), a + b,
                        output_ndv)

    hb.raster_calculator_af_flex([a, b, a.valid_mask, b.valid_mask],
                                 op,
                                 output_path,
                                 ndv=output_ndv)
    return hb.ArrayFrame(output_path)
def af_where_lt_value_set_to(a, value, set_to, output_path):
    def op(a):
        return np.where(a < value, set_to, a)

    hb.raster_calculator_af_flex([a], op, output_path)
    return hb.ArrayFrame(output_path)
def proportion_change(after, before, output_path):
    def op(after, before):
        return (after - before) / before

    hb.raster_calculator_af_flex([after, before], op, output_path)
    return hb.ArrayFrame(output_path)
def a_greater_than_zero_b_equal_zero(a_path, b_path, output_path):
    def op(a, b):
        return np.where((a > 0) & (b == 0), 1, 0)

    hb.raster_calculator_af_flex([a_path, b_path], op, output_path)
    return hb.ArrayFrame(output_path)
def greater_than(a_path, b_path, output_path):
    def op(a, b):
        return np.where(a > b, 1, 0)

    hb.raster_calculator_af_flex([a_path, b_path], op, output_path)
    return hb.ArrayFrame(output_path)
def divide(a_path, b_path, output_path):
    def op(a, b):
        return a / b

    hb.raster_calculator_af_flex([a_path, b_path], op, output_path)
    return hb.ArrayFrame(output_path)
def multiply(a_path, b_path, output_path):
    def op(a, b):
        return a * b

    hb.raster_calculator_af_flex([a_path, b_path], op, output_path)
    return hb.ArrayFrame(output_path)
def subtract(a_path, b_path, output_path):
    def op(a, b):
        return a - b

    hb.raster_calculator_af_flex([a_path, b_path], op, output_path)
    return hb.ArrayFrame(output_path)
def add(a_flex, b_flex, output_path):
    def op(a, b):
        return a + b

    hb.raster_calculator_af_flex([a_flex, b_flex], op, output_path)
    return hb.ArrayFrame(output_path)
Esempio n. 11
0
 def __truediv__(self, after):
     def op(left, right):
         return left + right
     output_path = hb.temp(filename_start='div', remove_at_exit=False)
     return hb.raster_calculator_af_flex([self.path, after.path], op, output_path)
Esempio n. 12
0
 def __sub__(self, after):
     def op(left, right):
         return left - right
     output_path = hb.temp(filename_start='sub', remove_at_exit=True)
     return hb.raster_calculator_af_flex([self.path, after.path], op, output_path)