本文整理汇总了Python中osgeo.gdal.UseExceptions方法的典型用法代码示例。如果您正苦于以下问题:Python gdal.UseExceptions方法的具体用法?Python gdal.UseExceptions怎么用?Python gdal.UseExceptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osgeo.gdal
的用法示例。
在下文中一共展示了gdal.UseExceptions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_tif2
# 需要导入模块: from osgeo import gdal [as 别名]
# 或者: from osgeo.gdal import UseExceptions [as 别名]
def make_tif2(path, reso=(1., -1.), rsize=(10, 10), tl=(0., 10.),
proj=SRS[0]['wkt'], channel_count=1, dtype=gdal.GDT_Float32,
nodata=-32000, nodata_border_size=(0, 0, 0, 0)):
"""Create a tiff files"""
reso = np.asarray(reso)
fp = buzz.Footprint(tl=tl, rsize=rsize, size=np.abs(reso * rsize))
x, y = fp.meshgrid_raster
a = x + y
if nodata_border_size != 0:
l, r, t, b = nodata_border_size
if t != 0:
a[None:t, None:None] = nodata
if b != 0:
a[-b:None, None:None] = nodata
if l != 0:
a[None:None, None:l] = nodata
if r != 0:
a[None:None, -r:None] = nodata
LOGGER.info('TIFF ARRAY:%s\n', a)
gdal.UseExceptions()
driver = gdal.GetDriverByName('GTiff')
dataset = driver.Create(path, int(rsize[0]), int(rsize[1]), channel_count, dtype)
dataset.SetGeoTransform(fp.gt)
dataset.SetProjection(proj)
for i in range(channel_count):
dataset.GetRasterBand(i + 1).WriteArray(a)
dataset.GetRasterBand(i + 1).SetNoDataValue(nodata)
dataset.FlushCache()
示例2: has_geos
# 需要导入模块: from osgeo import gdal [as 别名]
# 或者: from osgeo.gdal import UseExceptions [as 别名]
def has_geos():
pnt1 = ogr.CreateGeometryFromWkt("POINT(10 20)")
pnt2 = ogr.CreateGeometryFromWkt("POINT(30 20)")
ogrex = ogr.GetUseExceptions()
gdalex = gdal.GetUseExceptions()
gdal.DontUseExceptions()
ogr.DontUseExceptions()
hasgeos = pnt1.Union(pnt2) is not None
if ogrex:
ogr.UseExceptions()
if gdalex:
gdal.UseExceptions()
return hasgeos
示例3: __init__
# 需要导入模块: from osgeo import gdal [as 别名]
# 或者: from osgeo.gdal import UseExceptions [as 别名]
def __init__(self):
# this allows GDAL to throw Python Exceptions
gdal.UseExceptions()
示例4: __init__
# 需要导入模块: from osgeo import gdal [as 别名]
# 或者: from osgeo.gdal import UseExceptions [as 别名]
def __init__(self):
"""
Constructor
"""
# this allows GDAL to throw Python Exceptions
gdal.UseExceptions()