GEE土地分类——Property ‘B1‘ of feature ‘LE07_066018_20220603‘ is missing.错误

简介:

我正在尝试使用我在研究区域中选择的训练点对图像集合中的每个图像进行分类。就背景而言,我正在进行的项目正在研究陆地卫星生命周期内冰川面积的变化以及随后的植被变化。这意味着自 1984 年以来,我正在处理大量图像,每年一到两张。因此,我真的很希望拥有可以映射集合的函数,而不必手动执行此操作。 
当我将分类器映射到 imageCollection 或采样图像后创建的 featureCollection 时,我在这篇文章的主题行中收到错误。 
这是一个简化的代码来向您展示我的问题: 
https://code.earthengine.google.com/0a7f4a322e18e8cb666acfef63b00d14

错误:

model

FeatureCollection (Error)

Property 'B1' of feature 'LE07_066018_20220603' is missing.

classifiedImages

ImageCollection (Error)

Property 'B1' of feature 'LE07_066018_20220603' is missing.

原始代码:

var wtrshd = ee.FeatureCollection("users/masonbull/nj_wtrshd_ocean"),classes = ee.FeatureCollection("projects/ee-masonbull/assets/allClasses");//identify my classes for classification
var classes = ee.FeatureCollection('projects/ee-masonbull/assets/allClasses');
var wtrshd = ee.FeatureCollection('users/masonbull/nj_wtrshd_ocean');
//set start and end date to get imagery
var date_i = '1999-03-01'; // set initial date (YYYY-MM-DD)
var date_f = '2023-06-30'; // Set final date (YYY-MM-DD)//grab landsat 7 data
var l7 = ee.ImageCollection("LANDSAT/LE07/C02/T1_RT").filterDate(date_i, date_f).filter(ee.Filter.calendarRange(5, 10, 'month')).filterBounds(ee.Geometry.Point(-148.8904089876178,60.362297433254604)).select('B1', 'B2', 'B3', 'B4', 'B5', 'B7', 'B8').filter(ee.Filter.lte('CLOUD_COVER_LAND', 25));//create a function to clip all of the imagery to the watershed boundaries
var clipping = function(image) {return image.clip(wtrshd);
};var l7_clip = l7.map(clipping);
print(l7_clip);//define bands and a label for the sampling
var l7Bands = ['B1', 'B2', 'B3', 'B4', 'B5', 'B7', 'B8'];var label = 'Class';//create a funciton to sample each image in the imageCollection
var sampleCollectionFunc = function(image){var sampler =  image.sampleRegions({'collection': classes,'properties': [label],'scale': 30,'geometries': true
});
return sampler;
};var sampleCollection = l7_clip.map(sampleCollectionFunc);
print('sampleCollection', sampleCollection);//add random column to sampled images (now featureCollections)
var addRandomFunc = function(FeatureCollection){var random = ee.FeatureCollection(FeatureCollection).randomColumn({'seed': 0, 'distribution': 'uniform'});return ee.FeatureCollection(random).set('band_order', ['B1', 'B2', 'B3', 'B4', 'B5', 'B7', 'B8', 'NDSI', 'elevation']);
};var randomCollection = sampleCollection.map(addRandomFunc);//create training data from random column
var createTraining = function(in_FeatureCollection){var filter = ee.FeatureCollection(in_FeatureCollection).filter(ee.Filter.lt('random', 0.8));return filter;
};
var training = randomCollection.map(createTraining);//train the classifier, in this case an SVM
var classifierSVM = ee.Classifier.libsvm({'decisionProcedure': 'Voting','svmType': 'C_SVC', 'kernelType': 'RBF', 'shrinking': true,'gamma': 0.00125,'cost': null}).train({'features': training,'classProperty': label,'inputProperties': l7Bands,'subsamplingSeed':0});//create a function to map over the feature and imageCollections to classify them 
var classSamp = function(FeatureCollection){return ee.FeatureCollection(FeatureCollection).classify(classifierSVM, 'predicted');
};
var model = ee.FeatureCollection(sampleCollection).map(classSamp);
print('model', model);var imageClassifier = function(image){return image.classify(classifierSVM, 'predicted');
};
var classVisParams = {min: 0, max: 5, 'palette': ['062EF5', 'E8EAF5', 'E5330C', '0E5B07', '938507', '00EF12']};var classifiedImages = l7_clip.map(imageClassifier);
print('classifiedImages', classifiedImages);

