2

I have a RasterLayer with 500 bands in R (I exported the raster as a single image in Google Earth Engine, which was originally an ImageCollection). I know you can extract the band you want to use by number:

raster("raster.tif", band = 1)
raster("raster.tif", band = 2)
# etc.

But I was wondering if there was a way to call the band by its name instead in R.

1
  • 3
    Are the band names even stored in the GeoTIFF? Does gdalinfo("raster.tif") using the gdalUtils package show them anywhere? If not, I think you are stuck unless you have a list of the names from somewhere else, otherwise you need to extract them from the gdalinfo metadata and lookup the band number to pass to raster(...)
    – Spacedman
    May 7, 2020 at 8:36

1 Answer 1

0

It doesn't help you with your currently downloaded file, but the ability to select by band name is included in the rgee package. https://csaybar.github.io/rgee/

1
  • Thanks, I will check out the package!
    – rachell
    May 7, 2020 at 17:54

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.