I have a .dat file (ENVI format) with specific band names, as you can see in the snapshot.

ENVI snapshot

I've imported this file in R, but I cannot find the band names in the R object. The command


gives this output

[1] "old_min_identification_VI_smooth_2010.1"  "old_min_identification_VI_smooth_2010.2" 
 [3] "old_min_identification_VI_smooth_2010.3"  "old_min_identification_VI_smooth_2010.4" 
 [5] "old_min_identification_VI_smooth_2010.5"  "old_min_identification_VI_smooth_2010.6" 

that is not correspondent to the band names of the .dat file as I can see in ENVI.

Any ideas to get this information fro the R object?

I've imported the .dat as a RasterStack object.

  • Band names are a tricky thing :( Related: stackoverflow.com/questions/26763013/…
    – Iris
    Oct 28, 2015 at 12:36
  • Do you have a .hdr with the .dat file?
    – Iris
    Oct 28, 2015 at 12:36
  • @Iris yes I have the .hdr. All the band names are stored there.
    – FraNut
    Oct 28, 2015 at 13:32
  • 2
    I think it is easiest to copy the band names from the hdr file and rename the band names of the rasterstack afterwards using names(stack_NDVI) <- c('a','b','c')
    – Iris
    Oct 28, 2015 at 13:36
  • Smart hint. If you will make an "official" answer I will upvote you :-)
    – FraNut
    Oct 28, 2015 at 13:48

1 Answer 1


I had the troubles myself and couldn't find a solution. To export and import rasters between ENVI and R and keep the band names seems impossible (cf. this related question).

A workaround is to copy the band_names from the .hdr file and rename the band names from the imported rasterstack.

band names = {a,b,c} copied from file.hdr

image <- stack("file.dat") 
band_names = c('a','b','c')
names(image) <- band_names
  • cannot upvote because I need 15 points of reputation...
    – FraNut
    Oct 28, 2015 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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