首页 > 其他分享 >GEE|Google Earth Engine报错Error in map(ID=LC08_123038_20190121) Element.copyProperties The source par

GEE|Google Earth Engine报错Error in map(ID=LC08_123038_20190121) Element.copyProperties The source par

时间:2022-11-25 11:13:08浏览次数:43  
标签:Engine map system source copyProperties 报错 GEE parameter

本文以LANDSAT/LC08/C01/T1_SR数据集为例介绍The source parameter is require应该如何解决。

image-20221125104510835

问题描述

GEE平台提供了影像在线处理,在完成对数据集处理后,想要对数据进行筛选展示或下载至本地时出现报错 Element.copyProperties: The source parameter is required.这是由于缺少源数据的系统属性,在老版的GEE中只需要copy源数据的‘system’属性,但是在最新的gee中,仅仅是copy源数据的‘system’并不能解决问题。

例:在老版的GEE中只需要使用copyProperties方法,copyProperties(img,['system:footprint','system:time_start'])即可,但是最近不知道是什么原因,copy完系统属性并没有很好的解决问题,虽然影像被筛选出来,但是在展示和下载的时候仍会报错。

有问题的代码

// set study area
var roi = ee.FeatureCollection("users/Zhangzijing/JH");
// reomove cloud for Landsat-8
function rmL8Cloud(image) { 
  var cloudShadowBitMask = (1 << 3); 
  var cloudsBitMask = (1 << 5); 
  var qa = image.select('pixel_qa'); 
  var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0) 
                 .and(qa.bitwiseAnd(cloudsBitMask).eq(0));
  return image.updateMask(mask).toFloat().divide(10000)
              .copyProperties(image)
              .copyProperties(image, ['system:time_start','system:time_end','system:footprint']);
}
// set time parameter
var year_start = 2019;
var year_end = 2020;
var imgCol = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR")
              .filterBounds(roi)
              .filter(ee.Filter.calendarRange(year_start, year_end,'year'))
              .map(rmL8Cloud);
print(imgCol); 
// compute the image total size
var imgSize = imgCol.size();
print("imgSize",imgSize); // result is 805
//compute the image avaibility
var imgCount = imgCol.select("B2").count().clip(roi);
print(imgCount); 
// define image render parameters
var visParam = {
 min: 10,
 max: 40,
 palette: 'FFFFFF, CE7E45, DF923D, F1B555, FCD163, 99B718, 74A901, 66A000, 529400,' +
   '3E8601, 207401, 056201, 004C00, 023B01, 012E01, 011D01, 011301'
};
Map.addLayer(imgCount,visParam,"imgCount",false);

// 定义空间筛选:利用边界进行叠加筛选.
var spatialFilter = ee.Filter.intersects({
leftField: '.geo',
rightField: '.geo',
maxError: 10
});
// 定义SaveAll-Join.
var saveAllJoin = ee.Join.saveAll({
matchesKey: 'scenes',
});
//运用SaveAll-Join.
var intersectJoined = saveAllJoin.apply(roi, PathRow, spatialFilter);
// 显示结果.
var intersected = ee.FeatureCollection(ee.List(intersectJoined.first().get('scenes')));
var styling = {color:'red',fillColor:'00000000'}
var styling1 = {color:'black',fillColor:'00000000'}
Map.centerObject(roi);
Map.addLayer(intersected.style(styling1), {}, 'WRS-2 polygons',false);
Map.addLayer(roi.style(styling),{}, 'guangdong',false);
Export.image.toDrive({
  image:imgCount,
  description:'avaibility_Landsat',
  folder:'avaibility_Landsat',
  region:roi,
  scale:30,
  crs:'EPSG:4326',
  maxPixels:1e13
});
Export.table.toDrive({
  collection:intersected,
  description:'PathRow',
  folder:'avaibility_Landsat'
})

报错情况

image-20221125105701995

解决方案

我们在处理数据的时候,将源数据源数据的所有属性赋给结果,最后根据情况再进行选择即可,好处(保留了源数据所有属性)

修改部分

这里是修改后的代码,主要针对去云函数:

function rmL8Cloud(image) { 
  var cloudShadowBitMask = (1 << 3); 
  var cloudsBitMask = (1 << 5); 
  var qa = image.select('pixel_qa'); 
  var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0) 
                 .and(qa.bitwiseAnd(cloudsBitMask).eq(0));
  return image.updateMask(mask).toFloat().divide(10000)
              .copyProperties(image)
              .set(image.toDictionary(image.propertyNames()));
}

运行结果

image-20221125105345743

标签:Engine,map,system,source,copyProperties,报错,GEE,parameter
From: https://www.cnblogs.com/tangjielin/p/16924487.html

相关文章