当前位置: 首页 > news >正文

GEE错误——image.reduceRegion is not a function

简介

image.reduceRegion is not a function

这里的主要问题是我们进行地统计分析的时候,我们的作用对象必须是单景影像,而不是影像集合

错误"image.reduceRegion is not a function" 表示你正在尝试使用reduceRegion()函数来处理图像数据,但是该函数在所使用的图像对象上并不存在。这通常发生在以下几种情况下:

  1. 你使用的图像对象并不是由Earth Engine提供的图像数据类型。只有Earth Engine提供的图像数据类型,如Image、ImageCollection等,才包含reduceRegion()函数。确保你使用的图像对象是Earth Engine提供的类型。

  2. 你使用的图像对象是一个空对象或没有加载任何数据。如果图像对象为空,那么该对象上是没有reduceRegion()函数的。请确保你加载了正确的图像数据,或者使用其他方法创建图像对象。

  3. 你使用了错误的函数名称。请检查你的代码,确保你使用的是reduceRegion()而不是其他名称类似的函数。

请根据具体情况查看你的代码,并根据上述解释进行适当的修改。

代码

var landsat = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2"),imageVisParam = {"opacity":1,"bands":["B7","B6","B4"],"min":11451.624047549685,"max":13348.162011801593,"gamma":1},blore = /* color: #0b4a8b *//* shown: false *//* displayProperties: [{"type": "rectangle"}] */ee.Geometry.Polygon([[[77.1829215561055, 13.595511689413932],[77.1829215561055, 12.530677550689433],[78.1167594467305, 12.530677550689433],[78.1167594467305, 13.595511689413932]]], null, false),pol_CO = ee.ImageCollection("COPERNICUS/S5P/OFFL/L3_CO"),pol_NO2 = ee.ImageCollection("COPERNICUS/S5P/OFFL/L3_NO2"),pol_CH4 = ee.ImageCollection("COPERNICUS/S5P/OFFL/L3_CH4"),pol_SO2 = ee.ImageCollection("COPERNICUS/S5P/OFFL/L3_SO2"),pol_O3 = ee.ImageCollection("COPERNICUS/S5P/OFFL/L3_O3");
var parks = ee.FeatureCollection('projects/ee-koushikyash/assets/Ban_parks_10ha');var i = 1;
var bufferDis = 50// create new buffer
var newBuffer = function(feature) {var geometry = feature.geometry();var buffer = geometry.buffer(bufferDis * i);// print(i)buffer = buffer.difference(geometry)var newFeature = ee.Feature(buffer, feature.toDictionary());return newFeature;
};// subtract geometry
var subtractGeometries = function(feature1, feature2) {var geometry1 = feature1.geometry();var geometry2 = feature2.geometry();return geometry1.difference(geometry2);
};var allBuffers = ee.List([])var parks_0 = parks;
Map.addLayer(parks_0, {}, 'Buffer around Bangalore Parks ' + (0));
allBuffers = allBuffers.add(parks_0)
var prev = parks_0
var colors = ["Red", "Green", "Orange", "Yellow", "Pink"]var total = 5;
for(var j = 0; j < total; j++){var parks_1 = parks.map(newBuffer)var temp = parks_1parks_1 = parks_1.map(function(f1) {var index = parks_1.toList(parks_1.size()).indexOf(f1)var f2 = ee.Feature(prev.toList(prev.size()).get(index))return ee.Feature(subtractGeometries(f1, f2), f1.toDictionary())});// changing stateprev = tempi += 1allBuffers = allBuffers.add(parks_1)Map.addLayer(parks_1,  {color: colors[j]}, 'Buffer around Bangalore Parks ' + (i));
}//Add pollutant images
var image_so2 = pol_SO2.filterBounds(parks).filterDate('2024-01-01', '2024-01-31').select('SO2_column_number_density').mean().clip(parks)var image_no2 = pol_NO2.filterBounds(parks).filterDate('2024-01-01', '2024-01-31').select('NO2_column_number_density').mean().clip(parks)var image_ch4 = pol_CH4.filterBounds(parks).filterDate('2024-01-01', '2024-01-31').select('CH4_column_volume_mixing_ratio_dry_air').mean().clip(parks)var image_o3 = pol_O3.filterBounds(parks).filterDate('2024-01-01', '2024-01-31').select('O3_column_number_density').mean().clip(parks)var image_co = pol_CO.filterBounds(parks).filterDate('2024-01-01', '2024-01-31').select('CO_column_number_density').mean().clip(parks) // Check the type of image
print("Type of image_so2:", typeof image_so2);// Check if image_so2 is an ee.Image object
print("Is image_so2 an ee.Image?", image_so2 instanceof ee.Image);// Check the type of park
print("Type of a park feature:", typeof parks.get(0));
print(parks.first());
// Check if a park feature is an ee.Feature object
print("Is a park feature an ee.Feature?", parks.first() instanceof ee.Feature);// Check if the geometry method is available on a park feature
print("Does park feature have a geometry method?", parks.get(0).geometry !== undefined);// var sampleFeature = parks.first();
// var geometry = sampleFeature.geometry();
// print("Geometry of sample feature:", geometry);// var featureCount = parks.size();
// print("Number of features in parks:", featureCount);// Function to calculate pollutant statistics for each park
var calculateStatistics = function(image, park) {var stats = image.reduceRegion({reducer: ee.Reducer.mean().combine({reducer2: ee.Reducer.minMax(),sharedInputs: true}),geometry: park.geometry(),scale: 30,maxPixels: 1e9});// Map over the stats to format them as featuresvar features = ee.Feature(null, stats).set('date', image.date().format('YYYY-MM-dd')).set('park_name', park.get('name')); // Assuming 'name' is the property containing park namesreturn features;
};// Function to get statistics for all pollutants and parks
var getResults = function(parks, images) {var results = ee.List(images).map(function(image) {var stats = parks.map(function(park) {return calculateStatistics(image, ee.Feature(park));});return stats;}).flatten();return results;
};// Function to format the results
var format = function(table) {var rows = table.distinct('date');var columns = parks.aggregate_array('name'); var formattedResults = rows.map(function(row) {var date = row.get('date');var parkStats = table.filter(ee.Filter.eq('date', date));var values = parkStats.aggregate_array('pollutant_min', 'pollutant_max', 'pollutant_mean');return ee.Feature(null, values).set('date', date);});return formattedResults;
};// Export to CSV function
var exportToCsv = function(table, desc, name) {Export.table.toDrive({collection: table,description: desc,fileNamePrefix: name,fileFormat: "CSV"});
};// Assuming you have defined the pollutant images (image_so2, image_no2, etc.) and parks beforehand// Get data for all pollutants and parksvar image_so2 = pol_SO2.filterBounds(parks).filterDate('2024-01-01', '2024-01-31').select('SO2_column_number_density').mean().clip(parks)var image_no2 = pol_NO2.filterBounds(parks).filterDate('2024-01-01', '2024-01-31').select('NO2_column_number_density').mean().clip(parks)var image_ch4 = pol_CH4.filterBounds(parks).filterDate('2024-01-01', '2024-01-31').select('CH4_column_volume_mixing_ratio_dry_air').mean().clip(parks)var image_o3 = pol_O3.filterBounds(parks).filterDate('2024-01-01', '2024-01-31').select('O3_column_number_density').mean().clip(parks)var image_co = pol_CO.filterBounds(parks).filterDate('2024-01-01', '2024-01-31').select('CO_column_number_density').mean().clip(parks) var images = [image_so2, image_no2, image_ch4, image_o3, image_co]; //checking the type of iamges array
print(images);var results = getResults(parks, images);// Format the results
var formattedResults = format(results);// Export the formatted results to CSV
exportToCsv(formattedResults, "PollutantStatistics", "pollutant_stats");

正确解析

 这里的正确思路是我们需要进行分析,也就是说我们的作用对象是影像,而非影像集合,所以这里我们不能混淆这里两个概念,首先看一下两个函数的差异:

ee.Image(args)

An object to represent an Earth Engine image. This constructor accepts a variety of arguments:

  • A string: an EarthEngine asset id,

  • A string and a number: an EarthEngine asset id and version,

  • A number or ee.Array: creates a constant image,

  • A list: creates an image out of each list element and combines them into a single image,

  • An ee.Image: returns the argument,

  • Nothing: results in an empty transparent image.

Arguments:

args (Image|List<Object>|Number|Object|String, optional):

Constructor argument.

Returns: Image

ee.ImageCollection(args)

ImageCollections can be constructed from the following arguments:

  • A string: assumed to be the name of a collection,

  • A list of images, or anything that can be used to construct an image.

  • A single image.

  • A computed object - reinterpreted as a collection.

Arguments:

args (ComputedObject|Image|List<Object>|String):

The constructor arguments.

Returns: ImageCollection

这是两个之间的差异,然后再看reduce region的函数

reduceRegion(reducer, geometryscalecrscrsTransformbestEffortmaxPixelstileScale)

Apply a reducer to all the pixels in a specific region.

Either the reducer must have the same number of inputs as the input image has bands, or it must have a single input and will be repeated for each band.

