本文整理汇总了Python中qgis.core.QgsRasterProjector.setCRS方法的典型用法代码示例。如果您正苦于以下问题:Python QgsRasterProjector.setCRS方法的具体用法?Python QgsRasterProjector.setCRS怎么用?Python QgsRasterProjector.setCRS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgis.core.QgsRasterProjector
的用法示例。
在下文中一共展示了QgsRasterProjector.setCRS方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: write
# 需要导入模块: from qgis.core import QgsRasterProjector [as 别名]
# 或者: from qgis.core.QgsRasterProjector import setCRS [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):
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