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');

相关文章
|
7月前
【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
|
7月前
|
iOS开发
Xcode报错“compact unwind compressed function offset doesn‘t fit in 24 bits
Xcode报错“compact unwind compressed function offset doesn‘t fit in 24 bits
71 1
|
7月前
random.sample(population, k)
random.sample(population, k)
44 0
YOLO V5出现RuntimeError: result type Float can‘t be cast to the desired output type long int解决方法
YOLO V5出现RuntimeError: result type Float can‘t be cast to the desired output type long int解决方法
717 0
|
索引
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]
245 0
Multiple substitutions specified in non-positional format; did you mean to add BUG(7)
Multiple substitutions specified in non-positional format; did you mean to add BUG(7)
|
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
543 0
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
|
编译器
relocation value does not fit in 26 bits (offset: 0x10, type: 1)
relocation value does not fit in 26 bits (offset: 0x10, type: 1)
214 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
167 0
Julia:报错 no method matching increment_deriv!(::Float64, ::Float64)
描述是 `no method matching increment_deriv!(::Float64, ::Float64)` ,找不到该方法。
114 0