I'have a raster image from Scran25 IGN. In Qgis, it opens perfectly but in R (with rgdal or raster packages), I do not know how to keep the original colors like this exemple?

IGN scan25 from Banyuls

I have tried


communes<-readOGR(dsn = "./Banyuls//MyCreate/Surface_4communes/",layer = "4communesAOC")



And the result is IGN scan25 import in R with bad colors

  • 2
    Show some code! Use ?brick and ?plotRGB. We can only guess what your actual problem is – mdsumner Jun 22 '14 at 12:00
  • I have write some news thing... scan25, I believe, is a "one band" raster. I do not understand how the past has three band? Is it needed? – delaye Jun 22 '14 at 13:37
  • 1
    You are using the raster() function which is only intended for single band rasters. If you use stack() or brick() then your three RGB bands will be in the resulting raster class object. You will still need plotRGB to display the composite image. – Jeffrey Evans Jun 22 '14 at 16:24
  • We need to what raster source is referenced by thay VRT. It may be rgb or palette but no point in us guessing. – mdsumner Jun 22 '14 at 23:12
  • Could you post the content of scan25@legend@colortable? – Oscar Perpiñán Jun 23 '14 at 7:55

Very simple:

#load the raster as a stack so all channels are included
#then plot it an RGB raster
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.