-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefineNullCell.py
241 lines (208 loc) · 24.2 KB
/
defineNullCell.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# -*- coding: utf-8 -*-
"""
defineNullCell.py
***************************************************************************
* *
* 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__ = 'Leandro França'
__date__ = '2020-11-22'
__copyright__ = '(C) 2020, Leandro França'
from PyQt5.QtCore import QCoreApplication, QVariant
from qgis.core import (QgsProcessing,
QgsFeatureSink,
QgsWkbTypes,
QgsFields,
QgsField,
QgsFeature,
QgsPointXY,
QgsGeometry,
QgsProcessingException,
QgsProcessingAlgorithm,
QgsProcessingParameterString,
QgsProcessingParameterNumber,
QgsProcessingParameterField,
QgsProcessingParameterBoolean,
QgsProcessingParameterCrs,
QgsProcessingParameterEnum,
QgsFeatureRequest,
QgsExpression,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterFeatureSink,
QgsProcessingParameterFileDestination,
QgsProcessingParameterMultipleLayers,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterRasterDestination,
QgsApplication,
QgsProject,
QgsRasterLayer,
QgsCoordinateTransform,
QgsCoordinateReferenceSystem)
import gdal
from osgeo import osr, gdal_array
from math import floor, ceil
import numpy as np
class DefineNullCell(QgsProcessingAlgorithm):
LOC = QgsApplication.locale()
def translate(self, string):
return QCoreApplication.translate('Processing', string)
def tr(self, *string):
# Traduzir para o portugês: arg[0] - english (translate), arg[1] - português
if self.LOC == 'pt':
if len(string) == 2:
return string[1]
else:
return self.translate(string[0])
else:
return self.translate(string[0])
def createInstance(self):
return DefineNullCell()
def name(self):
return 'definenullcell'
def displayName(self):
return self.tr('Define null cells', 'Definir pixel nulo')
def group(self):
return self.tr('LF Raster')
def groupId(self):
return 'lf_raster'
def shortHelpString(self):
txt_en = 'Cells of a raster with values outside the interval (minimum and maximum) are defined as null value.'
txt_pt = 'As células do raster com valores fora do intervalo (mínimo e máximo) são definidas como valor nulo.'
dic_BW = {'face': 'iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAMMwAADDMBUlqVhwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAIUSURBVEiJvZa9quJAGIbfMfEYTUSUQAqLYOnehJobsBTlHLbRQtKKlY3lObegxRa7pRdg7y0saiuoKAErMZif2Squ2eTEOCfsC1Pk+3uYb2YyQwCg1+u9UUqHAKoAOCQrB8ASwPt0Ov1JdF3/bprmj4QhoXp5eXnjTdMcUEr/Bw+WZQ15Smn1q4UIIZBlGaIoghBys2+3W1yv19u367rfeAAc6ww5jkOz2USj0YAoigH/aDTCbrfzpfCUUrAC2+02NE2LjPm3NjNQkiTU6/WHsFAgi1RVRSqVCthd171BwmozA/P5fMA2n88xm81g2zYAwHGccCAL9H43elosFrhcLpE5zMCwHMdxImtRSp8DptNpZDIZAIAgCAG/IAi+42Ga5q29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u5313U/2bZdvhr0F9Fo9phaoDu9AAAAAElFTkSuQmCC'}
footer = '''<div align="right">
<p align="right"><b>'''+self.tr('Author: Leandro Franca', 'Autor: Leandro França')+'''</b></p>
<div align="right">
<a target="_blank" rel="noopener noreferrer" href="https://www.udemy.com/user/leandro-luiz-silva-de-franca/"><img title="Udemy" src="data:image/png;base64,'''+dic_BW['udemy']+'''"></a> <a target="_blank" rel="noopener noreferrer" href="https://www.facebook.com/GEOCAPT/"><img title="Facebook" src="data:image/png;base64,'''+dic_BW['face']+'''"></a> <a target="_blank" rel="noopener noreferrer" href="https://www.youtube.com/channel/UCLrewDGciytcBG9r0OxTW2w"><img title="Youtube" src="data:image/png;base64,'''+dic_BW['youtube']+'''"></a> <a target="_blank" rel="noopener noreferrer" href="https://www.researchgate.net/profile/Leandro_Franca2"><img title="ResearchGate" src="data:image/png;base64,'''+dic_BW['RG']+'''"></a> <a target="_blank" rel="noopener noreferrer" href="https://github.com/LEOXINGU"><img title="GitHub" src="data:image/png;base64,'''+dic_BW['github']+'''"></a> <a target="_blank" rel="noopener noreferrer" href="https://www.linkedin.com/in/leandro-fran%C3%A7a-93093714b/"><img title="Linkedin" src="data:image/png;base64,'''+dic_BW['linkedin']+'''"></a> <a target="_blank" rel="noopener noreferrer" href="http://lattes.cnpq.br/8559852745183879"><img title="Lattes" src="data:image/png;base64,'''+dic_BW['lattes']+'''"></a>
</div>
</div>'''
return self.tr(txt_en, txt_pt) + footer
RasterIN ='RasterIN'
MIN = 'MIN'
MAX = 'MAX'
NULLVALUE = 'NULLVALUE'
RasterOUT = 'RasterOUT'
OPEN = 'OPEN'
def initAlgorithm(self, config=None):
# INPUT
self.addParameter(
QgsProcessingParameterRasterLayer(
self.RasterIN,
self.tr('Input Raster', 'Raster de Entrada'),
[QgsProcessing.TypeRaster]
)
)
self.addParameter(
QgsProcessingParameterNumber(
self.MIN,
self.tr('Minimum Value', 'Valor mínimo'),
type = 1,
defaultValue = 1
)
)
self.addParameter(
QgsProcessingParameterNumber(
self.MAX,
self.tr('Maximum Value', 'Valor máximo'),
type = 1,
defaultValue = 2**16-1
)
)
self.addParameter(
QgsProcessingParameterNumber(
self.NULLVALUE,
self.tr('Value for defining null cells', 'Valor para definir os pixels nulos'),
type = 1,
defaultValue = 0
)
)
self.addParameter(
QgsProcessingParameterBoolean(
self.OPEN,
self.tr('Load output raster', 'Carregar imagem de saída'),
defaultValue= True
)
)
# OUTPUT
self.addParameter(
QgsProcessingParameterFileDestination(
self.RasterOUT,
self.tr('Raster with null cells defined', 'Raster com pixels nulos definidos'),
fileFilter = '.tif'
)
)
def processAlgorithm(self, parameters, context, feedback):
RasterIN = self.parameterAsRasterLayer(
parameters,
self.RasterIN,
context
)
if RasterIN is None:
raise QgsProcessingException(self.invalidSourceError(parameters, self.RasterIN))
RasterIN = RasterIN.dataProvider().dataSourceUri()
RGB_Output = self.parameterAsFileOutput(
parameters,
self.RasterOUT,
context
)
Carregar = self.parameterAsBool(
parameters,
self.OPEN,
context
)
MIN = self.parameterAsDouble(
parameters,
self.MIN,
context
)
MAX = self.parameterAsDouble(
parameters,
self.MAX,
context
)
Pixel_Nulo = self.parameterAsDouble(
parameters,
self.NULLVALUE,
context
)
if MAX < MIN or (Pixel_Nulo>MIN and Pixel_Nulo<MAX):
raise QgsProcessingException(self.tr('Problem in input parameters interval!', 'Problema no intervalo dos parâmetros de entrada!'))
else:
image = gdal.Open(RasterIN) # https://gdal.org/python/
prj=image.GetProjection()
geotransform = image.GetGeoTransform()
GDT = image.GetRasterBand(1).DataType
n_bands = image.RasterCount
cols = image.RasterXSize # Number of columns
rows = image.RasterYSize # Number of rows
# Create CRS object
CRS=osr.SpatialReference(wkt=prj)
# Criate driver
Driver = gdal.GetDriverByName('GTiff').Create(RGB_Output, cols, rows, n_bands, GDT)
Driver.SetGeoTransform(geotransform) # specify coords
Driver.SetProjection(CRS.ExportToWkt()) # export coords to file
for k in range(n_bands):
band = image.GetRasterBand(k+1).ReadAsArray()
# Defining null pixels
band = ((band>=MIN)*(band<=MAX))*band + ((band<MIN)*(band>MAX))*Pixel_Nulo
outband = Driver.GetRasterBand(k+1)
feedback.pushInfo(self.tr('Writing Band {}...'.format(k+1), 'Escrevendo Banda {}...'.format(k+1)))
outband.WriteArray(band) # write band to the raster
outband.SetNoDataValue(Pixel_Nulo)
image=None # Close dataset
Driver.FlushCache() # write to disk
Driver = None # save, close
feedback.pushInfo(self.tr('Operation completed successfully!', 'Operação finalizada com sucesso!'))
feedback.pushInfo('Leandro França - Eng Cart')
self.CAMINHO = RGB_Output
self.CARREGAR = Carregar
return {self.RasterOUT: RGB_Output}
def postProcessAlgorithm(self, context, feedback):
if self.CARREGAR:
rlayer = QgsRasterLayer(self.CAMINHO, self.tr('Raster with defined null cells', 'Raster com pixels nulos definidos'))
QgsProject.instance().addMapLayer(rlayer)
return {}