GEE错误——Layer error: Image.connectedPixelCount: Segment size calculation on floating point bands is n

简介: GEE错误——Layer error: Image.connectedPixelCount: Segment size calculation on floating point bands is n

问题

我正在编写一段代码,用于检测/计算图像中烧焦区域的斑块。我以为使用 GEE 中的 connectedPixelCount() 函数可以帮助我完成这项工作。然而,后者似乎对合成图像不起作用。有没有办法让它将合成图像视为典型的单层图像?(如果有用于合成图像的替代函数,也能解决我的问题)。

Layer error: Image.connectedPixelCount: Segment size calculation on floating point bands is not supported. Unsupported type: Type<Float<-32768.0, 32767.0>>.

函数

connectedPixelCount(maxSize, eightConnected)

生成一幅图像,其中每个像素包含 4 个或 8 个相连的相邻像素(包括自身)。

参数:

this:input(图像):

输入的图像。

maxSize(整数,默认:100):

邻域的最大尺寸(像素)。

eightConnected(布尔值,默认值:true):

是否使用 8 连接而非 4 连接的规则。

返回值 图像

int32()

On an element-wise basis, casts the input value to a signed 32-bit integer.

Arguments:

this:input (Array):

The input array.

Returns: Image

原始代码:

var country = ['AU'];
var geometry = ee.FeatureCollection('USDOS/LSIB/2013')
                      .filter(ee.Filter.inList('cc', country));
Map.centerObject(geometry, 5);
var modisFire = ee.ImageCollection('MODIS/006/MCD64A1')
                  .map(function(image) { return image.clip(geometry);})
                  .filter(ee.Filter.date('2017-01-01', '2017-12-31'))
                  .select('BurnDate');
var date = ee.Date('2017-06-01');
var composite = modisFire.mean().set('system:time_start', date.millis(), 
                                     'dateYMD', date.format('YYYY-MM-dd'), 
                                      'numbImages', modisFire.size());
var img = ee.Image(modisFire.toList(3).get(0));
var img1 = ee.Image(composite);
Map.addLayer(img, {palette: 'red'}, 'June Fire');
Map.addLayer(img, {palette: 'orange'}, 'Summer Fire');
var patches = img1.connectedPixelCount(5, false);
patches = patches.updateMask(patches.gte(5));
Map.addLayer(patches, {palette: 'blue'}, 'Burned Area');

修改后的代码

var modisFire = ee.ImageCollection('MODIS/006/MCD64A1')
                  .map(function(image) { return image.clip(geometry);})
                  .filter(ee.Filter.date('2017-05-01', '2017-08-31'))
                  .select('BurnDate');
var date = ee.Date('2017-06-01');
var composite = modisFire.mean().set('system:time_start', date.millis(), 
                                     'dateYMD', date.format('YYYY-MM-dd'), 
                                      'numbImages', modisFire.size());
var img = ee.Image(modisFire.toList(3).get(0));
var img1 = ee.Image(composite);
Map.addLayer(img, {palette: 'red'}, 'June Fire');
Map.addLayer(img, {palette: 'orange'}, 'Summer Fire');
var patches = img1.int16().connectedPixelCount(5, false);
Map.addLayer(patches, {palette: 'red'}, 'patches');
patches = patches.updateMask(patches.gte(5));
Map.addLayer(patches, {palette: 'blue'}, 'Burned Area');

相关文章
|
9月前
【Simulink】报错:Size mismatch (size [2 x 1] ~= size [1 x 1]). The size to the left is the size of the l
【Simulink】报错:Size mismatch (size [2 x 1] ~= size [1 x 1]). The size to the left is the size of the l
|
9月前
|
Python
GEE—关于RSEI生态遥感指数中出现的问题 Layer error: Image.rename: The number of names (1) must match the number of..
GEE—关于RSEI生态遥感指数中出现的问题 Layer error: Image.rename: The number of names (1) must match the number of..
244 0
成功解决but is 0 and 2 (computed from start 0 and end 9223372 over shape with rank 2 and stride-1)
成功解决but is 0 and 2 (computed from start 0 and end 9223372 over shape with rank 2 and stride-1)
|
索引
Result window is too large, from + size must be less than or equal to: [10000]
Result window is too large, from + size must be less than or equal to: [10000]
269 0
|
JSON 数据格式
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
577 0
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
Only Tensors of floating point and complex dtype can require gradients问题解决方案
Only Tensors of floating point and complex dtype can require gradients问题解决方案
472 0
Only Tensors of floating point and complex dtype can require gradients问题解决方案
undefined reference to `gdk_monitor_get_scale_factor/gtk_widget_get_scale_factor‘
undefined reference to `gdk_monitor_get_scale_factor/gtk_widget_get_scale_factor‘
102 0
error: x264_bit_depth undeclared (first use in this function) did you mean x264_picture_t
error: x264_bit_depth undeclared (first use in this function) did you mean x264_picture_t
170 0
ValueError: Sample larger than population or is negative
ValueError: Sample larger than population or is negative
209 0
Denodo For Big Data
In order to build Virtual Data Services, the user follows three simple steps: 1. Connect & Virtualize Any Source.
2304 0