Returns a dictionary of the reducer's outputs.

Arguments:

this:image (Image):

The image to reduce.

reducer (Reducer):

The reducer to apply.

geometry (Geometry, default: null):

The region over which to reduce data. Defaults to the footprint of the image's first band.

scale (Float, default: null):

A nominal scale in meters of the projection to work in.

crs (Projection, default: null):

The projection to work in. If unspecified, the projection of the image's first band is used. If specified in addition to scale, rescaled to the specified scale.

crsTransform (List, default: null):

The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with 'scale', and replaces any transform already set on the projection.

bestEffort (Boolean, default: false):

If the polygon would contain too many pixels at the given scale, compute and use a larger scale which would allow the operation to succeed.

maxPixels (Long, default: 10000000):

The maximum number of pixels to reduce.

tileScale (Float, default: 1):

A scaling factor between 0.1 and 16 used to adjust aggregation tile size; setting a larger tileScale (e.g. 2 or 4) uses smaller tiles and may enable computations that run out of memory with the default.

Returns: Dictionary

具体分析

这里其实最主要的问题是我们作用的对象是image,但是这里我们要写入function的时候,我们写入的方式不对,所以这里出现了错误,这里的问题就在于我们需要重新解析我们的函数,函数需要重新分开来操作,整体的思路是我们要map,也就是对每一个操作的影像进行分析,然后添加属性什么的问题就可以进行了。

相关文章:

GEE错误——image.reduceRegion is not a function

简介 image.reduceRegion is not a function 这里的主要问题是我们进行地统计分析的时候&#xff0c;我们的作用对象必须是单景影像&#xff0c;而不是影像集合 错误"image.reduceRegion is not a function" 表示你正在尝试使用reduceRegion()函数来处理图像数据&…...

rk356x 关于yocto编译linux及bitbake实用方法

Yocto 完整编译 source oe-init-build-envbitbake core-image-minimalYocto 查询包名 bitbake -s | grep XXX // 获取rockchip相关包 :~/rk3568/yocto$ bitbake -s | grep rockchip android-tools-conf-rockchip :1.0-r0 gstreamer1.0-rockchip …...

Chrome您的连接不是私密连接 |输入“thisisunsafe”命令绕过警告or添加启动参数

一、输入 thisisunsafe 在当前页面用键盘输入 thisisunsafe &#xff0c;不是在地址栏输入(切记)&#xff0c;就直接敲键盘就行了 因为Chrome不信任这些自签名ssl证书&#xff0c;为了安全起见&#xff0c;直接禁止访问了&#xff0c;thisisunsafe 这个命令&#xff0c;说明你…...

牛客面试前端1

HTML语义化 是什么 前端语义化是指在构建网页时多使用html语义化标签布局&#xff0c;多使用带有语义的标签如header&#xff0c;aside&#xff0c;footer等标签为什么 结构清晰利于开发者开发与维护 有利于seo搜索引擎优化 有利于在网络卡顿时&#xff0c;正常显示页面结构&a…...

Linux的软件包管理器-yum

