Process data based on sta. result from ENVI
read the data
reshape data
load("Sta_samples_new_ENVI.RData")
libs<-read.csv("J:/PhD/WICKEPIN/20160632/biomass/Wickpin_biomass/images/Spectral compare between QUCK and none/Spectral_libs.csv",T)
name_sample<-c("Pasture_1","Pasture_2","Pasture_3","Eucalyptus_1","Eucalyptus_2","Eucalyptus_3","Saltbush_1","Saltbush_2","Saltbush_3","Red_grave_road_1","Red_grave_road_2","White_road_next_to_pasture_1","Dam_1","Dam_2","Dam_3","Salinity_1","Salinity_2","Salinity_3","White_road_next_to_pasture_2","Salinity_blue_1","Salinity_blue_2")
lin<-melt(sta_samples,id=c(1,4))
names(lin)<-c("Band","Sample","Date","DN")
lin$DN<-lin$DN/100
lin1<-melt(lin,id=c(1,2,3))
sta_veg<-dcast(lin1,Date+Band~Sample)
sta_veg$Wave<-c(0.45,0.55,0.675,0.780)
names(sta_veg)<-c("Date","Band",name_sample,"Wave length")
plot data
sta_veg<-arrange(sta_veg,Band,Date)
f_plot<-function(sta_veg=sta_veg,lib_1,lib_2,name){
.sub<-which(libs[[lib_1]]>=0.1 & libs[[lib_1]]<=1.3)
x<-libs[[lib_1]][.sub]
y<-libs[[lib_2]][.sub]
ids<-grep(name,names(sta_veg))
plot(x,y,type="l",xlab="Wavelength (um)",ylab="Refletance (%)",main=name,ylim=c(0,max(y)))
for( i in c(1:length(ids))){
points(sta_veg$`Wave length`,sta_veg[[ids[i]]],col=c("black","red"),pch=i,cex=1.5)
}
#text(1, c(13,11,9), c("Red: Winter;","Black: Summer.","Shapes: Samples"), cex = 1.2,col=c("red","black","black"))
legend("bottomright", names(sta_veg)[ids],
text.col = "black", lty = c(-1), pch = c(1:length(ids)),
bg = "gray90")
legend("right", c("Winter","Summer"),
text.col = c("red","black"))
}
print(names(libs))
## [1] "Wavelength.Very.dark.grayish.brown.silty.loam..um."
## [2] "Reflectance....Very.dark.grayish.brown.silty.loam."
## [3] "Wavelength..Green.Rye.grass...um."
## [4] "Reflectance....Green.Rye.grass."
## [5] "Wavelength..Conifer...um."
## [6] "Reflectance....Conifer."
## [7] "Wavelength.Dry.Grass..um."
## [8] "Reflectance....Dry.Grass."
## [9] "Wavelength.Tapwater..um."
## [10] "Reflectance...Tapwater."
# plot soil road with "Very.dark.grayish.brown.silty.loam" sepctral feature
f_plot(sta_veg,1,2,"road")

# plot Saltbush with "green grass" sepctral feature
f_plot(sta_veg,3,4,"Saltbush")

# plot Eucalyptus with "Conifer" sepctral feature
f_plot(sta_veg,5,6,"Eucalyptus")

# plot Pasture with "green grass" sepctral feature
f_plot(sta_veg,3,4,"Pasture")

# plot Pasture with "Dry grass" sepctral feature
f_plot(sta_veg,7,8,"Pasture")

# plot Salinity with "Very.dark.grayish.brown.silty.loam" sepctral feature
f_plot(sta_veg,1,2,"Salinity")

# plot Dam with "Very.dark.grayish.brown.silty.loam" sepctral feature
f_plot(sta_veg,1,2,"Dam")

# plot Dam with "green grass" sepctral feature
f_plot(sta_veg,3,4,"Dam")

# plot Dam with "Tapwater" sepctral feature
f_plot(sta_veg,9,10,"Dam")
