如何使用python 3中的gdal.grid设置栅格的分辨率?
如何设置GDAL.GRID中生成的光栅的输出分辨率?我正在使用下面的代码,该代码生产具有非常大的单元格(〜70m)的TIF,但是VRT中引用的数据(FILEPATH_VRT_IN)具有以下分辨率的数据。当使用反距离加权算法和最近的X,y半径为1M时,我会得到相同的结果。
from osgeo import gdal
temp_wd = gdal.Grid("C:/Temp/Python-Output-WD-01.TIF", filepath_vrt_in, zfield="Z", algorithm = "nearest:radius1=5.0:radius2=5.0:angle=0.0:nodata=-9999")
temp_wd = None
我还尝试使用以下在输出TIF上使用GDAL.WARP,该输出TIF以类似的分辨率产生TIF。
temp_warpwd = gdal.Warp("C:/Temp/Python-Output-WD-WARPED-01.TIF", "C:/Temp/Python-Output-WD-01.TIF", xRes=5, yRes=5)
temp_warpwd = None
How to set the output resolution of the raster generated in gdal.Grid? I am using the code below, which produces a TIF with very large cells (~70m) however the data referenced in the vrt (filepath_vrt_in) has data at sub-metre resolution. I get the same result when using inverse distance weighting algorithm, and nearest neighbour at x,y radius of 1m.
from osgeo import gdal
temp_wd = gdal.Grid("C:/Temp/Python-Output-WD-01.TIF", filepath_vrt_in, zfield="Z", algorithm = "nearest:radius1=5.0:radius2=5.0:angle=0.0:nodata=-9999")
temp_wd = None
I have also tried using gdal.Warp as below on the output TIF, which produces a TIF at similar resolution.
temp_warpwd = gdal.Warp("C:/Temp/Python-Output-WD-WARPED-01.TIF", "C:/Temp/Python-Output-WD-01.TIF", xRes=5, yRes=5)
temp_warpwd = None
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我也有同样的问题,并找到了这个解决方案:
例如,创建具有100 x 200像素的GTIFF写作:
I had the same question and found this solution:
To create for example a GTiff with 100 x 200 pixels write: