Quantcast
Channel: Earthdata Forum
Viewing all articles
Browse latest Browse all 1307

Home • Re: GEDI L2B products : removing nan valeus, noises and analysus

$
0
0
To export all values (not just mean or median) from specific bands like rh98, rh90, rh75, and rh50 from your dataset, you can use Google Earth Engine's reduceRegion function along with export.table.toDrive to export the data as a CSV file. Here's how you can modify your

script:
// Load the dataset
var dataset = ee.ImageCollection('LARSE/GEDI/GEDI02_A_002_MONTHLY')
.map(qualityMask)
.select(['rh98', 'rh90', 'rh75', 'rh50'])
.filterBounds(municipiosIntersectados)
.filterDate(startDateObj, endDateObj);

// Function to reduce each image to a single row per region of interest
var reduceToTable = function(image) {
var stats = image.reduceRegion({
reducer: ee.Reducer.percentile([98, 90, 75, 50]),
geometry: municipiosIntersectados,
scale: 30, // Adjust scale as per your requirement
bestEffort: true,
});
return ee.Feature(null, stats);
};

// Apply the reduceRegion function to each image in the collection
var reduced = dataset.map(reduceToTable);

// Flatten the collection of features into a single FeatureCollection
var featureCollection = ee.FeatureCollection(reduced);

// Export the FeatureCollection to Google Drive as a CSV file
Export.table.toDrive({
collection: featureCollection,
description: 'GEDI_percentiles_data',
fileFormat: 'CSV',
});

Explanation:
Loading Dataset: Load the GEDI dataset and apply any necessary filters (qualityMask, filterBounds, filterDate).

Mapping Percentiles: Select the bands (rh98, rh90, rh75, rh50) and map a function (reduceToTable) over the image collection to compute the percentiles for each image.

ReduceRegion Function: Within reduceToTable, use reduceRegion with ee.Reducer.percentile to calculate the specified percentiles (98, 90, 75, 50) for each image within the specified region (municipiosIntersectados).

FeatureCollection: Convert the reduced image collection (reduced) into a FeatureCollection where each feature contains the computed percentiles as properties.

Export to Drive: Use Export.table.toDrive to export the FeatureCollection to Google Drive as a CSV file. Adjust description and other parameters (fileFormat, scale, etc.) as per your specific needs.

Make sure to replace municipiosIntersectados, startDateObj, and endDateObj with your actual variables or values. Adjust the scale parameter in reduceRegion according to the resolution needed for your analysis.

Statistics: Posted by vuelitics — Wed Jul 03, 2024 9:02 am America/New_York



Viewing all articles
Browse latest Browse all 1307

Trending Articles