本文整理匯總了Python中qgis.core.QgsRasterProjector.clone方法的典型用法代碼示例。如果您正苦於以下問題:Python QgsRasterProjector.clone方法的具體用法?Python QgsRasterProjector.clone怎麽用?Python QgsRasterProjector.clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類qgis.core.QgsRasterProjector
的用法示例。
在下文中一共展示了QgsRasterProjector.clone方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: write
# 需要導入模塊: from qgis.core import QgsRasterProjector [as 別名]
# 或者: from qgis.core.QgsRasterProjector import clone [as 別名]
def write(self, theRasterName):
print theRasterName
path = "%s/%s" % ( self.testDataDir, theRasterName )
#myFileInfo = QFileInfo( path )
#myBaseName = myFileInfo.baseName()
rasterLayer = QgsRasterLayer(path, "test")
if not rasterLayer.isValid(): return False
provider = rasterLayer.dataProvider()
tmpFile = QTemporaryFile()
tmpFile.open() # fileName is no avialable until open
tmpName = tmpFile.fileName()
tmpFile.close();
# do not remove when class is destroyd so that we can read the file and see difference
tmpFile.setAutoRemove ( False )
fileWriter = QgsRasterFileWriter ( tmpName )
pipe = QgsRasterPipe()
if not pipe.set( provider.clone() ):
print "Cannot set pipe provider"
return False
#nuller = QgsRasterNuller()
#nuller.setNoData( ... )
#if not pipe.insert( 1, nuller ):
# print "Cannot set pipe nuller"
# return False
projector = QgsRasterProjector()
projector.setCRS( provider.crs(), provider.crs() )
if not pipe.insert( 2, projector.clone() ):
print "Cannot set pipe projector"
return False
fileWriter.writeRaster( pipe, provider.xSize(), provider.ySize(), provider.extent(), provider.crs() )
checker = QgsRasterChecker()
ok = checker.runTest( "gdal", tmpName, "gdal", path );
self.report += checker.report();
# All OK, we can delete the file
tmpFile.setAutoRemove ( ok );
return ok