本文整理汇总了Python中rasterio.enums方法的典型用法代码示例。如果您正苦于以下问题:Python rasterio.enums方法的具体用法?Python rasterio.enums怎么用?Python rasterio.enums使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rasterio
的用法示例。
在下文中一共展示了rasterio.enums方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_resampling_enum
# 需要导入模块: import rasterio [as 别名]
# 或者: from rasterio import enums [as 别名]
def _get_resampling_enum(method: str) -> Any:
from rasterio.enums import Resampling
if method == 'nearest':
return Resampling.nearest
if method == 'linear':
return Resampling.bilinear
if method == 'cubic':
return Resampling.cubic
if method == 'average':
return Resampling.average
raise ValueError(f'unknown resampling method {method}')
示例2: _has_alpha_band
# 需要导入模块: import rasterio [as 别名]
# 或者: from rasterio import enums [as 别名]
def _has_alpha_band(src: 'DatasetReader') -> bool:
from rasterio.enums import MaskFlags, ColorInterp
return (
any([MaskFlags.alpha in flags for flags in src.mask_flag_enums])
or ColorInterp.alpha in src.colorinterp
)
示例3: test_reproject
# 需要导入模块: import rasterio [as 别名]
# 或者: from rasterio import enums [as 别名]
def test_reproject():
from rasterio.warp import reproject
from rasterio.enums import Resampling
with rasterio.Env():
# As source: a 1024 x 1024 raster centered on 0 degrees E and 0
# degrees N, each pixel covering 15".
rows, cols = src_shape = (1024, 1024)
# decimal degrees per pixel
d = 1.0 / 240
# The following is equivalent to
# A(d, 0, -cols*d/2, 0, -d, rows*d/2).
src_transform = rasterio.Affine.translation(
-cols*d/2,
rows*d/2) * rasterio.Affine.scale(d, -d)
src_crs = {'init': 'EPSG:4326'}
source = np.ones(src_shape, np.uint8) * 255
# Destination: a 2048 x 2048 dataset in Web Mercator (EPSG:3857)
# with origin at 0.0, 0.0.
dst_shape = (2048, 2048)
dst_transform = Affine.from_gdal(
-237481.5, 425.0, 0.0, 237536.4, 0.0, -425.0)
dst_crs = {'init': 'EPSG:3857'}
destination = np.zeros(dst_shape, np.uint8)
reproject(
source,
destination,
src_transform=src_transform,
src_crs=src_crs,
dst_transform=dst_transform,
dst_crs=dst_crs,
resampling=Resampling.nearest)
# Assert that the destination is only partly filled.
assert destination.any()
assert not destination.all()
# Testing upsample function