解决方案:

这里主要的问题在于我们给svm分类器的训练数据传参的时候出现了一个问题,也就是,训练数据需要的是一个矢量集合,而这里我们可以看到经过下面代码处理后的并不是一个矢量集合,而是集合中嵌套的集合

var training = randomCollection.map(createTraining)

这里我们使用flatten()函数来减少一个嵌套就可以分析了

函数:

train(features, classProperty, inputPropertiessubsamplingsubsamplingSeed)

Trains the classifier on a collection of features, using the specified numeric properties of each feature as training data. The geometry of the features is ignored.

Arguments:

this:classifier (Classifier):

An input classifier.

features (FeatureCollection):

The collection to train on.

classProperty (String):

The name of the property containing the class value. Each feature must have this property, and its value must be numeric.

inputProperties (List, default: null):

The list of property names to include as training data. Each feature must have all these properties, and their values must be numeric. This argument is optional if the input collection contains a 'band_order' property, (as produced by Image.sample).

subsampling (Float, default: 1):

An optional subsampling factor, within (0, 1].

subsamplingSeed (Integer, default: 0):

A randomization seed to use for subsampling.

Returns: Classifier

flatten()

Flattens collections of collections.

Arguments:

this:collection (FeatureCollection):

The input collection of collections.

Returns: FeatureCollection

修改后的代码:

var wtrshd = ee.FeatureCollection("users/masonbull/nj_wtrshd_ocean"),classes = ee.FeatureCollection("projects/ee-masonbull/assets/allClasses");
//identify my classes for classification
var classes = ee.FeatureCollection('projects/ee-masonbull/assets/allClasses');
var wtrshd = ee.FeatureCollection('users/masonbull/nj_wtrshd_ocean');
//set start and end date to get imagery
var date_i = '1999-03-01'; // set initial date (YYYY-MM-DD)
var date_f = '2023-06-30'; // Set final date (YYY-MM-DD)//grab landsat 7 data
var l7 = ee.ImageCollection("LANDSAT/LE07/C02/T1_RT").filterDate(date_i, date_f).filter(ee.Filter.calendarRange(5, 10, 'month')).filterBounds(ee.Geometry.Point(-148.8904089876178,60.362297433254604)).select('B1', 'B2', 'B3', 'B4', 'B5', 'B7', 'B8').filter(ee.Filter.lte('CLOUD_COVER_LAND', 25));//create a function to clip all of the imagery to the watershed boundaries
var clipping = function(image) {return image.clip(wtrshd);
};var l7_clip = l7.map(clipping);
print(l7_clip);//define bands and a label for the sampling
var l7Bands = ['B1', 'B2', 'B3', 'B4', 'B5', 'B7', 'B8'];var label = 'Class';//create a funciton to sample each image in the imageCollection
var sampleCollectionFunc = function(image){var sampler =  image.sampleRegions({'collection': classes,'properties': [label],'scale': 30,'geometries': true
});
return sampler;
};var sampleCollection = l7_clip.map(sampleCollectionFunc);
print('sampleCollection', sampleCollection);//add random column to sampled images (now featureCollections)
var addRandomFunc = function(FeatureCollection){var random = ee.FeatureCollection(FeatureCollection).randomColumn({'seed': 0, 'distribution': 'uniform'});return ee.FeatureCollection(random).set('band_order', ['B1', 'B2', 'B3', 'B4', 'B5', 'B7', 'B8', 'NDSI', 'elevation']);
};var randomCollection = sampleCollection.map(addRandomFunc);//create training data from random column
var createTraining = function(in_FeatureCollection){var filter = ee.FeatureCollection(in_FeatureCollection).filter(ee.Filter.lt('random', 0.8));return filter;
};
var training = randomCollection.map(createTraining).flatten();//train the classifier, in this case an SVM
var classifierSVM = ee.Classifier.libsvm({'decisionProcedure': 'Voting','svmType': 'C_SVC', 'kernelType': 'RBF', 'shrinking': true,'gamma': 0.00125,'cost': null}).train({'features': training,'classProperty': label,'inputProperties': l7Bands,'subsamplingSeed':0});//create a function to map over the feature and imageCollections to classify them 
var classSamp = function(FeatureCollection){return ee.FeatureCollection(FeatureCollection).classify(classifierSVM, 'predicted');
};
var model = ee.FeatureCollection(sampleCollection).map(classSamp);
print('model', model.first());var imageClassifier = function(image){return image.classify(classifierSVM, 'predicted');
};
var classVisParams = {min: 0, max: 5, 'palette': ['062EF5', 'E8EAF5', 'E5330C', '0E5B07', '938507', '00EF12']};var classifiedImages = l7_clip.map(imageClassifier);
print('classifiedImages', classifiedImages.first());

