0

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. This is the scatter plot created by me using R.

I want to create such type of plot with two slop line and equations. 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]])
Axeman
  • 32,068
  • 8
  • 81
  • 94
Ronak Jain
  • 19
  • 1
  • 1
    Please provide some sample data as to make your code reproducible. – erc Aug 28 '18 at 08:44
  • I have made the subset of both imageries. link: https://drive.google.com/open?id=1F15vZhTr3iMcaEP807HuRvSLajXkFC6A – Ronak Jain Aug 28 '18 at 09:36
  • Please help me to resolve the issue @beetroot – Ronak Jain Aug 29 '18 at 08:01
  • 1
    If you want people to help you you should make it as easy and convenient as possible for them. This means that we should be able to copy and paste some data and code from your question in order to reproduce your problem. See here on how to do this: https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – erc Aug 29 '18 at 08:08

0 Answers0