Split stack

From AWF-Wiki
(Difference between revisions)
Jump to: navigation, search
(Using OTB SplitImage)
(Using OTB SplitImage)
 
(16 intermediate revisions by one user not shown)
Line 1: Line 1:
 
=Using OTB SplitImage=
 
=Using OTB SplitImage=
# Click the {{button|text=Open Data Source Manager}} [[Image:QGIS_3.0_datasource.png|30px]] and then {{button|text=Add raster layer}} [[Image:QGIS_2.0_addrast.png|20px]] and select the file ''/geodata/raster/s2/Subset_S2A_MSIL2A_20170619T_MUL.tif''.
+
# Click the {{button|text=Open Data Source Manager}} [[Image:QGIS_3.0_datasource.png|30px]] and then {{button|text=Add raster layer}} [[Image:QGIS_2.0_addrast.png|20px]] and select  a multiband raster file.
 
# In  processing toolbox, type {{typed|text=split image}} into the search field to find the {{button|text=OTB --> Image Manipulation --> SplitImage}} tool and open it.
 
# In  processing toolbox, type {{typed|text=split image}} into the search field to find the {{button|text=OTB --> Image Manipulation --> SplitImage}} tool and open it.
[[File:qgis-otb-splitimage.png|400px]]
+
[[File:qgis-otb-splitimage.png|500px]]
The ''Output pixel type'' is {{typed|text=float}}. (Note, the option {{typed|text=int}} does currently not work!).
+
 
Choose an output file name: {{button|text=Save to file}}. {{button|text=Run in background}}.
+
Choose the same ''Output pixel type'' like the input pixel type: here it is {{typed|text=uint16}}.
The resulting single band files need to be loaded manually into the map canvas.
+
 
 +
'''Important''': choose a physical output file: {{button|text=Save to file}}. Specify a file name with the extension '''.tif'''
 +
Uncheck "Open output file after running algorithm". Open the output files manually in QGIS.
  
 
=Using GDAL Translate=
 
=Using GDAL Translate=
# Click the {{button|text=Open Data Source Manager}} [[Image:QGIS_3.0_datasource.png|30px]] and then {{button|text=Add raster layer}} [[Image:QGIS_2.0_addrast.png|20px]] and select the file  ''/geodata/raster/s2/Subset_S2A_MSIL2A_20170619T_MUL.tif''.
+
* In the processing toolbar, type {{typed|text=Translate}} into the search field to find the {{button|text=GDAL\OGR --> Translate (Convert format)}} tool and open it.
# In the processing toolbar, type {{typed|text=Translate}} into the search field to find the {{button|text=GDAL\OGR --> Translate (Convert format)}} tool and open it.
+
* Change the output data format to unsigned 16bit integer): {{typed|text=-ot UInt16}}
** Unfold the '''Advanced parameters''' and change the output data format to unsigned 16bit integer): {{typed|text=-ot UInt16}}
+
* Click the button {{button|text=...}} of '''Converted''' to select path and name of output file.
** Click the button {{button|text=...}} of '''Converted''' to select path and name of output file.
+
 
** Type in the textbox '''Additional creation parameters''': {{typed|text=-b 1}}
+
( This selects only the first band).
+
** Click {{button|text=Run}}.
+
 
[[File:Qgis_split_stack.png|600px]]
 
[[File:Qgis_split_stack.png|600px]]
** Repeat the steps for other bands: change the name of the output file and edit the -b option accordingly.
 
  
# Create a multiband file with a spectral subset of 4 bands. Change the output file and the additional creation options:  
+
* Open the the OSGEO4W Shell. {{mitem|text=Start --> All Programs --> OSGeo4W --> OSGeo4W Shell}}
** '''Converted''' output file:{{typed|text=Subset_S2A_MSIL2A_20170619T_B02030408.tif}}
+
* Copy the content of the ''GDL/OGR console call'' and paste it into the OSGeo4W Shell.
 +
* Edit the command in OSGeo4W Shell by adding the option {{typed|text=-b 1}} to output only the first band.
 +
* Press {{button|text=Enter}} to execute the command in OSGeo4W Shell.
 +
 
 +
* Repeat the steps for other bands: change the output file name and edit the -b option accordingly.
 +
 
 +
* Create a multiband file with a spectral subset of 4 bands. Change the output file name and edit the command in OSGeo4W Shell additional creation options:  
 +
**'''Converted''' output file:{{typed|text=Subset_S2A_MSIL2A_20170619T_B02-
 +
-B03-B04-B08.tif}}
 
** '''Additional creation parameters:''' {{typed|text=-b 2 -b 3 -b 4 -b 8}}
 
** '''Additional creation parameters:''' {{typed|text=-b 2 -b 3 -b 4 -b 8}}
** Click {{button|text=Run}}.
+
** Press {{button|text=Enter}} to execute the command in OSGeo4W Shell.
  
 
[[Category:Working with Raster Data]]
 
[[Category:Working with Raster Data]]

Latest revision as of 11:56, 23 May 2022

[edit] Using OTB SplitImage

  1. Click the Open Data Source Manager QGIS 3.0 datasource.png and then Add raster layer QGIS 2.0 addrast.png and select a multiband raster file.
  2. In processing toolbox, type split image into the search field to find the OTB --> Image Manipulation --> SplitImage tool and open it.

Qgis-otb-splitimage.png

Choose the same Output pixel type like the input pixel type: here it is uint16.

Important: choose a physical output file: Save to file. Specify a file name with the extension .tif Uncheck "Open output file after running algorithm". Open the output files manually in QGIS.

[edit] Using GDAL Translate

  • In the processing toolbar, type Translate into the search field to find the GDAL\OGR --> Translate (Convert format) tool and open it.
  • Change the output data format to unsigned 16bit integer): -ot UInt16
  • Click the button ... of Converted to select path and name of output file.

Qgis split stack.png

  • Open the the OSGEO4W Shell. Start --> All Programs --> OSGeo4W --> OSGeo4W Shell
  • Copy the content of the GDL/OGR console call and paste it into the OSGeo4W Shell.
  • Edit the command in OSGeo4W Shell by adding the option -b 1 to output only the first band.
  • Press Enter to execute the command in OSGeo4W Shell.
  • Repeat the steps for other bands: change the output file name and edit the -b option accordingly.
  • Create a multiband file with a spectral subset of 4 bands. Change the output file name and edit the command in OSGeo4W Shell additional creation options:
    • Converted output file:Subset_S2A_MSIL2A_20170619T_B02-

-B03-B04-B08.tif

    • Additional creation parameters: -b 2 -b 3 -b 4 -b 8
    • Press Enter to execute the command in OSGeo4W Shell.
Personal tools
Namespaces

Variants
Actions
Navigation
Development
Toolbox
Print/export