本文整理匯總了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()