福田住房和建设局网站/企业营销推广策划
简介
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年起,并行执行功能已被许多客户应用于多种场景之中,其重要性日益凸显。然而,遗憾的是,我们始终未能提供一份详尽的用户使用文档&…...

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

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

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

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

【毕业设计】基于SSM的运动用品商城的设计与实现
1.项目介绍 在这个日益数字化和信息化的时代,随着人们购物习惯的转变,传统的实体商店已经无法满足人们日益增长的在线购物需求。因此,基于SSM(Spring Spring MVC MyBatis)框架的运动用品商城项目应运而生࿰…...

【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,点击第一项常规,配置附加库目录 5.添加文件索引,主要用于把路径导进来 6.这一步要添加的目录与你安装的cplex的目录有关系 F:\program…...

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

函数模板含有多个模板参数
如果一个模板接受多个参数,用逗号分隔参数。 使用时必要情况下需要主动传入模板参数。 #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 @@ …...