• 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函数的作用对象是影像集合而不是影像,所以我们作用的对象发生了错误。

    原始代码:

    1. var points = ee.FeatureCollection("projects/gee2erainfall/assets/arable_devices_metadata");
    2. var idasoil = ee.Image("ISDASOIL/Africa/v1/carbon_organic")
    3. .filterBounds(points)
    4. .filterDate('2015-08-01', '2017-09-08')
    5. print('Size of Idasoil collection', idasoil.size());
    6. var triplets = idasoil.map(function(image) {
    7. return image.select('mean_0_20').reduceRegions({
    8. collection: points.select(['arable_barcode']),
    9. reducer: ee.Reducer.mean(),
    10. scale: 30
    11. }).filter(ee.Filter.neq('mean', null))
    12. .map(function(f) {
    13. return f.set('imageId', image.id());
    14. });
    15. }).flatten();
    16. print(triplets.first());
    17. // We can export this tall table.
    18. // Specify the columns that we want to export
    19. Export.table.toDrive({
    20. collection: triplets,
    21. description: 'Arabledev_carbon_time_series',
    22. folder: 'earthengine',
    23. fileNamePrefix: 'Arabledev_carbon_time_series',
    24. fileFormat: 'CSV',
    25. selectors: ['arable_barcode', 'imageId', 'mean']
    26. });

    解决方案:

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

    函数

    reduceRegions(collection, reducer, scalecrscrsTransformtileScale)

    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

    修改后的代码:

    1. var idasoil = ee.Image("ISDASOIL/Africa/v1/carbon_organic")
    2. var stats = idasoil.reduceRegions({
    3. collection: points.select(['arable_barcode']),
    4. reducer: ee.Reducer.mean(),
    5. scale: 30
    6. })
    7. print(stats);
    8. // We can export this tall table.
    9. // Specify the columns that we want to export
    10. Export.table.toDrive({
    11. collection: stats,
    12. description: 'Arabledev_carbon_time_series',
    13. folder: 'earthengine',
    14. fileNamePrefix: 'Arabledev_carbon_time_series',
    15. fileFormat: 'CSV',
    16. });

     

  • 相关阅读:
    SpringCloud学习笔记 - 消息总线 - Spring Cloud Bus
    MapReduce的编程开发-格式整理
    专利一般怎么命名?
    C. Salyg1n and the MEX Game Codeforces Round 897 (Div. 2)
    你是否感受到AI就在身边?
    C++哈希+哈希改造
    以下代码运行可外接设备串口摄像头COM5的一个静止图像,如何修改才能实现获取图像数据的刷新,让运行弹出窗口的图像有实时显示功能
    Python 自动化教程(1) 概述,第一篇 Excel自动化首篇
    【Unity】3D跑酷游戏
    BOM之location对象
  • 原文地址:https://blog.csdn.net/qq_31988139/article/details/133616241