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

相关文章
|
8月前
【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
成功解决matplotlib.units.ConversionError: Failed to convert value(s) to axis units: ‘LiR‘
成功解决matplotlib.units.ConversionError: Failed to convert value(s) to axis units: ‘LiR‘
|
5月前
|
搜索推荐 Docker 容器
生信分析代码之前还好好的,怎么就报错了 Error in Ops. data. frame(guide_loc, panel_loc) :'==' only defined for equally-sized data frames
执行 `DimPlot` 函数时遇到错误 `;Error in Ops. data. frame(g guides_loc, panel_loc) : &#39;==&#39; only defined for equally-sized data frames`。解决方案和办法
1408 0
生信分析代码之前还好好的,怎么就报错了 Error in Ops. data. frame(guide_loc, panel_loc) :'==' only defined for equally-sized data frames
|
8月前
|
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..
229 0
|
8月前
random.sample(population, k)
random.sample(population, k)
46 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解决方法
759 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]
261 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
557 0
ValueError: With n_samples=0, test_size=0.15 and train_size=None, the resulting train set will be em
成功解决lightgbm.basic.LightGBMError: Parameter max_depth should be of type int, got “0.02“
成功解决lightgbm.basic.LightGBMError: Parameter max_depth should be of type int, got “0.02“