Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You probably just need to do</p> <pre><code>image( df.gtiff , col = rep( "cornflowerblue" , ncell(df.gtiff) ) ) </code></pre> <p>But in case that doesn't work, here are some worked examples:</p> <pre><code>require( raster ) # Observe difference between a brick and a raster logoB &lt;- brick(system.file("external/rlogo.grd", package="raster")) logoR &lt;- raster(system.file("external/rlogo.grd", package="raster")) # Use a brick and plotRGB to get intended colours (image uses heat.colors) par(mfrow=c(1,2)) image( logoR , axes = FALSE , labels = FALSE ) plotRGB( logoB ) </code></pre> <p><img src="https://i.stack.imgur.com/7KlIn.png" alt="enter image description here"></p> <pre><code># To manually mask and colour to a single value: # This file doesn't have NA values so setting e.g. plot( logoR , col = "blue" ) won't work... # Example of cell values for background colour logoB[1] red green blue [1,] 255 255 255 # Make binary mask with some threshold of 'close to white' or 'close to black' values newLogo &lt;- calc( logoB , function(x) sum( x ) &lt; 725 + 0 | sum( x ) &lt; 50 + 0 ) # Then plot, supplying a colour for each binary level plot(newLogo , col = c( "white" , "cornflowerblue" ) , main = "binary mask" ) </code></pre> <p><img src="https://i.stack.imgur.com/gmCEG.png" alt="enter image description here"></p> <pre><code># If your file has background cells set to NA you can just plot directly setting the colour equal to number of cells in raster: require(maptools) r &lt;- raster(system.file("external/test.grd", package="raster")) image( r , col = rep("cornflowerblue" , ncell(r)) , axes = FALSE ) </code></pre> <p><img src="https://i.stack.imgur.com/saWjL.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload