mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-18 00:03:05 -04:00
[processing] use full precision for elevation values
remove unused file
This commit is contained in:
parent
c3e3ba6b49
commit
f4f86cad63
@ -75,6 +75,10 @@ class Relief(GeoAlgorithm):
|
|||||||
self.value = None
|
self.value = None
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
if value == '':
|
||||||
|
if not self.optional:
|
||||||
|
return False
|
||||||
|
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
self.value = value if value != '' else None
|
self.value = value if value != '' else None
|
||||||
else:
|
else:
|
||||||
@ -100,11 +104,11 @@ class Relief(GeoAlgorithm):
|
|||||||
def colorsToString(colors):
|
def colorsToString(colors):
|
||||||
s = ''
|
s = ''
|
||||||
for c in colors:
|
for c in colors:
|
||||||
s += '{:.2f}, {:.2f}, {:d}, {:d}, {:d};'.format(c[0],
|
s += '{:f}, {:f}, {:d}, {:d}, {:d};'.format(c[0],
|
||||||
c[1],
|
c[1],
|
||||||
c[2],
|
c[2],
|
||||||
c[3],
|
c[3],
|
||||||
c[4])
|
c[4])
|
||||||
return s[:-1]
|
return s[:-1]
|
||||||
|
|
||||||
self.addParameter(ParameterRaster(self.INPUT_LAYER,
|
self.addParameter(ParameterRaster(self.INPUT_LAYER,
|
||||||
|
@ -1,80 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
"""
|
|
||||||
***************************************************************************
|
|
||||||
ReliefAuto.py
|
|
||||||
---------------------
|
|
||||||
Date : October 2016
|
|
||||||
Copyright : (C) 2016 by Alexander Bruy
|
|
||||||
Email : alexander dot bruy at gmail dot com
|
|
||||||
***************************************************************************
|
|
||||||
* *
|
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
|
||||||
* it under the terms of the GNU General Public License as published by *
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or *
|
|
||||||
* (at your option) any later version. *
|
|
||||||
* *
|
|
||||||
***************************************************************************
|
|
||||||
"""
|
|
||||||
|
|
||||||
__author__ = 'Alexander Bruy'
|
|
||||||
__date__ = 'October 2016'
|
|
||||||
__copyright__ = '(C) 2016, Alexander Bruy'
|
|
||||||
|
|
||||||
# This will get replaced with a git SHA1 when you do a git archive
|
|
||||||
|
|
||||||
__revision__ = '$Format:%H$'
|
|
||||||
|
|
||||||
import os
|
|
||||||
|
|
||||||
from qgis.PyQt.QtGui import QIcon
|
|
||||||
|
|
||||||
from qgis.analysis import QgsRelief
|
|
||||||
|
|
||||||
from processing.core.GeoAlgorithm import GeoAlgorithm
|
|
||||||
from processing.core.parameters import ParameterRaster
|
|
||||||
from processing.core.parameters import ParameterNumber
|
|
||||||
from processing.core.outputs import OutputRaster
|
|
||||||
from processing.core.outputs import OutputTable
|
|
||||||
from processing.tools import raster
|
|
||||||
|
|
||||||
pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]
|
|
||||||
|
|
||||||
|
|
||||||
class ReliefAuto(GeoAlgorithm):
|
|
||||||
|
|
||||||
INPUT_LAYER = 'INPUT_LAYER'
|
|
||||||
Z_FACTOR = 'Z_FACTOR'
|
|
||||||
OUTPUT_LAYER = 'OUTPUT_LAYER'
|
|
||||||
FREQUENCY_DISTRIBUTION = 'FREQUENCY_DISTRIBUTION'
|
|
||||||
|
|
||||||
def getIcon(self):
|
|
||||||
return QIcon(os.path.join(pluginPath, 'images', 'dem.png'))
|
|
||||||
|
|
||||||
def defineCharacteristics(self):
|
|
||||||
self.name, self.i18n_name = self.trAlgorithm('Relief (automatic colors)')
|
|
||||||
self.group, self.i18n_group = self.trAlgorithm('Raster terrain analysis')
|
|
||||||
|
|
||||||
self.addParameter(ParameterRaster(self.INPUT_LAYER,
|
|
||||||
self.tr('Elevation layer')))
|
|
||||||
self.addParameter(ParameterNumber(self.Z_FACTOR,
|
|
||||||
self.tr('Z factor'), 1.0, 999999.99, 1.0))
|
|
||||||
self.addOutput(OutputRaster(self.OUTPUT_LAYER,
|
|
||||||
self.tr('Relief')))
|
|
||||||
self.addOutput(OutputTable(self.FREQUENCY_DISTRIBUTION,
|
|
||||||
self.tr('Frequency distribution')))
|
|
||||||
|
|
||||||
def processAlgorithm(self, progress):
|
|
||||||
inputFile = self.getParameterValue(self.INPUT_LAYER)
|
|
||||||
zFactor = self.getParameterValue(self.Z_FACTOR)
|
|
||||||
outputFile = self.getOutputValue(self.OUTPUT_LAYER)
|
|
||||||
frequencyDistribution = self.getOutputValue(self.FREQUENCY_DISTRIBUTION)
|
|
||||||
|
|
||||||
outputFormat = raster.formatShortNameFromFileName(outputFile)
|
|
||||||
|
|
||||||
relief = QgsRelief(inputFile, outputFile, outputFormat)
|
|
||||||
colors = relief.calculateOptimizedReliefClasses()
|
|
||||||
relief.setReliefColors(colors)
|
|
||||||
relief.setZFactor(zFactor)
|
|
||||||
relief.exportFrequencyDistributionToCsv(frequencyDistribution)
|
|
||||||
relief.processRaster(None)
|
|
@ -239,11 +239,11 @@ class ReliefColorsWidget(BASE, WIDGET):
|
|||||||
rColors = self.reliefColors()
|
rColors = self.reliefColors()
|
||||||
colors = ''
|
colors = ''
|
||||||
for c in rColors:
|
for c in rColors:
|
||||||
colors += '{:.2f}, {:.2f}, {:d}, {:d}, {:d};'.format(c.minElevation,
|
colors += '{:f}, {:f}, {:d}, {:d}, {:d};'.format(c.minElevation,
|
||||||
c.maxElevation,
|
c.maxElevation,
|
||||||
c.color.red(),
|
c.color.red(),
|
||||||
c.color.green(),
|
c.color.green(),
|
||||||
c.color.blue())
|
c.color.blue())
|
||||||
return colors[:-1]
|
return colors[:-1]
|
||||||
|
|
||||||
|
|
||||||
|
@ -1153,17 +1153,18 @@ tests:
|
|||||||
name: Relief (custom colors)
|
name: Relief (custom colors)
|
||||||
params:
|
params:
|
||||||
AUTO_COLORS: false
|
AUTO_COLORS: false
|
||||||
COLORS: 85.00, 104.44, 7, 165, 144;104.44, 104.44, 12, 221, 162;104.44, 104.44,
|
COLORS: 85.000000, 104.436508, 7, 165, 144;104.436508, 104.436508, 12, 221, 162;104.436508,
|
||||||
33, 252, 183;104.44, 104.44, 247, 252, 152;104.44, 104.44, 252, 196, 8;104.44,
|
104.436508, 33, 252, 183;104.436508, 104.436508, 247, 252, 152;104.436508, 104.436508,
|
||||||
190.33, 252, 166, 15;190.33, 226.70, 175, 101, 15;226.70, 226.70, 255, 133,
|
252, 196, 8;104.436508, 190.333333, 252, 166, 15;190.333333, 226.698413, 175,
|
||||||
92;226.70, 243.00, 204, 204, 204
|
101, 15;226.698413, 226.698413, 255, 133, 92;226.698413, 243.000000, 204, 204,
|
||||||
|
204
|
||||||
INPUT_LAYER:
|
INPUT_LAYER:
|
||||||
name: dem.tif
|
name: dem.tif
|
||||||
type: raster
|
type: raster
|
||||||
Z_FACTOR: 1.0
|
Z_FACTOR: 1.0
|
||||||
results:
|
results:
|
||||||
OUTPUT_LAYER:
|
OUTPUT_LAYER:
|
||||||
hash: 6c79ec9b948c8e878aa490670e8a26a0b6efc5f9d162a0fff1042d80
|
hash: 7fe0e0174185fd743e23760f33615adf10f771b4275f320db6f7f4f8
|
||||||
type: rasterhash
|
type: rasterhash
|
||||||
|
|
||||||
# Case 1: Keep all fields
|
# Case 1: Keep all fields
|
||||||
|
Loading…
x
Reference in New Issue
Block a user