library(raster) library(colorRamps) library(RColorBrewer) #library(devtools) #install_url("https://github.com/Terradue/rLandsat8/releases/download/v0.1-SNAPSHOT/rLandsat8_0.1.0.tar.gz") library(rLandsat8) #source("rLandsat8fix.R") #変更した関数付け加えた関数をrLandsat8fix.Rというファイル名で作業フォルダに保存した場合。 setwd("/home/user/landsat8") #阿蘇山 path:112 row:037 product <- "LC81120372015013LGN00" Crop <- c(689000,701500,3635500,3644500) fname0<-"aso" #西之島 path:105 row:041 #product <- "LC81050412015172LGN00" #Crop<-c(485700,491000,3011000,3016000) #fname0<-"nishinoshima" #鳥取市 path:111 row:035 #product <- "LC81110352015214LGN00" #Crop <- c(420000,430000,3926000,3934600) #fname0<-"tottori" #福島 path:107 row:034 #product <- "LC81070342015218LGN00" #Crop<-c(490000,512000,4125000,4150000) #fname0<-"fukushima" #桜島 path:112 row:038 #product <- "LC81120382015221LGN00" #Crop <- c(650700,664300,3490800,3501200) #fname0<-"sakurazhima" #メタデータの読み込み meta<-read.meta(product) date<-meta$date_acquired #保存するファイル名,作成する画像のファイル名の基礎 fname<-paste0(fname0,substr(date,1,4),substr(date,6,7),substr(date,9,10)) #解像度=30m 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"))) #解像度=15m PAN <-stack(paste0(product,"/",product, "_B8.TIF")) names(PAN)<-"panchromatic" #解像度=100m 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) #library(devtools) #install_github("bleutner/RStoolbox") #library(RStoolbox) ## Brovey pan sharpening RGBpan <- panSharpen(subOLI,subPAN, r = 4, g = 3, b = 2) ## Plot #png(paste0(fname,"_1.png"),width=1200,height=1000) par(mfrow=c(1,2)) plotRGB(subOLI, r = 4, g = 3, b = 2, stretch = "lin") text((Crop[1]+Crop[2])/2,Crop[4],"True color",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)",pos=3, cex=1.5) par(mfrow=c(1,1)) #dev.off()
|