<jupyter_start><jupyter_text>Tasseled Cap Transformation for atmospherical adjusted Landsat 8 imagery**Author:** <NAME>**Description:** Tasseled Cap Transformation for Landsat 8 TOA imagery based on the scientfic work "Derivation of a tasselled cap transformation based on Landsat 8 at-satellite reflectance" by M.Baigab, L.Zhang, T.Shuai & Q.Tong (2014). The bands of the output image are the brightness index, greenness index and wetness index.<jupyter_code>from IPython.display import Image
import ee
ee.Initialize()<jupyter_output><empty_output><jupyter_text>Loading Landsat 8 TOA image Location: Oaxaca, Veracruz, Tabasco and Chiapas México<jupyter_code>image = ee.Image('LANDSAT/LC8_L1T_TOA/LC80230482016032LGN00')<jupyter_output><empty_output><jupyter_text>Create function for Tasseled Cap Transformation<jupyter_code># Function
def tasseled_cap_transformation(image):
    b = image.select("B2", "B3", "B4", "B5", "B6", "B7");
    #Coefficients are only for Landsat 8 TOA imagery
    brightness_coefficents= ee.Image([0.3029, 0.2786, 0.4733, 0.5599, 0.508, 0.1872])
    greenness_coefficents= ee.Image([-0.2941, -0.243, -0.5424, 0.7276, 0.0713, -0.1608]);
    wetness_coefficents= ee.Image([0.1511, 0.1973, 0.3283, 0.3407, -0.7117, -0.4559]);
    fourth_coefficents= ee.Image([-0.8239, 0.0849, 0.4396, -0.058, 0.2013, -0.2773]);
    fifth_coefficents= ee.Image([-0.3294, 0.0557, 0.1056, 0.1855, -0.4349, 0.8085]);
    sixth_coefficents= ee.Image([0.1079, -0.9023, 0.4119, 0.0575, -0.0259, 0.0252]);
    
    #Calculate tasseled cap transformation
    brightness = image.expression(
        '(B * BRIGHTNESS)',
        {
            'B':b,
            'BRIGHTNESS': brightness_coefficents
        })
    greenness = image.expression(
        '(B * GREENNESS)',
        {
            'B':b,
            'GREENNESS': greenness_coefficents
        })
    wetness = image.expression(
        '(B * WETNESS)',
        {
            'B':b,
            'WETNESS': wetness_coefficents
        })
    fourth = image.expression(
        '(B * FOURTH)',
        {
            'B':b,
            'FOURTH': fourth_coefficents
        })
    fifth = image.expression(
        '(B * FIFTH)',
        {
            'B':b,
            'FIFTH': fifth_coefficents
        })
    sixth = image.expression(
        '(B * SIXTH)',
        {
            'B':b,
            'SIXTH': sixth_coefficents
        })
    bright = brightness.reduce(ee.call("Reducer.sum"));
    green = greenness.reduce(ee.call("Reducer.sum"));
    wet = wetness.reduce(ee.call("Reducer.sum"));
    four = fourth.reduce(ee.call("Reducer.sum"));
    five = fifth.reduce(ee.call("Reducer.sum"));
    six = sixth.reduce(ee.call("Reducer.sum"));
    tasseled_cap = ee.Image(bright).addBands(green).addBands(wet).addBands(four).addBands(five).addBands(six)
    return tasseled_cap.rename('brightness','greenness','wetness','fourth','fifth','sixth')<jupyter_output><empty_output><jupyter_text>Derive and visualize Tasseled Cap Transformation<jupyter_code>tasseled_cap = tasseled_cap_transformation(image)
palette = ['FFFFFF','C0C0C0','808080','000000','FF0000','800000','FFFF00','808000','00FF00','008000','00FFFF','008080','0000FF','000080','FF00FF','800080']
palette = ','.join(palette)<jupyter_output><empty_output><jupyter_text>Brightness Index<jupyter_code>region = image.geometry().getInfo()['coordinates']
brightness = tasseled_cap.getThumbUrl({'min':-1,'max':1,
                                      'bands':['brightness'], 'palette':palette,'region':region})
Image(url=brightness)<jupyter_output><empty_output><jupyter_text>Greenness Index<jupyter_code>region = image.geometry().getInfo()['coordinates']
greenness = tasseled_cap.getThumbUrl({'min':-1,'max':1,
                                      'bands':['greenness'], 'palette':palette, 'region':region})
Image(url=greenness)<jupyter_output><empty_output><jupyter_text>Wetness Index<jupyter_code>region = image.geometry().getInfo()['coordinates']
wetness = tasseled_cap.getThumbUrl({'min':-1,'max':1,
                                      'bands':['wetness'], 'palette':palette, 'region':region})
Image(url=wetness)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15841346153846153, 'fraction_numerical': 0.06850961538461539, 'mean_word_length': 3.685810810810811, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '450431', 'license': 'Apache-2.0', 'n_tokens_mistral': 1687, 'n_tokens_neox': 1480, 'n_words': 234, 'path': '002_EE_Tasseled_Cap_Transformation_Landsat_8_TOA.ipynb', 'repo_name': 'wangjinzhulala/Google-Earth-Engine-Python-Examples', 'size': '4167'}