GEE错误——Line 2: ee.Image(...).filterBounds is not a function

简介: GEE错误——Line 2: ee.Image(...).filterBounds is not a function

错误:

我正在尝试通过应用过滤器绑定和过滤器日期来提取多个区域的平均碳含量。我得到的错误是:'filterbound 不是一个函数。

我认为问题在于我使用的是 ee.Image 而不是 ee.ImageCollection。我知道如何解决这个问题吗?谢谢

这里的代码: https://code.earthengine.google.com/82cc1dffe68a8b058f9befd267148072

Line 2: ee.Image(...).filterBounds is not a function

上面这张图片中我们可以看到filterbounds函数的作用对象是影像集合而不是影像,所以我们作用的对象发生了错误。

原始代码:

var points = ee.FeatureCollection("projects/gee2erainfall/assets/arable_devices_metadata");
var idasoil = ee.Image("ISDASOIL/Africa/v1/carbon_organic")
    .filterBounds(points)
    .filterDate('2015-08-01', '2017-09-08')
print('Size of Idasoil collection', idasoil.size()); 
var triplets = idasoil.map(function(image) {
  return image.select('mean_0_20').reduceRegions({
    collection: points.select(['arable_barcode']), 
    reducer: ee.Reducer.mean(), 
    scale: 30
  }).filter(ee.Filter.neq('mean', null))
    .map(function(f) { 
      return f.set('imageId', image.id());
    });
}).flatten();
print(triplets.first());
// We can export this tall table.
// Specify the columns that we want to export
Export.table.toDrive({
    collection: triplets,
    description: 'Arabledev_carbon_time_series',
    folder: 'earthengine',
    fileNamePrefix: 'Arabledev_carbon_time_series',
    fileFormat: 'CSV',
    selectors: ['arable_barcode', 'imageId', 'mean']
});

解决方案:

将影像换成影像集合代码就成立了,我们换一个影像集合,或者我们将影像单独直接操作就可以,区域统计是通过在图像上运行 reduceRegions() 来完成的。由于您的输入数据只是图像,因此您可以直接运行此函数。如果集合中有多个图像,则您使用的代码适合。

函数

reduceRegions(collection, reducer, scale, crs, crsTransform, tileScale)

Apply a reducer over the area of each feature in the given collection.

The reducer must have the same number of inputs as the input image has bands.

Returns the input features, each augmented with the corresponding reducer outputs.

Arguments:

this:image (Image):

The image to reduce.

collection (FeatureCollection):

The features to reduce over.

reducer (Reducer):

The reducer to apply.

scale (Float, default: null):

A nominal scale in meters of the projection to work in.

crs (Projection, default: null):

The projection to work in. If unspecified, the projection of the image's first band is used. If specified in addition to scale, rescaled to the specified scale.

crsTransform (List, default: null):

The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with 'scale', and will replace any transform already set on the projection.

tileScale (Float, default: 1):

A scaling factor used to reduce aggregation tile size; using a larger tileScale (e.g. 2 or 4) may enable computations that run out of memory with the default.

Returns: FeatureCollection

修改后的代码:

var idasoil = ee.Image("ISDASOIL/Africa/v1/carbon_organic")
var stats = idasoil.reduceRegions({
    collection: points.select(['arable_barcode']), 
    reducer: ee.Reducer.mean(), 
    scale: 30
  })
print(stats);
// We can export this tall table.
// Specify the columns that we want to export
Export.table.toDrive({
    collection: stats,
    description: 'Arabledev_carbon_time_series',
    folder: 'earthengine',
    fileNamePrefix: 'Arabledev_carbon_time_series',
    fileFormat: 'CSV',
});

 

相关文章
|
2月前
GEE错误——XXX is not a function,如何解决这个问题?
GEE错误——XXX is not a function,如何解决这个问题?
141 0
|
2月前
|
JavaScript 前端开发
GEE错误——gee错误Line 35: nir.subtract is not a function
GEE错误——gee错误Line 35: nir.subtract is not a function
21 0
|
2月前
Google Earth Engine(GEE)——当你无法进行两个图像相减的时候发生错误lst2020.subtract is not a function
Google Earth Engine(GEE)——当你无法进行两个图像相减的时候发生错误lst2020.subtract is not a function
23 0
|
2月前
Google Earth Engine(GEE)——ndvi.gt is not a function
Google Earth Engine(GEE)——ndvi.gt is not a function
18 2
|
6月前
|
编译器 C语言
__FILE__, __LINE__ __FUNCTION__
__FILE__, __LINE__ __FUNCTION__
|
Linux C语言 C++
__FILE__,__LINE__,FUNCTION__实现代码跟踪调试(linux下c语言编程 )
root@xuanfei-desktop:~/cpropram/2# cat global.h //头文件#ifndef CLOBAL_H        #define GLOBAL_H        #include         int funca(void);        int func...
1121 0
|
26天前
|
资源调度 Serverless 计算机视觉
高斯函数 Gaussian Function
**高斯函数,或称正态分布,以数学家高斯命名,具有钟形曲线特征。关键参数包括期望值μ(决定分布中心)和标准差σ(影响分布的宽度)。当μ=0且σ²=1时,分布为标准正态分布。高斯函数广泛应用于统计学、信号处理和图像处理,如高斯滤波器用于图像模糊。其概率密度函数为e^(-x²/2σ²),积分结果为误差函数。在编程中,高斯函数常用于创建二维权重矩阵进行图像的加权平均,实现模糊效果。
17 1
|
1月前
|
算法 Serverless C语言
CMake函数和宏(function和macro):使用函数和宏提高代码可读性
CMake函数和宏(function和macro):使用函数和宏提高代码可读性
33 1
|
1月前
|
存储 安全 编译器
【C++ 包装器类 std::function 和 函数适配器 std::bind】 C++11 全面的std::function和std::bind的入门使用教程
【C++ 包装器类 std::function 和 函数适配器 std::bind】 C++11 全面的std::function和std::bind的入门使用教程
33 0
|
1月前
|
SQL Oracle 关系型数据库
Flink的表值函数(Table-Valued Function,TVF)是一种返回值是一张表的函数
【2月更文挑战第17天】Flink的表值函数(Table-Valued Function,TVF)是一种返回值是一张表的函数
21 1

热门文章

最新文章