额外问题

除了上面的问题外,还会出现超限的问题:

model

FeatureCollection (Error)

User memory limit exceeded.

classifiedImages

ImageCollection (Error)

User memory limit exceeded.

 出现上面问题的时候我们就不要在云端通过打印的方式来进行了,直接可以通过导出数据的方式来实现影像分类后的结果。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/149233.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

卷积神经网络-池化层和激活层

2.池化层 根据特征图上的局部统计信息进行下采样,在保留有用信息的同时减少特征图的大小。和卷积层不同的是,池化层不包含需要学习的参数。最大池化(max-pooling)在一个局部区域选最大值作为输出,而平均池化(average pooling)计算一个局部区…

Elasticsearch数据操作原理

Elasticsearch 是一个开源的、基于 Lucene 的分布式搜索和分析引擎,设计用于云计算环境中,能够实现实时的、可扩展的搜索、分析和探索全文和结构化数据。它具有高度的可扩展性,可以在短时间内搜索和分析大量数据。 Elasticsearch 不仅仅是一个…

Apollo Planning2.0决策规划算法代码详细解析 (2): vscode gdb单步调试环境搭建

前言: apollo planning2.0 在新版本中在降低学习和二次开发成本上进行了一些重要的优化,重要的优化有接口优化、task插件化、配置参数改造等。 GNU symbolic debugger,简称「GDB 调试器」,是 Linux 平台下最常用的一款程序调试器。GDB 编译器通常以 gdb 命令的形式在终端…

抄写Linux源码(Day14:从 MBR 到 C main 函数 (3:研究 head.s) )

回忆我们需要做的事情: 为了支持 shell 程序的执行,我们需要提供: 1.缺页中断(不理解为什么要这个东西,只是闪客说需要,后边再说) 2.硬盘驱动、文件系统 (shell程序一开始是存放在磁盘里的,所以需要这两个东…

vertx的学习总结7之用kotlin 与vertx搞一个简单的http

这里我就简单的聊几句&#xff0c;如何用vertx web来搞一个web项目的 1、首先先引入几个依赖&#xff0c;这里我就用maven了&#xff0c;这个是kotlinvertx web <?xml version"1.0" encoding"UTF-8"?> <project xmlns"http://maven.apac…

【C++】一文带你走入vector

文章目录 一、vector的介绍二、vector的常用接口说明2.1 vector的使用2.2 vector iterator的使用2.3 vector空间增长问题2.4 vector 增删查改 三、总结 ヾ(๑╹◡╹)&#xff89;" 人总要为过去的懒惰而付出代价ヾ(๑╹◡╹)&#xff89;" 一、vector的介绍 vector…

[C国演义] 第十三章

第十三章 三数之和四数之和 三数之和 力扣链接 根据题目要求: 返回的数对应的下标各不相同三个数之和等于0不可包含重复的三元组 – – 即顺序是不做要求的 如: [-1 0 1] 和 [0, 1, -1] 是同一个三元组输出答案顺序不做要求 暴力解法: 排序 3个for循环 去重 — — N^3, …

企业微信机器人对接GPT

现在网上大部分微信机器人项目都是基于个人微信实现的&#xff0c;常见的类库都是模拟网页版微信接口。 个人微信作为我们自己日常使用的工具&#xff0c;也用于支付场景&#xff0c;很怕因为违规而被封。这时&#xff0c;可以使用我们的企业微信机器人&#xff0c;利用企业微信…

互联网Java工程师面试题·Elasticsearch 篇·第二弹

12、详细描述一下 Elasticsearch 索引文档的过程。 协调节点默认使用文档 ID 参与计算&#xff08;也支持通过 routing &#xff09;&#xff0c;以便为路由提供合适的分片。 shard hash(document_id) % (num_of_primary_shards) 1 、当分片所在的节点接收到来自协调节点…

Qt creator+cmake编译并安装

1、qt creator打开项目中的CMakeLists.txt 2、修改“构建设置“-“Cmake”-”Current Configuration“&#xff0c;其中&#xff0c;安装路径为CMAKE_INSTALL_PREFIX 3、修改“构建设置“-“构建的步骤”-”目标“&#xff0c;勾选"all"和"install" 4、构…

C语言qsort函数

排序qsort int int cmp(const void *a, const void *b) {return *(int *)a - *(int *)b;//先强转成int型&#xff0c;后解引用取值比较大小 }字符串数组 char a[] “hello world” //字符串数组&#xff0c;存放的是字符 int cmp(const void *a, const void *b) {return *(…

7.wifi开发【智能家居:终】,实践总结:智能开关,智能采集温湿,智能灯。项目运行步骤与运行细节,技术归纳与提炼,项目扩展

一。项目运行步骤与运行细节 1.项目运行步骤&#xff08;一定有其他的运行方式&#xff0c;我这里只提供一种我现在使用的编译方式&#xff09; &#xff08;1&#xff09;项目运行使用软件与技术&#xff1a; 1.Virtual linux 使用这个虚拟机进行程序的编译 2.Makefile与shl…

阿里云服务器镜像系统Anolis OS龙蜥详细介绍

阿里云服务器Anolis OS镜像系统由龙蜥OpenAnolis社区推出&#xff0c;Anolis OS是CentOS 8 100%兼容替代版本&#xff0c;Anolis OS是完全开源、中立、开放的Linux发行版&#xff0c;具备企业级的稳定性、高性能、安全性和可靠性。目前阿里云服务器ECS可选的Anolis OS镜像系统版…

【Java】猫和狗接口版本思路分析

目录 猫&#x1f431;和狗&#x1f415;&#xff08;接口版本&#xff09; 画图分析 案例代码 猫&#x1f431;和狗&#x1f415;&#xff08;接口版本&#xff09; 需求&#xff1a;对猫和狗进行训练&#xff0c;它们就可以跳高了&#xff0c;这里加入了跳高功能&#xff0…

Vue中实现自定义编辑邮件发送到指定邮箱(纯前端实现)

formspree里面注册账号 注册完成后进入后台新建项目并且新建表单 这一步完成之后你将得到一个地址 最后就是在项目中请求这个地址 关键代码如下&#xff1a; submitForm() {this.fullscreenLoading true;this.$axios({method: "post",url: "https://xxxxxxx…

MATLAB算法实战应用案例精讲-【优化算法】火烈鸟搜索优化算法(FSA)(附python代码实现)

前言 火烈鸟搜索算法(flamingo search algorithm,fsa)是一种模拟火烈鸟群体觅食行为的新型智能优化算法,可以用于路径规划领域。根据fsa的寻优过程可知,fsa存在以下不足:(1)初始化种群位置是随机的,不能保证种群质量;(2)在个体的迭代更新过程中缺少变异机制,导致种群多…

程序三高的方法

程序三高的方法 目录概述需求&#xff1a; 设计思路实现思路分析1.1&#xff09;高并发 参考资料和推荐阅读 Survive by day and develop by night. talk for import biz , show your perfect code,full busy&#xff0c;skip hardness,make a better result,wait for change,c…

Git使用【中】

欢迎来到Cefler的博客&#x1f601; &#x1f54c;博客主页&#xff1a;那个传说中的man的主页 &#x1f3e0;个人专栏&#xff1a;题目解析 &#x1f30e;推荐文章&#xff1a;题目大解析3 目录 &#x1f449;&#x1f3fb;分支管理分支概念git branch&#xff08;查看/删除分…

华为云云耀云服务器L实例评测|基于canal缓存自动更新流程 SpringBoot项目应用案例和源码

前言 最近华为云云耀云服务器L实例上新&#xff0c;也搞了一台来玩&#xff0c;期间遇到各种问题&#xff0c;在解决问题的过程中学到不少和运维相关的知识。 在之前的博客中&#xff0c;介绍过canal的安装和配置&#xff0c;参考博客 拉取创建canal镜像配置相关参数 & …