当前位置: 首页 > 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;我们始终未能提供一份详尽的用户使用文档&…...

web vue 项目 Docker化部署

Web 项目 Docker 化部署详细教程 目录 Web 项目 Docker 化部署概述Dockerfile 详解 构建阶段生产阶段 构建和运行 Docker 镜像 1. Web 项目 Docker 化部署概述 Docker 化部署的主要步骤分为以下几个阶段&#xff1a; 构建阶段&#xff08;Build Stage&#xff09;&#xff1a…...

Leetcode 3576. Transform Array to All Equal Elements

Leetcode 3576. Transform Array to All Equal Elements 1. 解题思路2. 代码实现 题目链接&#xff1a;3576. Transform Array to All Equal Elements 1. 解题思路 这一题思路上就是分别考察一下是否能将其转化为全1或者全-1数组即可。 至于每一种情况是否可以达到&#xf…...

C++:std::is_convertible

C++标志库中提供is_convertible,可以测试一种类型是否可以转换为另一只类型: template <class From, class To> struct is_convertible; 使用举例: #include <iostream> #include <string>using namespace std;struct A { }; struct B : A { };int main…...

LeetCode - 394. 字符串解码

题目 394. 字符串解码 - 力扣&#xff08;LeetCode&#xff09; 思路 使用两个栈&#xff1a;一个存储重复次数&#xff0c;一个存储字符串 遍历输入字符串&#xff1a; 数字处理&#xff1a;遇到数字时&#xff0c;累积计算重复次数左括号处理&#xff1a;保存当前状态&a…...

STM32F4基本定时器使用和原理详解

STM32F4基本定时器使用和原理详解 前言如何确定定时器挂载在哪条时钟线上配置及使用方法参数配置PrescalerCounter ModeCounter Periodauto-reload preloadTrigger Event Selection 中断配置生成的代码及使用方法初始化代码基本定时器触发DCA或者ADC的代码讲解中断代码定时启动…...

鸿蒙中用HarmonyOS SDK应用服务 HarmonyOS5开发一个医院挂号小程序

一、开发准备 ​​环境搭建​​&#xff1a; 安装DevEco Studio 3.0或更高版本配置HarmonyOS SDK申请开发者账号 ​​项目创建​​&#xff1a; File > New > Create Project > Application (选择"Empty Ability") 二、核心功能实现 1. 医院科室展示 /…...

转转集团旗下首家二手多品类循环仓店“超级转转”开业

6月9日&#xff0c;国内领先的循环经济企业转转集团旗下首家二手多品类循环仓店“超级转转”正式开业。 转转集团创始人兼CEO黄炜、转转循环时尚发起人朱珠、转转集团COO兼红布林CEO胡伟琨、王府井集团副总裁祝捷等出席了开业剪彩仪式。 据「TMT星球」了解&#xff0c;“超级…...

【OSG学习笔记】Day 16: 骨骼动画与蒙皮(osgAnimation)

骨骼动画基础 骨骼动画是 3D 计算机图形中常用的技术&#xff0c;它通过以下两个主要组件实现角色动画。 骨骼系统 (Skeleton)&#xff1a;由层级结构的骨头组成&#xff0c;类似于人体骨骼蒙皮 (Mesh Skinning)&#xff1a;将模型网格顶点绑定到骨骼上&#xff0c;使骨骼移动…...

保姆级教程:在无网络无显卡的Windows电脑的vscode本地部署deepseek

文章目录 1 前言2 部署流程2.1 准备工作2.2 Ollama2.2.1 使用有网络的电脑下载Ollama2.2.2 安装Ollama&#xff08;有网络的电脑&#xff09;2.2.3 安装Ollama&#xff08;无网络的电脑&#xff09;2.2.4 安装验证2.2.5 修改大模型安装位置2.2.6 下载Deepseek模型 2.3 将deepse…...

CRMEB 中 PHP 短信扩展开发:涵盖一号通、阿里云、腾讯云、创蓝

目前已有一号通短信、阿里云短信、腾讯云短信扩展 扩展入口文件 文件目录 crmeb\services\sms\Sms.php 默认驱动类型为&#xff1a;一号通 namespace crmeb\services\sms;use crmeb\basic\BaseManager; use crmeb\services\AccessTokenServeService; use crmeb\services\sms\…...