在gdal 2.1中使用gdal.Rasterize时是否可以设置数据类型(Byte,Float32)?目前,我使用 gdal.Translate 转换为 Byte,但这效率很低。
tif = my/target.tif
shp = my/source.shp
tiftemp = my/temp/solution.tif
rasterizeOptions = gdal.RasterizeOptions(xRes=20, yRes=20, allTouched=True etc.)
gdal.Rasterize(tiftemp, shp, options=rasterizeOptions)
#translate to Byte data type (not supported by Rasterize?)
gdal.Translate(tif, tiftemp, outputType=gdal.GDT_Byte,
creationOptions=['COMPRESS=PACKBITS')
我知道可以使用
subprocess.check_call('gdal_rasterize', '-ot', 'byte' ...)
但如果可能的话我宁愿避免这种情况。有任何想法吗?
这已在 GDAL 2.1.3 中修复。以前,数据类型是硬编码的,并且未在 Python 绑定中公开。看https://trac.osgeo.org/gdal/ticket/6710.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)