I am trying to load multiple rasters (87 in total) into R for analysis. The rasters are being loaded direct to a stack using this code:
filelist <- list.files(path="mypath", pattern="tif$", full.names=TRUE)
stk1 <- raster::stack(filelist)
The data largely load correctly apart from 9 problematic bands that seem to have the same issue. These bad bands are loading with 'attributes'. See example below
goodband
> goodband
class : RasterLayer
dimensions : 1768, 3674, 6495632 (nrow, ncol, ncell)
resolution : 40, 40 (x, y)
extent : 135800.4, 282760.4, 22297.69, 93017.69 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894
data source : goodband.tif
names : Good
values : 0.5, 36 (min, max)
badband
> badband
class : RasterLayer
dimensions : 1768, 3674, 6495632 (nrow, ncol, ncell)
resolution : 40, 40 (x, y)
extent : 135800.4, 282760.4, 22297.69, 93017.69 (xmin, xmax, ymin, ymax)
coord. ref. : +proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +datum=OSGB36 +units=m +no_defs +ellps=airy +towgs84=446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894
data source : badband.tif
names : Bad
values : 33, 6824 (min, max)
attributes :
ID OID Value Count
from: 0 0 33 433
to : 529 529 6824 1307
As you can see the badband has additional 'attributes' at the bottom. When trying to analyse bad bands they are just full of null values and don't operate like the good bands.
Could you advise how best to fix this problem?