GEE错误——Line 35: nir.subtract is not a function

在使用Google Earth Engine (GEE)时遇到'Line 35: nir.subtract is not a function'错误。该错误表明'nir'对象不是一个图像或类型不匹配。解决方法包括确保'nir'是图像且与操作对象类型相同,或通过镶嵌成图像或使用map()函数。原始代码中的问题在于在影像集合上应用了不应有的函数。修正后的代码应该正确使用影像或影像集合的方法。
摘要由CSDN通过智能技术生成

错误:

Line 35: nir.subtract is not a function

错误信息“第35行:nir.subtract不是一个函数”的意思是nir对象中不存在subtract()方法。这可能是因为nir对象不是一个图像,或者它是与您尝试从中减去的图像类型不同的图像。
要解决此错误,您需要确保nir对象是一个图像,并且它与您尝试从中减去的图像类型相同。

这里的主要问题在于就是我们应用的对象是影像集合,而不是影像,这一定我们可以在image collection中函数查看,它是没有加减乘除这些函数的,你只能看到image中有这个函数。所以我们就是认清两者的差异,然后这里的解决方案就是有两种,一种是影像集合镶嵌成为影像,另外一种就是将ndvi写成一个函数,利用map()进行遍历即可。同时可以利用表达式和集成的归一化函数来实现这个功能。

原始代码链接:

https://code.earthengine.google.com/4090e69773c331dea6c9d45a276e4e45

函数:

normalizedDifference(bandNames)

Computes the normalized difference between two bands. If the bands to use are not specified, uses the first two bands. The normalized difference is computed as (first − second) / (first + second). Note that the returned image band name is 'nd', the input image properties are not retained in the output image, and a negative pixel value in either input band will cause the output pixel to be masked. To avoid masking negative input values, use ee.Image.expression() to compute normalized difference.

Arguments:

this:input (Image):

The input image.

bandNames (List, default: null):

A list of names specifying the bands to use. If not specified, the first and second bands are used.

Returns: Image

问题:

这里其实代码并没有问题,我们只需仔细检查其代码的函数部分,只是在我们应用指数的函数中我们放错了我们影像,所以这里我们</

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

此星光明

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值