예제 #1
0
def SlopeReclass(bassin, zone, workdir, overwrite):
    """
    Reclassification des pentes en 4 classes
    """

    from qgis_helper import execute
    from processing.tools.system import getTempDirInTempFolder

    dem = os.path.join(workdir, bassin, zone, 'DEM5M.tif')
    # slope = os.path.join(workdir, bassin, zone, 'SLOPE.tif')
    output = os.path.join(workdir, bassin, zone, 'SLOPE_CLS.tif')

    if os.path.exists(output) and not overwrite:
        important('Output already exists : %s' % output)
        return

    info('Smooth DEM using 5x5 mean filter')

    parameters = dict(input=dem,
                      bands=[1],
                      filter_type=0,
                      size=5,
                      output=os.path.join(getTempDirInTempFolder(),
                                          'SMOOTHED.tif'))

    result = execute("fct:simplerasterfilter", **parameters)

    if 'OUTPUT' not in result:
        warning('Error :(')
        return

    info('Calculate slope')

    parameters = dict(input=result['OUTPUT'],
                      z_factor=1,
                      output=os.path.join(getTempDirInTempFolder(),
                                          'SLOPE.tif'))

    result = execute("qgis:slope", **parameters)

    if 'OUTPUT' not in result:
        warning('Error :(')
        return

    info('Reclass slopes')

    parameters = dict(input_raster=result['OUTPUT'],
                      raster_band=1,
                      table=[0, 2, 1, 2, 6, 2, 6, 12, 3, 12, None, 4],
                      no_data=0,
                      range_boundaries=1,
                      nodata_for_missing=True,
                      data_type=0,
                      output=output)

    result = execute('native:reclassifybytable', **parameters)

    if 'OUTPUT' in result:
        success('Saved to %s' % result['OUTPUT'])
예제 #2
0
파일: outputs.py 프로젝트: spono/QGIS
 def resolveValue(self, alg):
     self.value = getTempDirInTempFolder()
예제 #3
0
 def resolveValue(self, alg):
     self.value = getTempDirInTempFolder()
예제 #4
0
 def getOutputDir():
     outputDir = system.getTempDirInTempFolder()
     if not QDir(outputDir).exists():
         QDir().mkpath(outputDir)
     return unicode(os.path.abspath(outputDir))
#from processing.core.Processing import Processing
#Processing.initialize()
#versionSAGA = processing.algs.saga.SagaUtils.getInstalledVersion()
#print( versionSAGA)
from qgis.core import (Qgis, QgsProcessingFeedback)
#, \
#    QgsProcessingOutputRasterLayer,  QgsProcessingParameterRasterDestination)
import processing

info_extent = '795825.2212942,796084.9317131,6674126.9668843,6674710.7083225 [EPSG:2154]'
mon_feedback = QgsProcessingFeedback()

print("Version QGIS" + Qgis.QGIS_VERSION)
from processing.tools.system import getTempDirInTempFolder  #  getTempFilename
nom_temp_dir = getTempDirInTempFolder().replace("\\", "/")
nom_raster_temp = nom_temp_dir + "/" + "TARGET_OUT_GRID.sdat"
# JHJH
#layerURI_nettoye = nom_raster_temp.replace("\\", "/")
#raster_temp = QgsProcessingOutputRasterLayer( nom_raster_temp)
#destination_raster_temp = QgsProcessingParameterRasterDestination( raster_temp)
#
IDW_SAGA = {
    'SHAPES': 'D:/GIS/DATA/POINTS.shp',
    'FIELD': 'DIAM',
    'DW_WEIGHTING': 1,
    'DW_IDW_POWER': 2,
    'DW_IDW_OFFSET': False,
    'DW_BANDWIDTH': 1,
    'SEARCH_POINTS_ALL': 0,
    'SEARCH_RANGE': 0,
    'SEARCH_RADIUS': 100,