文章目录 软件包的概念yum源的配置的原因yum的使用查看软件包安装软件卸载软件 软件包的概念 软件包(SoftWare Package)是指具有特定的功能&#xff0c;用来完成特定任务的一个程序或一组程序。可分为应用软件包和系统软件包两大类 在Linux系统中&#xff0c;下载安装软件的方式…...

选择排序(Selection Sort)

选择排序(Selection Sort)是一种简单直观的排序算法。它的工作原理如下: 遍历数组:从待排序的数列中,找到当前未排序部分(即整个数组或已排序部分之后的部分)中的最小(或最大,取决于排序方式)元素。 交换位置:将找到的最小元素与未排序部分的第一个元素交换位置,这…...

网络面试题目

1、BGP报文有哪些? 有5种报文,Open、 Update、 Notification、 Keepalive和 Route-refresh等5种报文类型。 2、Vxlan了解多少? VLAN作为传统的网络隔离技术,VXLAN完美地弥补了VLAN的上述不足。 VXLAN(Virtual eXtensible Local Area Network,虚拟扩展局域网),(VXL…...

Web,Sip,Rtsp,Rtmp,WebRtc,专业MCU融屏视频混流会议直播方案分析

随着万物互联&#xff0c;视频会议直播互动深入业务各方面&#xff0c;主流SFU并不适合管理&#xff0c;很多业务需要各种监控终端&#xff0c;互动SIP硬件设备&#xff0c;Web在线业务平台能相互融合&#xff0c;互联互通&#xff0c; 视频混流直播&#xff0c;录存直播推广&a…...

Unreal 编辑器工具 批量重命名资源

右键 - Editor Utilities - Editor Utility Blueprint&#xff0c;基类选择 Asset Action Utility 在类默认值内&#xff0c;可以添加筛选器&#xff0c;筛选指定的类型 然后新建一个函数&#xff0c;加上4个输入&#xff1a;ReplaceFrom&#xff0c;ReplaceTo&#xff0c;Add…...

Voice Conversion、DreamScene、X-SLAM、Panoptic-SLAM、DiffMap、TinySeg

本文首发于公众号&#xff1a;机器感知 Voice Conversion、DreamScene、X-SLAM、Panoptic-SLAM、DiffMap、TinySeg Converting Anyones Voice: End-to-End Expressive Voice Conversion with a Conditional Diffusion Model Expressive voice conversion (VC) conducts speak…...

短信群发平台分析短信群发的未来发展趋势

短信群发平台在当前的移动互联网时代已经展现出了其独特的价值和广泛的应用场景。随着技术的不断进步和市场的不断变化&#xff0c;短信群发的未来发展趋势也将呈现出一些新的特点。 首先&#xff0c;随着5G网络的推广和普及&#xff0c;短信群发的速度和稳定性将得到进一步提…...

supervisord 使用指南

supervisord 使用指南 supervisord的安装 supervisor是一系列python脚本文件&#xff0c;以python package的形式管理&#xff0c;可以用于UNIX类系统的进程管理。 安装supervisor也相当简单&#xff0c;只需要用pip安装即可。 sudo pip install supervisor但是有可能将其安…...

AngularJS 的生命周期和基础语法

AngularJS 的生命周期和基础语法 文章目录 AngularJS 的生命周期和基础语法1. 使用步骤2. 生命周期钩子函数3. 点击事件4. if 语句1. if 形式2. if else 形式 5. for 语句6. switch 语句7. 双向数据绑定 1. 使用步骤 // 1. 要使用哪个钩子函数&#xff0c;就先引入 import { O…...

docker-compose 网络

自定义网络 - HOST 与宿主机共享网络 version: "3" services:web:image: nginx:1.21.6restart: alwaysports:- 80:80network_mode: host自定义网络 - 固定ip version: "3" services:web:image: nginx:1.21.6restart: alwaysports:- 80:80networks:app&am…...

农药生产厂污废水如何处理达标

农药生产厂的污废水处理是确保该行业对环境的负面影响最小化的重要环节。下面是一些常见的处理方法和步骤&#xff0c;可以帮助农药生产厂的污废水达到排放标准&#xff1a; 预处理&#xff1a;将废水进行初步处理&#xff0c;去除大颗粒悬浮物和固体残渣。这可以通过筛网、沉淀…...

根据相同的key 取出数组中最后一个值

数组中有很多对象 , 需根据当前页面的值current 和 数组中的key对比 拿到返回值 数据结构如下 之前写法 const clickedItem routeList.find(item > item.key current) // current是当前页 用reduce遍历数组返回最后一个值 const clickedItem routeList.reduce((lastIte…...

Github Action Bot 开发教程

Github Action Bot 开发教程 在使用 Github 时&#xff0c;你可能在一些著名的开源项目&#xff0c;例如 Kubernetes&#xff0c;Istio 中看到如下的一些评论&#xff1a; /lgtm /retest /area bug /assign xxxx ...等等&#xff0c;诸如此类的一些功能性评论。在这些评论出现…...

使用docker创建rocketMQ主从结构,使用

1、 创建目录 mkdir -p /docker/rocketmq/logs/nameserver-a mkdir -p /docker/rocketmq/logs/nameserver-b mkdir -p /docker/rocketmq/logs/broker-a mkdir -p /docker/rocketmq/logs/broker-b mkdir -p /docker/rocketmq/store/broker-a mkdir -p /docker/rocketmq/store/b…...

一次完整的 http 请求是怎样的?

一次完整的 http 请求是怎样的&#xff1f; &#x1f496;The Begin&#x1f496;点点关注&#xff0c;收藏不迷路&#x1f496; 域名解析 --> 发起 TCP 的 3 次握手 --> 建立 TCP 连接后发起 http 请求 --> 服务器响应 http 请求&#xff0c;浏览器得到 html 代码 --…...

并行执行的概念—— 《OceanBase 并行执行》系列 一

From 产品经理&#xff1a; 这是一份姗姗来迟的关于OceanBase并行执行的系统化产品文档。 自2019年起&#xff0c;并行执行功能已被许多客户应用于多种场景之中&#xff0c;其重要性日益凸显。然而&#xff0c;遗憾的是&#xff0c;我们始终未能提供一份详尽的用户使用文档&…...

使用 ipdb 调试回调函数

一、问题概述 回调函数是指一个函数执行完后&#xff0c;调用另外一个函数的过程。 一般步骤是&#xff0c;回调函数作为参数传递给原始函数&#xff0c;原始函数执行完自己的逻辑后&#xff0c;自动调用回调函数并将自己的执行结果作为参数传递给回调函数。 根据不同的用法&a…...

介绍一下mybatis的基本配置(mybatis-config.xml)

src/main/resources/mybatis-config.xml 这句代码&#xff0c;是XML的声明&#xff0c;它指定了&#xff0c;XML的版本 和 编码方式 <?xml version"1.0" encoding"UTF-8" ?>这句代码&#xff0c;声明了XML文档类型&#xff0c;它告诉解析器&#x…...

【MySQL】第一次作业

【MySQL】第一次作业 1、在官网下载安装包2、解压安装包&#xff0c;创建一个dev_soft文件夹&#xff0c;解压到里面。3、创建一个数据库db_classes4、创建一行表db_hero5、将四大名著中的常见人物插入这个英雄表 写一篇博客&#xff0c;在window系统安装MySQL将本机的MySQL一定…...

10个免费视频素材网站,剪辑师们赶紧收藏!

剪辑师们不知道去哪里找免费视频素材&#xff0c;就上这10个网站&#xff0c;免费下载部分还可商用&#xff0c;赶紧收藏起来&#xff01; 1、菜鸟图库 https://www.sucai999.com/video.html?vNTYwNDUx 菜鸟图库虽然是个设计素材网站&#xff0c;但除了设计类素材之外还有很多…...

【毕业设计】基于SSM的运动用品商城的设计与实现

1.项目介绍 在这个日益数字化和信息化的时代&#xff0c;随着人们购物习惯的转变&#xff0c;传统的实体商店已经无法满足人们日益增长的在线购物需求。因此&#xff0c;基于SSM&#xff08;Spring Spring MVC MyBatis&#xff09;框架的运动用品商城项目应运而生&#xff0…...

【Web】CTFSHOW 中期测评刷题记录(1)

目录 web486 web487 web488 web489 web490 web491 web492 web493 web494 web495 web496 web497 web498 web499 web500 web501 web502 web503 web505 web506 web507 web508 web509 web510 web486 扫目录 初始界面尝试文件包含index.php&am…...

vs配置cplex12.10

1.创建c空项目 2.修改运行环境 为release以及x64 3.创建cpp文件 4.鼠标右键点击项目中的属性 5.点击c/c&#xff0c;点击第一项常规&#xff0c;配置附加库目录 5.添加文件索引&#xff0c;主要用于把路径导进来 6.这一步要添加的目录与你安装的cplex的目录有关系 F:\program…...

Kubernetes 弃用Docker后 Kubelet切换到Containerd

containerd 是一个高级容器运行时&#xff0c;又名 容器管理器。简单来说&#xff0c;它是一个守护进程&#xff0c;在单个主机上管理完整的容器生命周期&#xff1a;创建、启动、停止容器、拉取和存储镜像、配置挂载、网络等。 containerd 旨在轻松嵌入到更大的系统中。Docke…...

函数模板含有多个模板参数

如果一个模板接受多个参数&#xff0c;用逗号分隔参数。 使用时必要情况下需要主动传入模板参数。 #include <iostream> #include <vector>/* Compute the greatest common divisor of two integers, using Euclids algorithm. */ template<class T, class U&g…...

Sprd Android 13 增加系统属性判断当前有无 OTG U盘插入,App 读取系统属性

添加系统属性,通过监听插拔广播判断当前有无OTG U盘插入 --- a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -246,6 +246,7 @@ …...

wordpress增加文章类型/关键词推广seo

抗干扰即要提高系统的可靠性&#xff0c;基本的出发点&#xff1a; 1.隔离外部的干扰信号&#xff0c;比如用屏蔽罩将系统局限于一个封闭空间内&#xff1b; 2.优化系统设计&#xff0c;减小本身干扰&#xff0c;并提高系统的抗干扰能力&#xff1b; 3.提高系统的自救能力。 从…...

成都 网站备案 幕布拍摄点/推广标题怎么写

大学物理实验考试样卷[1]一、有效数字及误差理论(25分)1、一量程为7.5V、准确度等级为1.0级的电压表&#xff0c;其结果的小数点后面应有( )位数字。(3分)A. 1 B. 2 C. 3 D. 42、mm。(3分)3、圆周长的计算公式 &#xff0c;其中R0.02640m&#xff0c;则式中R为 位有效数字&…...

国内网站建设阿里云/优化大师下载安装免费

react-native-country-picker-modal https://github.com/xcarpentier/react-native-country-picker-modalThe best Country Picker for React Native. 国家选择器提供了模式&#xff0c;允许用户从列表中选择一个国家。 它在每个国家名称旁边显示一个标志。 Demo on Exponent …...

运动网站建设主题/网站建设7个基本流程

JS控制HTML5 vedio播放UITableview自适应高度ios实现相册多选操作 2014-09-17 19:35:07| 分类&#xff1a; objective-c | 标签&#xff1a;ios 相册多选 |举报 |字号大中小 订阅 我们知道UIKit框架为我们提供了UIImagePickerController 这个控制器来读取相册资源&…...

网站建立供应商/百度竞价教程

下面是一些关于大数据挖掘的知识点&#xff0c;今天和大家一起来学习一下。1. 数据、信息和知识是广义数据表现的不同形式。 2. 主要知识模式类型有&#xff1a;广义知识&#xff0c;关联知识&#xff0c;类知识&#xff0c;预测型知识&#xff0c;特异型知识3. web挖掘研究的主…...

做珠宝网站价格多少/seo查询网站

提到mysql优化&#xff0c;索引优化是必不可少的。其中一种优化方式 ——索引优化&#xff0c;添加合适的索引能够让项目的并发能力和抗压能力得到明显的提升。我们知道项目性能的瓶颈主要是在"查(select)"语句&#xff0c;要提升"查"这一性能&#xff0c;…...