Python GDAL support bigtiff

Code:

Method1

from osgeo import gdal

#  get raster datasource
src_ds = gdal.Open("bigtif larger than 4 GB.tif")
print (src_ds)

# read raster bands
print "[ RASTER BAND COUNT ]: ", src_ds.RasterCount
for band in range( src_ds.RasterCount ):
    band += 1
    print "[ GETTING BAND ]: ", band
    srcband = src_ds.GetRasterBand(band)
    if srcband is None:
        continue

Method2

You can read the data as Array with: 

data = src_ds.ReadAsArray()

And then pass it on the your favourite plotting library.

Alternatively you could simply output to a more common 'picture' format (PNG for example), and use any viewer you like to display the result. 

vmin = 0 # minimum value in your data (will be black in the output) 
vmax = 1 # minimum value in your data (will be white in the output) 
ds = gdal.Translate('fused.png', 'fused.tif', format='PNG', outputType=gdal.GDT_Byte, scaleParams=[[vmin,vmax]]) 
ds = None

The scaling is necessary to convert your data values to the 8-bit range (0-255) which commonly used for pictures.

Requiremennts:

gdal 2.2.4 +

libtiff 4.0.9 +

Using conda:

conda search gdal

conda install gdal=2.2.4

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值