I am working on a project using Google Earth Engine to analyze geospatial data, specifically Sentinel-2 imagery. I have encountered a perplexing issue where, despite valid minimum and maximum values for certain Landsat bands, the corresponding band values in my dataset are consistently null. This occurs even when other bands in the same dataset have valid and non-null values.
Key Details: I have carefully examined the Landsat dataset details and confirmed the existence of valid minimum and maximum values for the bands in question (e.g., B1, B10, B11, etc.). The issue persists across multiple Landsat datasets, and I have also checked alternative bands such as 'avg_rad,' which do not exhibit the same problem. I have tried various approaches to access and print these bands within the Google Earth Engine scripting environment, but the values continue to appear as null. I am seeking assistance from the community to diagnose and understand the root cause of this issue, as it hinders the progress of my project.
// Load the six datasets for each year
var dataset2015 = ee.Image('users/aissanasralli/tunisia/2015/stacked_image_tunisia_2015');
var dataset2016 = ee.Image('users/aissanasralli/tunisia/2016/stacked_image_tunisia_2016');
var dataset2017 = ee.Image('users/aissanasralli/tunisia/2017/stacked_image_tunisia_2017');
var dataset2018 = ee.Image('users/aissanasralli/tunisia/2018/stacked_image_tunisia_2018');
var dataset2019 = ee.Image('users/aissanasralli/tunisia/2019/stacked_image_tunisia_2019');
var dataset2020 = ee.Image('users/aissanasralli/tunisia/2020/stacked_image_tunisia_2020');
// estimates for 2015 and 2020
var worldpop2015 = ee.Image('projects/ee-aissanasralli/assets/TUN_pph_2015_v2');
var worldpop2020 = ee.Image('projects/ee-aissanasralli/assets/TUN_pph_2020_v2');
// Load administrative boundary of Tunisia
var tunisiaBoundary = ee.FeatureCollection('FAO/GAUL/2015/level0').filter(ee.Filter.eq('ADM0_NAME', 'Tunisia'));
// Create a region of interest (ROI) based on the administrative boundary
var roi = tunisiaBoundary.geometry();
// Sample the target variable (population in 2020) at random points within Tunisia
var samples = worldpop2020.sample({
region: roi,
scale: 100, // Adjust the scale based on your dataset resolution
numPixels: 10, // Adjust the number of pixels based on your needs
geometries: true // Include geometries in the samples
});
// Define input features (X) and target variable (Y)
var features = [dataset2015, dataset2016, dataset2017, dataset2018, dataset2019, dataset2020];
var target = 'b1'; // the actual band name in worldpop2020
// Map over the samples to associate features and target variable
var trainingData = samples.map(function(sample) {
// Get the geometry of the sample
var geometry = sample.geometry();
// Extract values of each feature at the sample's location
var featureValues = ee.List(features).map(function(feature) {
return ee.Image(feature).reduceRegion(ee.Reducer.first(), geometry, 100);
});
// Extract the target variable at the sample's location
var targetValue = sample.get(target);
// Create a feature with properties for each feature and the target
return ee.Feature(geometry, {
'feature_2015': featureValues.get(0),
'feature_2016': featureValues.get(1),
'feature_2017': featureValues.get(2),
'feature_2018': featureValues.get(3),
'feature_2019': featureValues.get(4),
'feature_2020': featureValues.get(5),
'target': targetValue,
});
});
// Print one training sample to check its structure
print('propertyNames:', trainingData.propertyNames());
print('Example Training Sample:', trainingData.first());
print('Size:', trainingData.size());
Has anyone encountered similar challenges with null values in Landsat bands within the Google Earth Engine environment?
What potential factors or considerations could lead to valid min/max values coexisting with persistent null values in Landsat bands?
Are there alternative methods or best practices to access and retrieve Landsat band values in Earth Engine that I might be overlooking?
What I Tried: I have attempted various approaches to access and print Landsat bands in my Google Earth Engine script, focusing on bands such as B1, B10, B11, and others. I carefully examined the Landsat dataset details to ensure valid minimum and maximum values for these bands.
Expected Outcome: I expected to retrieve and print the actual band values for each pixel in the specified Landsat bands. My goal was to analyze the temporal and spatial patterns within these bands to further my geospatial analysis.
Actual Outcome: Despite valid minimum and maximum values being present in the Landsat dataset details, I consistently observed null values when attempting to access and print the band values. This occurred across multiple Landsat datasets and persisted even when using alternative bands such as 'avg_rad,' which did not exhibit the same issue.
Methods Tried:
Utilizing the reduceRegion function to extract band values at specific points.
Iterating over training samples and using the get method to retrieve band values.
Checking alternative bands and metadata to identify any anomalies.