Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
LETG
Rename bands
Commits
fc4681c0
Commit
fc4681c0
authored
Sep 10, 2021
by
PIERSON Julie
Browse files
removing output since raster gets modified in place
parent
0e07d282
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
21 deletions
+1
-21
rename_bands_algorithm.py
rename_bands_algorithm.py
+1
-21
No files found.
rename_bands_algorithm.py
View file @
fc4681c0
...
...
@@ -82,14 +82,6 @@ class RenameBandsAlgorithm(QgsProcessingAlgorithm):
)
)
# TODO
# output raster layer
self
.
addParameter
(
QgsProcessingParameterRasterDestination
(
'OUTPUT'
,
self
.
tr
(
'Raster output'
)
)
)
def
processAlgorithm
(
self
,
parameters
,
context
,
feedback
):
"""
...
...
@@ -99,7 +91,6 @@ class RenameBandsAlgorithm(QgsProcessingAlgorithm):
# Retrieve inputs and outputs
input_raster
=
self
.
parameterAsRasterLayer
(
parameters
,
self
.
INPUT
,
context
)
band_table
=
self
.
parameterAsMatrix
(
parameters
,
self
.
TABLE
,
context
)
output_path_raster
=
self
.
parameterAsOutputLayer
(
parameters
,
self
.
OUTPUT
,
context
)
# get input raster path
raster_path
=
input_raster
.
source
()
...
...
@@ -118,20 +109,9 @@ class RenameBandsAlgorithm(QgsProcessingAlgorithm):
for
band_number
in
range
(
nbands
):
band
=
raster_gdal
.
GetRasterBand
(
band_number
+
1
)
band
.
SetDescription
(
band_table
[
band_number
][
0
])
# running gdal:translate processing algorithm
param_translate
=
{
'INPUT'
:
input_raster
,
'TARGET_CRS'
:
None
,
'NODATA'
:
None
,
'COPY_SUBDATASETS'
:
False
,
'OPTIONS'
:
''
,
'EXTRA'
:
''
,
'DATA_TYPE'
:
0
,
'OUTPUT'
:
output_path_raster
}
processing
.
run
(
"gdal:translate"
,
param_translate
)
# Return the results of the algorithm as a dictionary
return
{
self
.
OUTPUT
:
output_path_raster
,
'matrix'
:
band_table
}
return
{}
def
name
(
self
):
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment