Ejemplo n.º 1
0
    # Generate source class for reclassify script
    srcClass = mapUtil.getSrcClass(subNoLst)

    qLvlLst = mapUtil.getIntValLst(subValLvlOut, "Q", subNoLst, wsid)
    eroLvlLst = mapUtil.getIntValLst(subValLvlOut, "MUSL", subNoLst, wsid)
    tnLvlLst = mapUtil.getIntValLst(subValLvlOut, "TN", subNoLst, wsid)
    tpLvlLst = mapUtil.getIntValLst(subValLvlOut, "TP", subNoLst, wsid)

    fnRecWs = os.path.join(defaultFNFD.fdRecWSTif, 'recws{}.tif'.format(wsNo))
    generalfuncs.checkExists(fnRecWs)

    # Reclass
    print("Generating maps for watershed {}".format(wsNo))
    fndestQ = os.path.join(defaultFNFD.fdTauLayers,
                           'aa{}{}.tif'.format("Q", wsNo))
    generalfuncs.removeFileifExist(fndestQ)
    mapUtil.reclassifyRaster(fnRecWs, fndestQ, srcClass, qLvlLst,
                             globalsetting.fnGdalReclassPy)

    fndestEro = os.path.join(defaultFNFD.fdTauLayers,
                             'aa{}{}.tif'.format("MUSL", wsNo))
    generalfuncs.removeFileifExist(fndestEro)
    mapUtil.reclassifyRaster(fnRecWs, fndestEro, srcClass, eroLvlLst,
                             globalsetting.fnGdalReclassPy)

    fndestTN = os.path.join(defaultFNFD.fdTauLayers,
                            'aa{}{}.tif'.format("TN", wsNo))
    generalfuncs.removeFileifExist(fndestTN)
    mapUtil.reclassifyRaster(fnRecWs, fndestTN, srcClass, tnLvlLst,
                             globalsetting.fnGdalReclassPy)
Ejemplo n.º 2
0
    print("Projection for DEM is {}".format(demProj))
    print("Projection for boundary is {}".format(bdyProj))
    exit()

########################################################################################
# Generate watershed
numProcesses = userinputs.numProcessers
mpiexecPath = globalsetting.mpiexecPath
if numProcesses > 0 and (mpiexecPath == '' or not os.path.exists(mpiexecPath)):
    print(
        'Cannot find MPI program {0} so running TauDEM with just one process'.
        format(mpiexecPath))
    numProcesses = 0

# Running Pit removal
generalfuncs.removeFileifExist(defaultFNFD.fnpFel)
generalfuncs.addToLog("PitFill ...")
taudemfuncs.runPitFill(userinputs.fnDem, defaultFNFD.fnpFel, numProcesses)

generalfuncs.removeFileifExist(defaultFNFD.fnpSd8)
generalfuncs.removeFileifExist(defaultFNFD.fnpP)
generalfuncs.addToLog('D8FlowDir ...')
taudemfuncs.runD8FlowDir(defaultFNFD.fnpFel, defaultFNFD.fnpSd8,
                         defaultFNFD.fnpP, numProcesses)

generalfuncs.removeFileifExist(defaultFNFD.fnpAd8)
generalfuncs.addToLog('AreaD8 ...')
taudemfuncs.runAreaD8(defaultFNFD.fnpP, defaultFNFD.fnpAd8, None, None,
                      numProcesses)

generalfuncs.removeFileifExist(defaultFNFD.fnpGord)
Ejemplo n.º 3
0
########################################################################################
generalfuncs.checkExists(userinputs.fnpOutLet)
"""check consistency of projection system"""
demProj = gdalfuncs.getRasterProj(userinputs.fnDem)
oltProj = gdalfuncs.getShpProjGdal(userinputs.fnpOutLet)

if not (demProj == oltProj):
    print("Error: The dem and outlet do not have same projection system.")
    exit()
########################################################################################
# Generate streamline
numProcesses = userinputs.numProcessers
mpiexecPath = globalsetting.mpiexecPath

# Move outlet to streamline to make sure that the outlet is ont the stream cells
generalfuncs.removeFileifExist(defaultFNFD.fnpMvOlt)
generalfuncs.addToLog('moveOutlet to stream line ...')
taudemfuncs.runMoveOutlets(defaultFNFD.fnpP, defaultFNFD.fnpSrcStream,
                           userinputs.fnpOutLet, defaultFNFD.fnpMvOlt,
                           userinputs.mvOltSnapDist, numProcesses)

if numProcesses > 0 and (mpiexecPath == '' or not os.path.exists(mpiexecPath)):
    print(
        'Cannot find MPI program {0} so running TauDEM with just one process'.
        format(mpiexecPath))
    numProcesses = 0

generalfuncs.removeFileifExist(defaultFNFD.fnpAd8)
generalfuncs.addToLog('AreaD8 ...')
taudemfuncs.runAreaD8(defaultFNFD.fnpP, defaultFNFD.fnpAd8,
                      defaultFNFD.fnpMvOlt, None, numProcesses)
Ejemplo n.º 4
0

########################################################################################
# Input data check: projection and coverage
generalfuncs.checkExists(userinputs.fnDem)

########################################################################################
# Generate streamline
numProcesses = userinputs.numProcessers
mpiexecPath = globalsetting.mpiexecPath
if numProcesses > 0 and (mpiexecPath == '' or not os.path.exists(mpiexecPath)):
    print('Cannot find MPI program {0} so running TauDEM with just one process'.format(mpiexecPath))
    numProcesses = 0

# Running Pit removal
generalfuncs.removeFileifExist(defaultFNFD.fnpFel)
generalfuncs.addToLog("PitFill ...")
ok = taudemfuncs.runPitFill(userinputs.fnDem, 
                            defaultFNFD.fnpFel,
                            numProcesses)   

generalfuncs.removeFileifExist(defaultFNFD.fnpSd8)
generalfuncs.removeFileifExist(defaultFNFD.fnpP)
generalfuncs.addToLog('D8FlowDir ...')
taudemfuncs.runD8FlowDir(defaultFNFD.fnpFel, 
                                defaultFNFD.fnpSd8,
                                defaultFNFD.fnpP,
                                numProcesses)   

generalfuncs.removeFileifExist(defaultFNFD.fnpAd8)
generalfuncs.addToLog('AreaD8 ...')
Ejemplo n.º 5
0
soilProj = gdalfuncs.getRasterProj(userinputs.fnLandUse)

if not (demProj == landuseProj):
    print("Error: The projection of the LANDUSE layer is not \
            consistent with that of the DEM layer.")
    exit()
if not (demProj == soilProj):
    print("Error: The projection of the SOIL layer is not \
            consistent with that of the DEM layer.")
    exit()

################ Cut landuse and soil to WS extent #################
subWsFullExt = gdalfuncs.getRasterExtent(defaultFNFD.fnpSubWsFull)
print('Clipping Landuse Data to watershed boundary ...')
generalfuncs.addToLog('Clipping Landuse Data to watershed boundary ...')
generalfuncs.removeFileifExist(defaultFNFD.fnpWsExtLu)
gdalfuncs.clipRasterbyExtent(userinputs.fnLandUse, subWsFullExt,
                             defaultFNFD.fnpWsExtLu)
print('Clipping Soil Data to watershed boundary ...')
generalfuncs.addToLog('Clipping Soil Data to watershed boundary ...')
generalfuncs.removeFileifExist(defaultFNFD.fnpWsExtSoil)
gdalfuncs.clipRasterbyExtent(userinputs.fnSoil, subWsFullExt,
                             defaultFNFD.fnpWsExtSoil)

################ Convert WSBdy from tiff to shp #################
generalfuncs.removeFileifExist(defaultFNFD.fnpSubWsShp)
print('Convert watershed raster to shapefile ...')
generalfuncs.addToLog('Convert watershed raster to shapefile ...')
gdalfuncs.convtif2shp(defaultFNFD.fnpSubWsFull, defaultFNFD.fnpSubWsShp)
print('Convert plen raster to asc ...')
generalfuncs.removeFileifExist(defaultFNFD.fnpPlenAsc)