本文整理汇总了Python中rasterio.drivers方法的典型用法代码示例。如果您正苦于以下问题:Python rasterio.drivers方法的具体用法?Python rasterio.drivers怎么用?Python rasterio.drivers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rasterio
的用法示例。
在下文中一共展示了rasterio.drivers方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadBands
# 需要导入模块: import rasterio [as 别名]
# 或者: from rasterio import drivers [as 别名]
def loadBands(inputRaster, snapshape, gfs):
import rasterio
with rasterio.drivers():
with rasterio.open(inputRaster, 'r') as src:
if gfs:
return list(handleBands(src.read_band(i), snapshape) for i in range(1, src.count + 1))
else:
return list(src.read())
示例2: upwrap_raster
# 需要导入模块: import rasterio [as 别名]
# 或者: from rasterio import drivers [as 别名]
def upwrap_raster(inputRaster, outputRaster, bidx, bandtags):
import rasterio
with rasterio.drivers():
with rasterio.open(inputRaster, 'r') as src:
if bidx == 'all':
bandNos = np.arange(src.count) + 1
else:
bandNos = list(int(i.replace(' ', '')) for i in bidx.split(','))
fixedArrays = list(gribdoctor.handleArrays(src.read_band(i)) for i in bandNos)
fixAff = gribdoctor.updateBoundsAffine(src.affine)
if bandtags:
tags = list(src.tags(i + 1) for i in range(src.count))
click.echo(json.dumps(tags, indent=2))
with rasterio.open(outputRaster, 'w',
driver='GTiff',
count=len(bandNos),
dtype=src.meta['dtype'],
height=src.shape[0] * 2,
width=src.shape[1] * 2,
transform=fixAff,
crs=src.crs
) as dst:
for i, b in enumerate(fixedArrays):
dst.write_band(i + 1, b)
示例3: smoosh_rasters
# 需要导入模块: import rasterio [as 别名]
# 或者: from rasterio import drivers [as 别名]
def smoosh_rasters(inputRasters, outputRaster, gfs, development):
import rasterio
rasInfo = list(gribdoctor.loadRasterInfo(b) for b in inputRasters)
if abs(rasInfo[0]['affine'].c) > 360 and development == True:
gfs = False
kwargs = rasInfo[0]['kwargs']
elif development == True:
gfs = True
snapShape = gribdoctor.getSnapDims(rasInfo)
snapSrc = gribdoctor.getSnapAffine(rasInfo, snapShape)
allBands = list(gribdoctor.loadBands(b, snapShape, gfs) for b in inputRasters)
allBands = list(b for sub in allBands for b in sub)
if gfs:
zoomFactor = 2
kwargs = gribdoctor.makeKwargs(allBands, snapSrc, snapShape, zoomFactor)
else:
zoomFactor = 1
kwargs['count'] = len(allBands)
kwargs['driver'] = 'GTiff'
with rasterio.drivers():
with rasterio.open(outputRaster, 'w', **kwargs) as dst:
for i, b in enumerate(allBands):
dst.write_band(i + 1, b)
示例4: loadRaster
# 需要导入模块: import rasterio [as 别名]
# 或者: from rasterio import drivers [as 别名]
def loadRaster(filePath, bands, bounds):
"""
"""
with rasterio.drivers():
with rasterio.open(filePath,'r') as src:
oaff = src.affine
upperLeft = src.index(bounds.left, bounds.top)
lowerRight = src.index(bounds.right, bounds.bottom)
filler = np.zeros((lowerRight[0] - upperLeft[0], lowerRight[1] - upperLeft[1])) - 999
return np.dstack(list(
src.read(i[1], boundless=True, out=filler, window=((upperLeft[0], lowerRight[0]),(upperLeft[1], lowerRight[1]))
) for i in bands
)), oaff
示例5: from_geotiff
# 需要导入模块: import rasterio [as 别名]
# 或者: from rasterio import drivers [as 别名]
def from_geotiff(path_to_tif):
with rasterio.drivers(CPL_DEBUG=True):
with rasterio.open(path_to_tif) as src:
b, g, r = src.read()
total = np.zeros(r.shape, dtype=rasterio.uint16)
for band in r, g, b:
total += band
total /= 3
return total, src