-2

I would like to make a graph like this. I saw that it is possible using the pavo R package, but I do not have the values โ€‹โ€‹of wavelength or reflectance, I did not understand very well how I get it. What I have is an image (from UAV) and I can get its RGB band values. From there, how to proceed in R?

enter image description here

Igor Cobelo
  • 419
  • 3
  • 12

1 Answers1

0

This is not the type of question to ask on SO, because it no concern any programming problem, in addition, all information about your data is missing, so it is impossible to create an example for you. I don't know what kind of sensor the UAV carried, but if you want a plot like the image you posted, you need several spectral bands (tens to hundreds, like a hyperspectral image) to create the "smooth" spectral signatures of the example image. However, the typical workflow is to import your bands as a rasterStack for example (or rasterBrick), then extract the values of all bands at some points location (which typically come from a sampling design). The points must cover all the classes whose spectral signature you want to create (If you want the spectral signatures of, let say 10 land use classes, the sampling points must fall within each land uses). Finally, simply plot the wavelength of your spectral bands against the extracted values, grouped by land-use classes.

a little piece of pseudocode:

library(raster)
library(ggplot2)
r <- raster(ncol=36, nrow=18, vals=runif(648,300,320))
s <- lapply(seq(100,700,20), function(x)r+x*runif(1))
s <- stack(s)
names(s) <- seq(100,700,20)+300
xy <- cbind(-50, seq(-80, 80, by=20))
sp <- SpatialPoints(xy)
ex <- extract(s, sp,df=T)
ex$ID <- factor(c(1,1,1,2,2,2,3,3,3))
m <- reshape2::melt(ex,id.vars="ID")
m$ID <- factor(m$ID)
m$variable <- as.numeric(gsub("X","",m$variable))

ggplot(m,aes(x=variable,y=value,col=ID,group=ID))+
  geom_line()
Elia
  • 2,210
  • 1
  • 6
  • 18