Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 平均光栅时,是否有方法计算用于计算像素平均值的每个像素的n个非NaN值?_Python_R_Raster_Arcgis_Qgis - Fatal编程技术网

Python 平均光栅时,是否有方法计算用于计算像素平均值的每个像素的n个非NaN值?

Python 平均光栅时,是否有方法计算用于计算像素平均值的每个像素的n个非NaN值?,python,r,raster,arcgis,qgis,Python,R,Raster,Arcgis,Qgis,我有大约40个锉刀(TIFF)。我计算了光栅的平均值,这很简单。但是,作为第二个输出,我想确定用于计算每个像素平均值的每个像素的非NaN值的n个数,并将其显示为光栅。基本上,我需要知道每个像素有多少个值用于计算平均值。这可能吗?我正在寻找使用GIS(ArcGIS或QGIS都可以)、Python或R的解决方案。干杯。以下是如何使用terra软件包使用R实现这一点 library(terra) s <- rast(system.file("ex/logo.tif", pac

我有大约40个锉刀(TIFF)。我计算了光栅的平均值,这很简单。但是,作为第二个输出,我想确定用于计算每个像素平均值的每个像素的非NaN值的n个数,并将其显示为光栅。基本上,我需要知道每个像素有多少个值用于计算平均值。这可能吗?我正在寻找使用GIS(ArcGIS或QGIS都可以)、Python或R的解决方案。干杯。

以下是如何使用terra
软件包使用R实现这一点

library(terra)
s <- rast(system.file("ex/logo.tif", package="terra"))   

m <- mean(s)
n <- sum(!is.na(s))
library(raster)
b <- brick(system.file("external/rlogo.grd", package="raster"))
mb <- mean(b)
nb <- sum(!is.na(b))

很抱歉,我只是修改了我的评论,说我使用了光栅软件包的说明,它工作了。