I have stored the two raster images (.tif format) using the rater library and made the scatter plot between those raster images. As I am using the "abline" function for the creation of the regression line and that line provide me slope and intercept. But I would like to generate the two more slop lines along the x-axis for the points present at the minimum and another for the points present at the maximum position but I can't.
Help me to do such.
This is the scatter plot created by me using R.
I want to create such type of plot with two slop line and equations.
lst<- "F:/LC08_L1TP_148043_20180423_20180502_01_T1/Output/ArcGIS/LST.tif"
lst1 <- raster(lst)
plot(lst1)
summary(lst1)
ndvi<- "F:/LC08_L1TP_148043_20180423_20180502_01_T1/Output/ArcGIS/NDVI.tif"
ndvi1 <- raster(ndvi)
plot(ndvi1)
summary(ndvi1)
plot(ndvi1, lst1)
s <- stack(ndvi1, lst1)
names(s) <- c('ndvi1', 'lst1')
#xyplot(ndvi1~lst1, data = s, alpha = 1)
s1 <- data.frame(na.omit(values(s)))
#s2 <- lm(lst1~ndvi1, data = s1) #may give error
s1_1 <- sampleRegular(s, 1000000)
s1_2 <- data.frame(na.omit(s1_1))
s1_2 <- lm(lst1~ndvi1, data = s1_2)
xyplot(lst1~ndvi1, data = s, alpha = 1)
abline(s1_2, col = "red")
#equation of trendline
paste('y =', coef(s1_2)[[2]], '* x', '+', coef(s1_2)[[1]])