R 如何将光栅像素的值与这些像素的真实表面相乘?

R How to multiply the values of the raster pixels with the true surfaces of these pixels?

我想用栅格每个像素的降水值(mm)乘以R下每个像素对应的面积。

起初,我直接将栅格乘以平均像素面积(总面积/像素数)。 但是,如果我们在全球范围内使用 WGS84 投影,实际上赤道和高纬度地区的像素区域有很大不同吗? 这就是我问这个问题的原因。

提前感谢您的帮助

您可以使用以下方法计算每单位面积(此处以米为单位)每个像素的值:

rows = init(raster , v='y') # latitude bands 
PI = 3.14159265359 # PI number
earth_radius = 6371007.181 # radius of earth in meter
raster_resolution = xres(raster) # resolution of the raster layer

new_raster <-  raster  * (( raster_resolution * (PI / 180) * earth_radius) * ( raster_resolution * (3.14159265359 / 180) * earth_radius * cos(rows/180*PI)))