Display of Geospatial raster in R

Let’s load an image from a Sentinel satellite that contains 4 spectral bands. Saving the file is described in the previous post.

First, display a band with:

The raster is displayed in the default color palette on the Plots tab of RStudio.

raster2_1

To display the raster in grayscale, the col attribute must be added to the plot function:

gray.colors() is a palette of grays, and the number 255 indicates the number of shades.

raster2_2

To plot the raster in the color composition, you can use the plotRGB(x, r, g, b, stretch) function, where x – the name of the variable with the multicband raster, r – the number of a single raster for the R band, g – the number of a single raster for the G band, B – the number of a single raster for the B band, stretch – for images with radiometric resolution above 8 bits, it is necessary to degrade this resolution by defining the type of post-processing). For more information, see the description of the plotRGB function.

After executing the function we see the composition in real colors:

raster2_3

Leave a Reply

Your email address will not be published.

Translate using Google Translate»
Social media & sharing icons powered by UltimatelySocial

Podoba Ci się nasza strona? Odwiedź nasz profil