如何使用python 3中的gdal.grid设置栅格的分辨率?

发布于 2025-01-24 23:48:48 字数 574 浏览 4 评论 0原文

如何设置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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

別甾虛僞 2025-01-31 23:48:48

我也有同样的问题,并找到了这个解决方案:

例如,创建具有100 x 200像素的GTIFF写作:

from osgeo import gdal
raster= gdal.Grid(destName='output.tif',srcDS='input.shp',format='GTiff',options=gdal.GridOptions(width=100,height=200))

I had the same question and found this solution:

To create for example a GTiff with 100 x 200 pixels write:

from osgeo import gdal
raster= gdal.Grid(destName='output.tif',srcDS='input.shp',format='GTiff',options=gdal.GridOptions(width=100,height=200))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文