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.xdnf.cn/news/149693.html

如若内容造成侵权/违法违规/事实不符,请联系一条长河网进行投诉反馈,一经查实,立即删除!

相关文章

SpringCloud-消息组件

1 简介 了解过RabbitMQ后,可能我们会遇到不同的系统在用不同的队列。比如系统A用的Kafka,系统B用的RabbitMQ,但是没了解过Kafka,因此可以使用Spring Stream,它能够屏蔽地产,像JDBC一样,只关心SQ…

阿里云ECS和轻量服务器有什么区别?

阿里云服务器ECS和轻量应用服务器有什么区别?轻量和ECS优缺点对比,云服务器ECS是明星级云产品,适合企业专业级的使用场景,轻量应用服务器是在ECS的基础上推出的轻量级云服务器,适合个人开发者单机应用访问量不高的网站…

API基础————包

什么是包,package实际上就是一个文件夹,便于程序员更好的管理维护自己的代码。它可以使得一个项目结构更加清晰明了。 Java也有20年历史了,这么多年有这么多程序员写了无数行代码,其中有大量重复的,为了更加便捷省时地…

如何使用 LeiaPix 让照片动起来

在过去,想要让照片动起来,需要使用专业的软件和技巧。但是,随着科技的发展,现在只需使用一个简单的工具,就可以轻松地让照片动起来。 LeiaPix 是一个免费的在线工具,可以将静态照片转换为动画。该工具使用…

十天学完基础数据结构-第九天(堆(Heap))

堆的基本概念 堆是一种特殊的树形数据结构,通常用于实现优先级队列。堆具有以下两个主要特点: 父节点的值始终大于或等于其子节点的值(最大堆),或者父节点的值始终小于或等于其子节点的值(最小堆&#xff…

qml保姆级教程五:视图组件

💂 个人主页:pp不会算法v 🤟 版权: 本文由【pp不会算法v】原创、在CSDN首发、需要转载请联系博主 💬 如果文章对你有帮助、欢迎关注、点赞、收藏(一键三连)和订阅专栏哦 QML系列教程 QML教程一:布局组件 文章目录 列表视图ListVi…

2023/10/4 QT实现TCP服务器客户端搭建

服务器端&#xff1a; 头文件 #ifndef WIDGET_H #define WIDGET_H#include <QWidget> #include <QTcpServer> #include <QTcpSocket> #include <QList> #include <QMessageBox> #include <QDebug>QT_BEGIN_NAMESPACE namespace Ui { cla…

《计算机视觉中的多视图几何》笔记(13)

13 Scene planes and homographies 本章主要讲述两个摄像机和一个世界平面之间的射影几何关系。 我们假设空间有一平面 π \pi π&#xff0c;平面上的一点为 x π x_{\pi} xπ​。 x π x_{\pi} xπ​分别在两幅图像 P , P ′ P, P P,P′上形成了 x , x ′ x, x x,x′。 那…

Pikachu靶场——PHP反序列化漏洞

文章目录 1. PHP反序列化1.1 反序列化代码审计1.2 漏洞防御 1. PHP反序列化 可参考我写的另一篇博客&#xff1a;反序列化漏洞及漏洞复现。 序列化serialize() 序列化说通俗点就是把一个对象变成可以传输的字符串&#xff0c;比如下面是一个对象&#xff1a; class S{publi…

《向量数据库指南》——用Milvus cloud搭建聊天机器人

作为向量数据库的佼佼者&#xff0c;Milvus 适用于各种需要借助高效和可扩展向量搜索功能的 AI 应用。 举个例子&#xff0c;如果想要搭建一个聊天机器人&#xff0c;Milvus 一定是其进行数据管理的首选。那么&#xff0c;如何让这个应用程序开发变得易于管理及更好理解&#x…

使用python-opencv检测图片中的人像

最简单的方法进行图片中的人像检测 使用python-opencv配合yolov3模型进行图片中的人像检测 1、安装python-opencv、numpy pip install opencv-python pip install numpy 2、下载yolo模型文件和配置文件&#xff1a; 下载地址&#xff1a; https://download.csdn.net/down…

计算机网络——计算机网络的性能指标(上)-速率、带宽、吞吐量、时延

目录 速率 比特 速率 例1 带宽 带宽在模拟信号系统中的意义 带宽在计算机网络中的意义 吞吐量 时延 发送时延 传播时延 处理时延 例2 例3 速率 了解速率之前&#xff0c;先详细了解一下比特&#xff1a; 比特 计算机中数据量的单位&#xff0c;也是信息论中信…

创建django文件

1、在指定目录里打开终端&#xff0c;输入D:\Softwares\Anaconda3\envs\pytorch\Scripts\django-admin .exe startproject 名称 &#xff0c;即可在对应目录里创建django文件。

【C语言】动态通讯录(超详细)

通讯录是一个可以很好锻炼我们对结构体的使用&#xff0c;加深对结构体的理解&#xff0c;在为以后学习数据结构打下结实的基础 这里我们想设计一个有添加联系人&#xff0c;删除联系人&#xff0c;查找联系人&#xff0c;修改联系人&#xff0c;展示联系人&#xff0c;排序这几…

力扣第226翻转二叉数 c++三种方法 +注释

题目 226. 翻转二叉树 简单 给你一棵二叉树的根节点 root &#xff0c;翻转这棵二叉树&#xff0c;并返回其根节点。 示例 1&#xff1a; 输入&#xff1a;root [4,2,7,1,3,6,9] 输出&#xff1a;[4,7,2,9,6,3,1]示例 2&#xff1a; 输入&#xff1a;root [2,1,3] 输出&am…

Linux shell编程学习笔记8:使用字符串

一、前言 字符串是大多数编程语言中最常用最有用的数据类型&#xff0c;这在Linux shell编程中也不例外。 本文讨论了Linux Shell编程中的字符串的三种定义方式的差别&#xff0c;以及字符串拼接、取字符串长度、提取字符串、查找子字符串等常用字符串操作,&#xff0c;以及反…

【Java】微服务——Ribbon负载均衡(跟进源码分析原理)

添加LoadBalanced注解&#xff0c;即可实现负载均衡功能&#xff0c;这是什么原理 1.负载均衡原理 SpringCloud底层其实是利用了一个名为Ribbon的组件&#xff0c;来实现负载均衡功能的。 2.源码跟踪 为什么我们只输入了service名称就可以访问了呢&#xff1f;之前还要获取…

论文阅读——Pyramid Grafting Network for One-Stage High Resolution Saliency Detection

目录 基本信息标题目前存在的问题改进网络结构CMGM模块解答为什么要用这两个编码器进行编码 另一个写的好的参考 基本信息 期刊CVPR年份2022论文地址https://arxiv.org/pdf/2204.05041.pdf代码地址https://github.com/iCVTEAM/PGNet 标题 金字塔嫁接网络的一级高分辨率显著性…

java做个qq机器人

前置的条件 机器人是基于mirai框架实现的。根据官方的文档&#xff0c;建议使用openjdk11。 我这里使用的编辑工具是idea2023 在idea中新建一个maven项目&#xff0c;虽然可以使用gradle进行构建&#xff0c;不过我这里由于网络问题没有跑通。 pom.xml <dependency>&l…

克服网络安全压力:如何掌控无限的云数据

管理云中的数字风险比以往任何时候都更加重要。数字化转型引发的云数据呈指数级增长&#xff0c;为安全分析师创造了一个更大的威胁环境。随着威胁行为者继续危害组织最敏感的数据&#xff0c;这一挑战将会加剧。 预计未来五年全球网络犯罪成本将激增&#xff0c;从 2022 年的…