GEE错误——image.reduceRegion is not a function
简介
image.reduceRegion is not a function
这里的主要问题是我们进行地统计分析的时候,我们的作用对象必须是单景影像,而不是影像集合
错误"image.reduceRegion is not a function" 表示你正在尝试使用reduceRegion()函数来处理图像数据,但是该函数在所使用的图像对象上并不存在。这通常发生在以下几种情况下:
-
你使用的图像对象并不是由Earth Engine提供的图像数据类型。只有Earth Engine提供的图像数据类型,如Image、ImageCollection等,才包含reduceRegion()函数。确保你使用的图像对象是Earth Engine提供的类型。
-
你使用的图像对象是一个空对象或没有加载任何数据。如果图像对象为空,那么该对象上是没有reduceRegion()函数的。请确保你加载了正确的图像数据,或者使用其他方法创建图像对象。
-
你使用了错误的函数名称。请检查你的代码,确保你使用的是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, geometry, scale, crs, crsTransform, bestEffort, maxPixels, tileScale)
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 这里的主要问题是我们进行地统计分析的时候,我们的作用对象必须是单景影像,而不是影像集合 错误"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 ,不是在地址栏输入(切记),就直接敲键盘就行了 因为Chrome不信任这些自签名ssl证书,为了安全起见,直接禁止访问了,thisisunsafe 这个命令,说明你…...
牛客面试前端1
HTML语义化 是什么 前端语义化是指在构建网页时多使用html语义化标签布局,多使用带有语义的标签如header,aside,footer等标签为什么 结构清晰利于开发者开发与维护 有利于seo搜索引擎优化 有利于在网络卡顿时,正常显示页面结构&a…...

Linux的软件包管理器-yum
文章目录 软件包的概念yum源的配置的原因yum的使用查看软件包安装软件卸载软件 软件包的概念 软件包(SoftWare Package)是指具有特定的功能,用来完成特定任务的一个程序或一组程序。可分为应用软件包和系统软件包两大类 在Linux系统中,下载安装软件的方式…...
选择排序(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融屏视频混流会议直播方案分析
随着万物互联,视频会议直播互动深入业务各方面,主流SFU并不适合管理,很多业务需要各种监控终端,互动SIP硬件设备,Web在线业务平台能相互融合,互联互通, 视频混流直播,录存直播推广&a…...

Unreal 编辑器工具 批量重命名资源
右键 - Editor Utilities - Editor Utility Blueprint,基类选择 Asset Action Utility 在类默认值内,可以添加筛选器,筛选指定的类型 然后新建一个函数,加上4个输入:ReplaceFrom,ReplaceTo,Add…...

Voice Conversion、DreamScene、X-SLAM、Panoptic-SLAM、DiffMap、TinySeg
本文首发于公众号:机器感知 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…...
短信群发平台分析短信群发的未来发展趋势
短信群发平台在当前的移动互联网时代已经展现出了其独特的价值和广泛的应用场景。随着技术的不断进步和市场的不断变化,短信群发的未来发展趋势也将呈现出一些新的特点。 首先,随着5G网络的推广和普及,短信群发的速度和稳定性将得到进一步提…...
supervisord 使用指南
supervisord 使用指南 supervisord的安装 supervisor是一系列python脚本文件,以python package的形式管理,可以用于UNIX类系统的进程管理。 安装supervisor也相当简单,只需要用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. 要使用哪个钩子函数,就先引入 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…...

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

根据相同的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 时,你可能在一些著名的开源项目,例如 Kubernetes,Istio 中看到如下的一些评论: /lgtm /retest /area bug /assign xxxx ...等等,诸如此类的一些功能性评论。在这些评论出现…...

使用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 请求是怎样的? 💖The Begin💖点点关注,收藏不迷路💖 域名解析 --> 发起 TCP 的 3 次握手 --> 建立 TCP 连接后发起 http 请求 --> 服务器响应 http 请求,浏览器得到 html 代码 --…...

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

idea大量爆红问题解决
问题描述 在学习和工作中,idea是程序员不可缺少的一个工具,但是突然在有些时候就会出现大量爆红的问题,发现无法跳转,无论是关机重启或者是替换root都无法解决 就是如上所展示的问题,但是程序依然可以启动。 问题解决…...

【项目实战】通过多模态+LangGraph实现PPT生成助手
PPT自动生成系统 基于LangGraph的PPT自动生成系统,可以将Markdown文档自动转换为PPT演示文稿。 功能特点 Markdown解析:自动解析Markdown文档结构PPT模板分析:分析PPT模板的布局和风格智能布局决策:匹配内容与合适的PPT布局自动…...
React---day11
14.4 react-redux第三方库 提供connect、thunk之类的函数 以获取一个banner数据为例子 store: 我们在使用异步的时候理应是要使用中间件的,但是configureStore 已经自动集成了 redux-thunk,注意action里面要返回函数 import { configureS…...
CSS设置元素的宽度根据其内容自动调整
width: fit-content 是 CSS 中的一个属性值,用于设置元素的宽度根据其内容自动调整,确保宽度刚好容纳内容而不会超出。 效果对比 默认情况(width: auto): 块级元素(如 <div>)会占满父容器…...

Aspose.PDF 限制绕过方案:Java 字节码技术实战分享(仅供学习)
Aspose.PDF 限制绕过方案:Java 字节码技术实战分享(仅供学习) 一、Aspose.PDF 简介二、说明(⚠️仅供学习与研究使用)三、技术流程总览四、准备工作1. 下载 Jar 包2. Maven 项目依赖配置 五、字节码修改实现代码&#…...
站群服务器的应用场景都有哪些?
站群服务器主要是为了多个网站的托管和管理所设计的,可以通过集中管理和高效资源的分配,来支持多个独立的网站同时运行,让每一个网站都可以分配到独立的IP地址,避免出现IP关联的风险,用户还可以通过控制面板进行管理功…...
前端工具库lodash与lodash-es区别详解
lodash 和 lodash-es 是同一工具库的两个不同版本,核心功能完全一致,主要区别在于模块化格式和优化方式,适合不同的开发环境。以下是详细对比: 1. 模块化格式 lodash 使用 CommonJS 模块格式(require/module.exports&a…...

Qt/C++学习系列之列表使用记录
Qt/C学习系列之列表使用记录 前言列表的初始化界面初始化设置名称获取简单设置 单元格存储总结 前言 列表的使用主要基于QTableWidget控件,同步使用QTableWidgetItem进行单元格的设置,最后可以使用QAxObject进行单元格的数据读出将数据进行存储。接下来…...
【系统架构设计师-2025上半年真题】综合知识-参考答案及部分详解(回忆版)
更多内容请见: 备考系统架构设计师-专栏介绍和目录 文章目录 【第1题】【第2题】【第3题】【第4题】【第5题】【第6题】【第7题】【第8题】【第9题】【第10题】【第11题】【第12题】【第13题】【第14题】【第15题】【第16题】【第17题】【第18题】【第19题】【第20~21题】【第…...

【计算机网络】SDN
SDN这种新型网络体系结构的核心思想:把网络的控制层面与数据层面分离,而让控制层面利用软件来控制数据层面中的许多设备。 OpenFlow协议可以被看成是SDN体系结构中控制层面与数据层面之间的通信接口。 在SDN中取代传统路由器中转发表的是“流表”&…...