如何使用gdal.wrap()用NAN单元重新样本栅格
我使用 gdal.wrap()将高分辨率重新采样到较低。但是,我的栅格没有价值( nan )。因此,当我设置Resamplealg时,NAN(S)的较大网格将成为Nan。
这是我的 python中的python :
from osgeo import gdal
### resample and reproject
### data are from MOD11A2 and MYD11A2, and have been converted into annual mean values
raster_rprj = gdal.Warp("./2015_daytime_mean_re.tif",
"./2015_daytime_mean_clip2.tif", dstSRS = "EPSG:4326",
xRes = 0.008, yRes = 0.008, resampleAlg = "average")
raster_rprj = None
我希望它以函数 np.nanmean()
I used gdal.Wrap() to resample from a high resolution to a lower. However, my raster has no value (nan). So, when I set resampleAlg, the larger grids with nan(s) will become nan.
Here is my reprex in Python:
from osgeo import gdal
### resample and reproject
### data are from MOD11A2 and MYD11A2, and have been converted into annual mean values
raster_rprj = gdal.Warp("./2015_daytime_mean_re.tif",
"./2015_daytime_mean_clip2.tif", dstSRS = "EPSG:4326",
xRes = 0.008, yRes = 0.008, resampleAlg = "average")
raster_rprj = None
I hope it runs as the function np.nanmean()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在重新采样之前,您可以将NAN值替换为平均值。
实现这一目标的numpy表达式如下:
其中a是您的像素的numpy阵列。
您会这样运行:
更多有关GDAL CALC: https://gdal.org/gdal.org/progms/gdal_calc.calc.html
然后您可以运行重新采样。
Before the resample, you could replace NaN values with averages.
The numpy expression to achieve that is the following:
Where A is the numpy array of your pixels.
You run it like this:
More about GDAL Calc: https://gdal.org/programs/gdal_calc.html
Then you can run the resample.