31 votes
Accepted

Using Rasterio or GDAL to stack multiple bands without using subprocess commands

Using rasterio you could do import rasterio file_list = ['file1.tif', 'file2.tif', 'file3.tif'] # Read metadata of first file with rasterio.open(file_list[0]) as src0: meta = src0.meta # ...
user avatar
15 votes

Using Rasterio or GDAL to stack multiple bands without using subprocess commands

If using GDAL 2.1+ it's as simple as gdal.BuildVRT then gdal.Translate: from osgeo import gdal outvrt = '/vsimem/stacked.vrt' #/vsimem is special in-memory virtual "directory" outtif = '/tmp/stacked....
user avatar
  • 53.3k
15 votes
Accepted

Multiband to single band raster

You could use gdal_translate from the new workflow, which is under: Raster > Conversion > Rearrange bands... You won't be able to select the pencil as in the past, but you can select only the ...
user avatar
  • 72.5k
12 votes
Accepted

Setting NoData for a multiband raster?

What you want to do is Set Raster Properties in a script or change it manually in ArcCatalog. This will not create a new raster or even take very long. In python it's a bit tricky: import sys, os, ...
user avatar
12 votes
Accepted

How to edit the metadata for individual bands of a multiband raster, preferably with GDAL?

You can use a simple python script that uses the Band.SetDescription method to set the band names: """ Set Band descriptions Usage: python set_band_desc.py /path/to/file.ext band desc [band desc.....
user avatar
  • 53.3k
9 votes
Accepted

Extracting 5 bands geotiff file into RGB file using GDAL?

Your values aren't in 0,255 since they are UInt16. You can try rescaling to 0,255 (GDAL works it out by default from input min/max and output default 0,255): gdal_translate -b 1 -b 2 -b 3 -mask "...
user avatar
  • 7,907
8 votes

How to use gdal_calc.py for multi-band images?

To calculate a grey-scale from the same input file using different bands u can open the file multiple times and define the band which you want to use with --A_band=n. See my example for calculating ...
user avatar
  • 647
8 votes
Accepted

Save multiband raster with gdal

i've found a way using a gdal object supported by numpy arrays.. import gdal import numpy as np from affine import Affine def save_multiband (output_name, dataset, raster_data, driver, ...
user avatar
8 votes
Accepted

Converting 4-band TIF to PNG while keeping all 4 bands?

This is a limitation of the PNG format. It only has 3 information channels (RGB), so one of your bands will be suppressed. If you really need to, you can save your NIR band as an alpha channel, but ...
user avatar
8 votes
Accepted

How to visualize multiband imagery using rasterio?

The Rasterio Plotting documentation describes how to visualize multiband imagery. For example, using 4-band NAIP imagery: import rasterio from rasterio.plot import show src = rasterio.open("path/to/...
user avatar
  • 50.4k
7 votes

Layer stacking rasters in QGIS?

Geoprocessing was moved to processing toolbar in QGIS 2.16, as you can see below:
user avatar
  • 36.5k
6 votes
Accepted

Is atmospheric correction necessary when working with multi-spectral indexes?

It depends upon the intended use of the Landsat data. Generally speaking, if you are doing multi-temporal analyses, you need atmospherically corrected data, otherwise DN format is sufficient. I would ...
user avatar
  • 50.4k
6 votes
Accepted

Viewing bands of landsat 8 images in QGIS for NDVI calculation?

You have downloaded the data and you can find it if you unpack the .tar.gz file using 7zip or similar software for unpacking files. The .tar.gz file is the fourth file from the top that can be seen in ...
user avatar
6 votes

Getting multiband raster's min and max values with Python in QGIS?

Next code works with multi band raster. It uses QgsRasterDataProvider objects to calculate statistic through QgsRasterBandStats objects. layer = iface.activeLayer() extent = layer.extent() provider ...
user avatar
  • 26.9k
6 votes
Accepted

Displaying single band from multi-band raster using QGIS

This is a display issue: you want to display a continuous band using categories. You do not need to split your image to create a new new image: this can be done directly on the multiple band image, ...
user avatar
  • 48.7k
6 votes

Sum over Bands, Google Earth Engine

Here is another approach: // Make a (toy) 3 bands image var image = ee.Image([1,2,3]).rename(['one', 'two', 'three']) Map.addLayer(image, null, '3 bands image') // Sum all bands var sum_bands = ...
user avatar
5 votes
Accepted

Using multiband images in ArcGIS Raster Calculator?

You need to use each single band as an image to do raster calculator in ArcGIS. Raster calculator cannot give you access to the multiple bands composited into a one image. However, you can access each ...
user avatar
  • 36.5k
5 votes
Accepted

Is it possible to read in specific bands from a multi-band raster with gdal or rasterio?

You can read specific bands in a single call using rasterio by passing a list/tuple of band numbers (Following the GDAL convention, bands are indexed from 1): import rasterio rasterio.__version__ '1....
user avatar
  • 53.3k
5 votes
Accepted

NIR, R, G, B multiband (4 Band) GeoTIFF gdal_translate colorinterp issues

Using the creation option -co "ALPHA=NO" param in the gdal_translate command prevented the 4th band being set as alpha (its set as undefined now) which solved the issue. This solution was found here:...
user avatar
  • 295
5 votes

Converting 4-band TIF to PNG while keeping all 4 bands?

I will just answer my own question here, if anyone runs into the same problem with multiband images and TensorFlow. I ended up using Keras on top of TensorFlow and instead of feeding the image files ...
user avatar
  • 400
4 votes

How to check for corrupted raster data?

Building on FelixIP's answer, the following method checks for 1) zero values in a 200x200m area located at the center of the image and 2) corrupt rasters that will not read. The bad files are added ...
user avatar
  • 50.4k
4 votes
Accepted

NDVI from Landsat8 LandsatLook images

You will not be able to generate the NDVI from Landsat Look images. These are generated from the visible bands to "simulate natural color" In order to get the image with all bands, including red and ...
user avatar
  • 9,500
4 votes
Accepted

Difference between a spectroradiometer and multispectral sensor

According to NASA, a spectral radiometer is a multispectral sensor. Spectroradiometer—A radiometer that measures the intensity of radiation in multiple wavelength bands (i.e., multispectral). Many ...
user avatar
  • 417
4 votes
Accepted

How does ArcGIS calculate zonal statistics with multi-band rasters?

With a multi-band raster input, ArcGIS will only process the first band: Multiband raster data When a multiband raster is used as input, most Spatial Analyst tools operate only on the first ...
user avatar
  • 53.3k
4 votes
Accepted

Retrieve single band from multiband raster served by Geoserver

From the GeoServer user manual: <RasterSymbolizer> <Opacity>1.0</Opacity> <ChannelSelection> <GrayChannel> <SourceChannelName&...
user avatar
  • 15.8k
4 votes
Accepted

Convert a multiband raster to a polygon in qgis

I just figured it out... Use Raster Calculator: band@1 * 0 + band@2 * 0 + band@3 * 0 Then will get a raster of two values, then vectorizing this raster will only take a second.
user avatar
  • 1,356
4 votes

Process of Radiometric Calibration

With more than one calibration target, you can estimate the relationship between your measurement and the albedo/reflectance with a linear regression. If you have only one calibration target, you ...
user avatar
  • 48.7k
4 votes
Accepted

Build reflectance maps with Python and GDAL

This is a non-trivial problem. One solution is to collect ground reflectance spectra coincident with the time of UAV flight. The reference spectra may consist of white, grey and black panels that are ...
user avatar
  • 805
4 votes
Accepted

Get colortable from three-band RGB raster (brick) with R

There's a function in rgdal for this SGDF2PCT, so here I coerce to SpatialGridDataFrame, build the colour table and rebuild the raster. Note that indexing in raster is assuming [0, 255]. Control ...
user avatar
  • 7,907
4 votes
Accepted

Open a mutliband raster, edit values in one of the bands, and overwrite the raster using Python/Rasterio?

You can write to selected bands using the indexes keyword. If you want your array to contain only zeros you can also create a new numpy array. This way you don't need to read any data at all. ...
user avatar
  • 1,187

Only top scored, non community-wiki answers of a minimum length are eligible