Python rasterio.drivers() Examples
The following are 5
code examples of rasterio.drivers().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
rasterio
, or try the search function
.
Example #1
Source File: __init__.py From grib-doctor with MIT License | 5 votes |
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())
Example #2
Source File: cut_splice_globewrap.py From grib-doctor with MIT License | 5 votes |
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)
Example #3
Source File: cut_splice_globewrap.py From grib-doctor with MIT License | 5 votes |
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)
Example #4
Source File: fill_facets.py From make-surface with MIT License | 5 votes |
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
Example #5
Source File: rastertoolz.py From spandex with BSD 3-Clause "New" or "Revised" License | 5 votes |
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