setwd("/media/user/MUSIC/nishinoshima") dir<-c("LC81050412013310LGN00","LC81050412013358LGN00","LC81050412014089LGN00","LC81050412014185LGN00", "LC81050412014281LGN00","LC81050412014297LGN00","LC81050412014329LGN00","LC81050412015044LGN00", "LC81050412015060LGN00","LC81050412015092LGN00","LC81050412015156LGN00","LC81050412015172LGN00", "LC81050412015188LGN00","LC81050412015204LGN00","LC81050412015236LGN00") fname0<-"nishinoshima" for (i in 1:15){ product <- dir[i] Crop<-c(485700,491000,3011000,3016000) meta<-read.meta(product) date<-meta$date_acquired fname<-paste0(fname0,substr(date,1,4),substr(date,6,7),substr(date,9,10)) OLI<-stack(c(aerosol=paste0(product,"/",product, "_B1.TIF"),blue=paste0(product,"/",product, "_B2.TIF"), green=paste0(product,"/",product, "_B3.TIF"),red=paste0(product,"/",product, "_B4.TIF"), nir=paste0(product,"/",product, "_B5.TIF"),swir1=paste0(product,"/",product, "_B6.TIF"), swir2=paste0(product,"/",product, "_B7.TIF"),cirrus=paste0(product,"/",product, "_B9.TIF"))) PAN <-stack(paste0(product,"/",product, "_B8.TIF")) names(PAN)<-"panchromatic" TIRS<-stack(c(tirs1=paste0(product,"/",product, "_B10.TIF"),tirs2=paste0(product,"/",product, "_B11.TIF"))) subOLI <- crop(OLI,Crop) subPAN <- crop(PAN,Crop) subTIRS <- crop(TIRS,Crop) bands=c(unstack(subOLI)[1:7],unstack(subPAN),unstack(subOLI)[8],unstack(subTIRS)) l<-list(metadata = meta, band = bands) names(l$band)<-c("aerosol","blue", "green", "red","nir","swir1","swir2","panchromatic","cirrus","tirs1","tirs2") RGBpan <- panSharpen(stack(l$band[2:4]),l$band$panchromatic,r=3,g=2,b=1) png(paste0(fname,"_1.png"),width=1200,height=1000) par(mfrow=c(1,2)) plotRGB(RGBpan,r = 3, g = 2, b = 1,stretch = "hist") text((Crop[1]+Crop[2])/2,Crop[4],"Pan-sharpened(method:brovey stretch:hist)",pos=3, cex=1.5) plotRGB(RGBpan,r = 3, g = 2, b = 1,stretch = "lin") text((Crop[1]+Crop[2])/2,Crop[4],"Pan-sharpened(method:brovey stretch:lin)",pos=3, cex=1.5) par(mfrow=c(1,1)) dev.off() btemp <- ToAtSatelliteBrightnessTemperature(l, band="tirs1") SST <- btemp - 273.15 temperature<-radiocorr(landsat8=l, band="swir2",method="DOS4") png(paste0(fname,"_2.png"),width=1200,height=1000) par(mfrow=c(1,2)) plot(l$band$panchromatic, col = gray.colors(30),legend=FALSE, axes=FALSE,box=FALSE) breakpoints <- seq(10,80,2) plot(SST,col=blue2green2red(length(breakpoints)),legend=F,axes=FALSE,box=FALSE,alpha=0.5,add=T,breaks=breakpoints) plot(SST, legend.only=TRUE,col=blue2green2red(length(breakpoints)), legend.width=1, legend.shrink=0.5,,breaks=breakpoints, axis.args=list(at=seq(10,80,5), labels=seq(10,80,5), cex.axis=1)) text((Crop[1]+Crop[2])/2,Crop[4],"輝度温度(℃)",pos=3, cex=1.5) plot(l$band$panchromatic, col = gray.colors(30),legend=FALSE, axes=FALSE,box=FALSE) plot(temperature,col=blue2green2red(30),legend=F,axes=FALSE,box=FALSE,alpha=0.5,add=T) r.range <- c(minValue(temperature), maxValue(temperature)) plot(temperature, legend.only=TRUE, col=blue2green2red(30), legend.width=1, legend.shrink=0.5, axis.args=list(at=c(r.range[1], r.range[2]), labels=c("L","H"), cex.axis=1), legend.args=list(text='temperature', side=4, font=1, line=0.75, cex=1)) text((Crop[1]+Crop[2])/2,Crop[4],"BAND7(swir2)",pos=3, cex=1.5) par(mfrow=c(1,1)) dev.off() }
|