admin管理员组

文章数量:1185646

I've quite new to working with satellite data and the Google Earth Engine (GEE). I've been working on using their machine leanring models to train a classifier. I then attempted to understands some of the regional statistics using the ReduceRegions() function to calculate the mean water temperature and salinity.

Each of the regions are created using polygons.

Here's a code snippet of the functionality:

var mariculture_regions = classified_threshold.selfMask();
var region_features = [
    ee.Feature(AOI_Saul, {region: 'Sual'}),
    ee.Feature(AOI_Burgos, {region: 'Burgos'}),
    ee.Feature(AOI_Ormoc, {region: 'Ormoc'}),
    ee.Feature(AOI_Balingasag, {region: 'Balingasag'}),
    ee.Feature(AOI_Panabo, {region: 'Panabo'})
  ];
var all_regions = ee.FeatureCollection(region_features);
var mariculture_geometries = all_regions.filterBounds(mariculture_regions.geometry());

/*
  Extract water temperature and salinity at 2m depth for mariculture sites.
*/
var sea_temp_salinity = hycom_sea_temp_salinity
                        .filter(ee.Filter.date('2024-01-01', '2024-01-15'))
                        .filter(ee.Filter.bounds(all_regions));
var seaWaterTemperature = sea_temp_salinity.select('water_temp_2')
  .map(function scaleAndOffset(image) {
    return ee.Image(image).multiply(0.001).add(20);
  }).first();
var seaSalinity = sea_temp_salinity.select('salinity_2')
  .map(function scaleAndOffset(image) {
    return ee.Image(image).multiply(0.001).add(20);
  }).first();
  
var mariculture_water_stats = mariculture_regions.addBands(seaWaterTemperature, ['water_temp_2']).addBands(seaSalinity, ['salinity_2']);

var stats = mariculture_water_stats.sampleRegions({
  collection: mariculture_geometries,
  scale: 10,
  geometries: true
});

var mariculture_means = mariculture_water_stats.select(['water_temp_2', 'salinity_2']).reduceRegions({
  collection: mariculture_geometries.limit(1000),
  reducer: ee.Reducer.mean(),
  scale: 10,
  tileScale: 16
});

print(mariculture_means);
print(stats)

Ideally I should be able to obtain the means for water temperature and salinity for all regions. However, both the reduceRegions() and sampleRegions() only return the mean values for the "Sual" region.

I've attempted the following with no success:

  1. Adding CRS transforms, tileScale, bestEffort.
  2. Changing the order of regions.
  3. Using reduceRegion() for each region individually.

In all the above cases only the mean value for "Sual" is valid and the rest are null. I am quite perplexed as to where I have gone wrong with my code.

本文标签: javascriptGEE reduceRegions() and sampleRegions() returns null values for certain geometriesStack Overflow