我有两个栅格文件,一个为30m分辨率,另一个为100m分辨率。我想获取30m分辨率栅格的每个像素的坐标,然后从100m分辨率栅格中提取每个坐标的值。最终目标是一个30m分辨率的栅格,其值来自100m栅格。
我正在使用Python,并且尝试使用rasterio模块,但是我一直在努力了解如何提取每个像素的纬度/经度(或行/列)点。
我的CRS是:WGS84,EPSG 4326
我的分辨率是:res:(0.0002694945900000002,0.00026949459)
到目前为止,我的代码:
import numpy as np
import skimage.transform as st
import rasterio
import pyproj
30m_file = rasterio.open(path_to_30m_file)
100m_file = rasterio.open(path_to_100m_file)
band1 = 30m_file.read(1)
print("band1:", band1)
#Access values based on georeferenced space
x, y = 30m_file.bounds.left + 0.003, 30m_file.bounds.top - 0.002
row, col = 30m_file.index(x, y)
print("row:", row)
print("col:", col)
print("example value:", band1[row, col])
#The logic would then follow:
# for every pixel lat/lon in 30m file
# open 100m file
# extract 100m value at those 30m pixel lat/lon
# keeping 30m resolution
但是访问坐标然后通过它们进行解析是阻止我前进的原因。