Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: New version (2023.10.14) does not handle Landsat8 dataset correctly. #48

Open
mn5hk opened this issue Jan 26, 2024 · 5 comments
Open
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@mn5hk
Copy link

mn5hk commented Jan 26, 2024

Hi team, the new version appears to have problems when taking reducers with the Landsat 8 data.

Sharing a code snippet here:

#Acquire optical data using hf.dataset
optical = hf.Landsat8(tonlesap, start_date, end_date)
elv = ee.Image("JAXA/ALOS/AW3D30/V2_2").select("AVE_DSM")

opt_corrected = optical.apply_func(corrections.illumination_correction, elevation = elv)

opt_reduced = opt_corrected.collection.median()

Map = geemap.Map(center = (12.7, 105), zoom = 8)

Map.addLayer(tonlesap, {}, 'Region of Interest')
Map.addLayer(opt_reduced, opt_params, 'Optical Imagery')
Map.addLayerControl()
Map

Also attached are the snippets of the error msg:
image
image

@KMarkert
Copy link
Collaborator

Can you please share a full working example for me to replicate and investigate? What are the variables tonlesap, start_date, end_date?

@mn5hk
Copy link
Author

mn5hk commented Jan 28, 2024

Hi @KMarkert, thanks for a quick response. Please find an extended code snippet with roi and timeslice definitions:

#Define the region of interest
tonlesap = ee.Geometry.Polygon([
        [106.40316, 11.7778],
        [106.40316, 13.6104],
        [103.56869, 13.6104],
        [103.56869, 11.7778]
    ])

#Define time period of interest
start_date = "2021-09-26"
end_date = "2021-10-15"

opt_params = {
    "min": 50,
    "max": 5500,
    "bands": "red,green,blue",
    "gamma":1.5,
    "dimensions": 1024
}

#Acquire optical data using hf.dataset
optical = hf.Landsat8(tonlesap, start_date, end_date)
elv = ee.Image("JAXA/ALOS/AW3D30/V2_2").select("AVE_DSM")

opt_corrected = optical.apply_func(corrections.illumination_correction, elevation = elv)

opt_reduced = opt_corrected.collection.median()

Map = geemap.Map(center = (12.7, 105), zoom = 8)

Map.addLayer(tonlesap, {}, 'Region of Interest')
Map.addLayer(opt_reduced, opt_params, 'Optical Imagery')
Map.addLayerControl()
Map

@KMarkert KMarkert added bug Something isn't working good first issue Good for newcomers labels Jan 28, 2024
@KMarkert
Copy link
Collaborator

Found the source of the error. There is a lookup for sun angle properties in the illumination_correction function (see here).

The latest update upgraded the Landsat collections to use Collection 2 (C1 is deprecated) and there were changes to property names including the ones that are looked up by the function which causes it to fail.

here is a quick fix that worked for me:

#Acquire optical data using hf.dataset
optical = hf.Landsat8(tonlesap, start_date, end_date)

# function to rename the sun angle properties to what is expected by
# the illumination_correction function
def rename_sunangle_properties(image):
    sz = ee.Number(90).subtract(image.get('SUN_ELEVATION'))
    sa = image.get('SUN_AZIMUTH')
    return image.set({"SOLAR_ZENITH_ANGLE": sz, "SOLAR_AZIMUTH_ANGLE": sa})

# apply the function to rename properties
optical = optical.apply_func(rename_sunangle_properties)

elv = ee.Image("JAXA/ALOS/AW3D30/V2_2").select("AVE_DSM").unmask(0)

opt_corrected = optical.apply_func(hf.corrections.illumination_correction, elevation = elv, scale=180)

Longer term fix will be to update the illumination_correction function lookup section to look for the correct properties. That should be a relatively straightforward fix.

@mn5hk
Copy link
Author

mn5hk commented Jan 29, 2024

Hi Kel, the quick fix worked for me. Thanks a lot for your prompt support and a detailed explanation to the issue.

@mn5hk mn5hk closed this as completed Jan 29, 2024
@KMarkert
Copy link
Collaborator

No problem!

I am reopening this issue so we have in in the backlog for things to fix.

@KMarkert KMarkert reopened this Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants