Exemplo n.º 1
0
    def create_toa(self, image_path, dst_path, mtl):
        # In this function we use rasterio library to calculate Landsat0 Top of atmosphere images

        creation_options = {'nodata': 0, 'compress': 'deflate', 'predict': 2}
        try:
            #define which band
            bandnum = _parse_bands_from_filename([image_path],
                                                 '.*/LC08.*\_B{b}.TIF')
            print(bandnum)

            calculate_landsat_reflectance(
                [image_path],
                mtl,
                dst_path,
                rescale_factor=55000,
                creation_options=creation_options,
                bands=bandnum,
                dst_dtype='uint16',
                processes=4,
                pixel_sunangle=True,
            )

            return dst_path
        except ValueError:
            pass
Exemplo n.º 2
0
def radiance(ctx, src_path, src_mtl, dst_path, rescale_factor, readtemplate,
             verbose, creation_options, l8_bidx, dst_dtype, workers, clip):
    """Calculates Landsat8 Top of Atmosphere Radiance
    """
    if verbose:
        logger.setLevel(logging.DEBUG)

    if l8_bidx == 0:
        l8_bidx = _parse_bands_from_filename([src_path], readtemplate)[0]

    calculate_landsat_radiance(src_path, src_mtl, dst_path, rescale_factor,
                               creation_options, l8_bidx, dst_dtype, workers,
                               clip)
Exemplo n.º 3
0
def reflectance(ctx, src_path, src_mtl, dst_path,
         verbose, creation_options, l8_bidx, dst_dtype, workers):
    """Calculates Landsat8 Surface Reflectance
    """
    if verbose:
        logger.setLevel(logging.DEBUG)

    if l8_bidx == 0:
        template =  '.*\LC8.*_B{b}.TIF'
        l8_bidx = _parse_bands_from_filename([src_path], template)[0]
    elif not isinstance(l8_bidx, int):
        raise ValueError("%s is not a valid integer" % l8_bidx)

    calculate_landsat_reflectance(src_path, src_mtl, dst_path, creation_options, l8_bidx, dst_dtype, workers)
Exemplo n.º 4
0
def radiance(ctx, src_path, src_mtl, dst_path, verbose, creation_options,
             l8_bidx, dst_dtype, workers):
    """Calculates Landsat8 Surface Radiance
    """
    if verbose:
        logger.setLevel(logging.DEBUG)

    if l8_bidx == 0:
        template = '.*\LC8.*_B{b}.TIF'
        l8_bidx = _parse_bands_from_filename([src_path], template)[0]
    elif not isinstance(l8_bidx, int):
        raise ValueError("%s is not a valid integer" % l8_bidx)

    calculate_landsat_radiance(src_path, src_mtl, dst_path, creation_options,
                               l8_bidx, dst_dtype, workers)
Exemplo n.º 5
0
def reflectance(ctx, src_paths, src_mtl, dst_path, dst_dtype, rescale_factor,
                clip, readtemplate, workers, l8_bidx, verbose,
                creation_options, pixel_sunangle):
    """Calculates Landsat8 Top of Atmosphere Reflectance
    """
    if verbose:
        logger.setLevel(logging.DEBUG)

    if l8_bidx == 0:
        l8_bidx = _parse_bands_from_filename(list(src_paths), readtemplate)

    calculate_landsat_reflectance(list(src_paths), src_mtl, dst_path,
                                  rescale_factor, creation_options,
                                  list(l8_bidx), dst_dtype, workers,
                                  pixel_sunangle, clip)
Exemplo n.º 6
0
def brighttemp(ctx, src_path, src_mtl, dst_path, dst_dtype, temp_scale,
               readtemplate, workers, thermal_bidx, verbose, creation_options):
    """Calculates Landsat8 at-satellite brightness temperature.
    TIRS band data can be converted from spectral radiance
    to brightness temperature using the thermal
    constants provided in the metadata file:
    """

    if verbose:
        logger.setLevel(logging.DEBUG)

    if thermal_bidx == 0:
        thermal_bidx = _parse_bands_from_filename([src_path], readtemplate)[0]

    calculate_landsat_brightness_temperature(src_path, src_mtl, dst_path,
                                             temp_scale, creation_options,
                                             thermal_bidx, dst_dtype, workers)
Exemplo n.º 7
0
def test_parse_band_from_filename_good():
    assert _parse_bands_from_filename(['LC81070352015122LGN00_B3.tif'],
                                      'LC8.*_B{b}.tif') == [3]
Exemplo n.º 8
0
def test_parse_band_from_filename_bad():
    with pytest.raises(ValueError):
        _parse_bands_from_filename(['LC81070352015122LGN00_B3.tif'],
                                   'LC8NOGOOD.*_B{b}.tif')
Exemplo n.º 9
0
def test_parse_band_from_filename_good():
	assert _parse_bands_from_filename(['LC81070352015122LGN00_B3.tif'], 'LC8.*_B{b}.tif') == [3]
Exemplo n.º 10
0
def test_parse_band_from_filename_bad():
	with pytest.raises(ValueError):
		_parse_bands_from_filename(['LC81070352015122LGN00_B3.tif'], 'LC8NOGOOD.*_B{b}.tif')
Exemplo n.º 11
0
def test_parse_band_from_filename_default():
    assert _parse_bands_from_filename(['data/LC81070352015122LGN00_B3.TIF'],
                                      '.*/LC8.*\_B{b}.TIF') == [3]
Exemplo n.º 12
0
def test_parse_band_from_filename_bad2():
    with pytest.raises(ValueError):
        _parse_bands_from_filename(['data/tiny_LC81070352015122LGN00_B3.tif'],
                                   '.*/LC8.*\_B{b}.TIF')