本文整理汇总了Python中molusce.algorithms.dataprovider.Raster.geoTransformMatch方法的典型用法代码示例。如果您正苦于以下问题:Python Raster.geoTransformMatch方法的具体用法?Python Raster.geoTransformMatch怎么用?Python Raster.geoTransformMatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类molusce.algorithms.dataprovider.Raster
的用法示例。
在下文中一共展示了Raster.geoTransformMatch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRaster
# 需要导入模块: from molusce.algorithms.dataprovider import Raster [as 别名]
# 或者: from molusce.algorithms.dataprovider.Raster import geoTransformMatch [as 别名]
#.........这里部分代码省略.........
answer = [[[ 0, 0, 0,],
[ 0, 0, 0],
[ 0, 0, 0]]]
assert_array_equal(answer, rast.bands)
rast = Raster('examples/multifact.tif')
rast.bands = rast.bands*1.1
rast.roundBands(decimals=1)
answer = np.array(
[[
[1.1,1.1,3.3],
[3.3,2.2,1.1],
[0.0,3.3,1.1]
]])
assert_array_equal(answer, rast.bands)
def test_isContinues(self):
rast = Raster('examples/multifact.tif')
self.assertFalse(rast.isCountinues(bandNo=1))
rast = Raster('examples/dist_roads.tif')
self.assertTrue(rast.isCountinues(bandNo=1))
def test_getBandStat(self):
stat = self.r1.getBandStat(1)
self.assertAlmostEqual(stat['mean'], 15.0/9)
self.assertAlmostEqual(stat['std'], np.sqrt(10.0/9))
def test_normalize(self):
multifact = [
[1,1,3],
[3,2,1],
[0,3,1],
]
# Normalize using std and mean
r1 = Raster('examples/multifact.tif')
r1.normalize()
r1.denormalize()
assert_array_equal(r1.getBand(1), multifact)
# Normalize using min and max
r1 = Raster('examples/multifact.tif')
r1.normalize(mode='maxmin')
r1.denormalize()
assert_array_equal(r1.getBand(1), multifact)
# Two normalization procedures
r1 = Raster('examples/multifact.tif')
r1.normalize()
r1.normalize(mode='maxmin')
r1.denormalize()
assert_array_equal(r1.getBand(1), multifact)
r1 = Raster('examples/multifact.tif')
r1.normalize(mode='maxmin')
r1.normalize()
r1.denormalize()
assert_array_equal(r1.getBand(1), multifact)
def test_getNeighbours(self):
neighbours = self.r2.getNeighbours(row=1,col=0, size=0)
self.assertEqual(neighbours, [[1]])
neighbours = self.r2.getNeighbours(row=1,col=1, size=1)
assert_array_equal(neighbours, [self.data2])
neighbours = self.r3.getNeighbours(row=1,col=1, size=1)
assert_array_equal(neighbours, [self.data2, self.data1])
# Check pixel on the raster bound and nonzero neighbour size
self.assertRaises(ProviderError, self.r2.getNeighbours, col=1, row=0, size=1)
self.assertRaises(ProviderError, self.r2.getNeighbours, col=1, row=1, size=2)
def test_geodata(self):
geodata = self.r1.getGeodata()
self.r1.setGeoData(geodata)
geodata['xSize'] = geodata['xSize'] + 10
self.assertRaises(ProviderError, self.r1.setGeoData, geodata=geodata)
self.assertTrue(self.r1.geoDataMatch(self.r1))
self.assertTrue(self.r1.geoDataMatch(raster=None, geodata=self.r1.getGeodata()))
self.assertTrue(self.r1.geoTransformMatch(self.r1))
self.assertTrue(self.r1.geoTransformMatch(raster=None, geodata=self.r1.getGeodata()))
def test_save(self):
try:
filename = 'temp.tiff'
self.r1.save(filename)
r2 = Raster(filename)
self.assertEqual(r2.get_dtype(), self.r1.get_dtype())
self.assertEqual(r2.getBandsCount(), self.r1.getBandsCount())
for i in range(r2.getBandsCount()):
assert_array_equal(r2.getBand(i+1), self.r1.getBand(i+1))
finally:
os.remove(filename)
def test_getBandGradation(self):
self.assertEqual(set(self.r1.getBandGradation(1)), set([0, 1, 2, 3]))