Closed vjunquer closed 4 years ago
Thanks for your feedback. Would you please share the lines of code you are running? Also would you please share your data files if possible? (You may upload them to Google Drive or Dropbox and send the link). I ran the examples in the package and I don't find any issue so I would need your data to debug the error. Thanks
Dear Ali
Thanks a lot for the quick return.
I figured out that only eval="multiple" is giving an error. If I use original , it runs. I did not figure out how to make "multiple" work.
Code is below. And files are here:
https://www.dropbox.com/sh/z1tmumumagar735/AACWV9EERh7Lugm9oZIyl34ua?dl=0
Thanks a lot
Victoria
require(diffeR)
predict03 <- raster("C:/Users/vmj/Documents/ETH/02_R4D/50_LU_Decision_BN/gBay/gBay_Model_Verification/output_t1_2003/LUt1.tiff", band=5)
r_o_umask <- brick("C:/Users/vmj/Documents/ETH/02_R4D/50_LU_Decision_BN/BN_LU_R_OUTPUT_Rasters/r_o_umask.grd")
real03 <- subs(r_o_umask[[4]],eq_gBay_lu, by=1, which=3, subsWithNA=T)
diff03_all <- differenceMR(predict03, real03, eval = "original") diff03_all_mult <- differenceMR(predict03, real03, eval = "multiple") #error
Victoria Junquera Doctoral candidate Planning of Landscape and Urban Systems (PLUS), ETH Zürich www.plus.ethz.chhttp://www.plus.ethz.ch/de websitehttps://plus.ethz.ch/chair/people/person-detail.html?persid=219459 http://www.plus.ethz.ch/de +41 (0)44 633 6830 +41 (0)78 715 2160
From: Ali Santacruz notifications@github.com Sent: Thursday, December 5, 2019 5:24:47 PM To: amsantac/diffeR Cc: Junquera Victoria; Author Subject: Re: [amsantac/diffeR] differenceMR error: "number of layers in input rasters must be equal" (#1)
Thanks for your feedback. Would you please share the lines of code you are running? Also would you please share your data files if possible? (You may upload them to Google Drive or Dropbox and send the link). I ran the examples in the package and I don't find any issue so I would need your data to debug the error. Thanks
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/amsantac/diffeR/issues/1?email_source=notifications&email_token=ANAAN2LEMFQINGHFI2YMS63QXETM7A5CNFSM4JV32BX2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGBI2DA#issuecomment-562203916, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANAAN2JA5G6L6NJCSTSL5ZLQXETM7ANCNFSM4JV32BXQ.
Thanks for sharing your data and your script.
What is eq_gBay_lu? I get this error when creating real03:
real03 <- subs(r_o_umask[[4]],eq_gBay_lu, by=1, which=3, subsWithNA=T) Error in subs(r_o_umask[[4]], eq_gBay_lu, by = 1, which = 3, subsWithNA = T) : object 'eq_gBay_lu' not found
I would need the code lines that create eq_gBay_lu. Thanks
I'm sorry, forgot that one:
eq_gBay_lu <- data.frame(r_x=c(NA,1,2,3,4,6,8) ,lugbay=c(NA,NA,1,2,3,NA,NA) ,lugbay_withRUBlut0=c(NA,NA,1,2,3,4,NA))
I don't think this is the issue, but - perhaps.
Thanks again
Victoria
Victoria Junquera Doctoral candidate Planning of Landscape and Urban Systems (PLUS), ETH Zürich www.plus.ethz.chhttp://www.plus.ethz.ch/de websitehttps://plus.ethz.ch/chair/people/person-detail.html?persid=219459 http://www.plus.ethz.ch/de +41 (0)44 633 6830 +41 (0)78 715 2160
From: Ali Santacruz notifications@github.com Sent: Thursday, December 5, 2019 6:27:14 PM To: amsantac/diffeR Cc: Junquera Victoria; Author Subject: Re: [amsantac/diffeR] differenceMR error: "number of layers in input rasters must be equal" (#1)
Thanks for sharing your data and your script.
What is eq_gBay_lu? I get this error when creating real03:
real03 <- subs(r_o_umask[[4]],eq_gBay_lu, by=1, which=3, subsWithNA=T) Error in subs(r_o_umask[[4]], eq_gBay_lu, by = 1, which = 3, subsWithNA = T) : object 'eq_gBay_lu' not found
I would need the code lines that create eq_gBay_lu. Thanks
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/amsantac/diffeR/issues/1?email_source=notifications&email_token=ANAAN2KWVA437NM75A5TN2LQXE2XFA5CNFSM4JV32BX2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGBPH3A#issuecomment-562230252, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANAAN2NR6JKYIKZEJEDWXTLQXE2XFANCNFSM4JV32BXQ.
It seems the problem is that predict03 and real03 have a different set of categories, as there are not pixels with category 3 in the predict03 raster:
unique(predict03) [1] 1 2 4 unique(real03) [1] 1 2 3 4
Both rasters should have the same set of categories. This is an assumption in the composite() function which is the function that actually prints the error.
I will probably change the message error to mention the number of categories, not the number of layers, which is not the actual problem, as in your case. Also I may include a conditional statement at the beginning of the differenceMR() code to test whether the input raster maps have the same set of categories.
Dear Ali,
Thanks a lot. Just a follow up question: The function only gives me an error when I use eval = "multiple"; when I use eval = "original" it gives me results, even though my rasters have different categories. I suppose that these results are still valid?
Thanks again so much Victoria
Victoria Junquera Doctoral candidate Planning of Landscape and Urban Systems (PLUS), ETH Zürich www.plus.ethz.chhttp://www.plus.ethz.ch/de websitehttps://plus.ethz.ch/chair/people/person-detail.html?persid=219459 http://www.plus.ethz.ch/de +41 (0)44 633 6830 +41 (0)78 715 2160
From: Ali Santacruz notifications@github.com Sent: Thursday, December 5, 2019 8:37:40 PM To: amsantac/diffeR Cc: Junquera Victoria; Author Subject: Re: [amsantac/diffeR] differenceMR error: "number of layers in input rasters must be equal" (#1)
It seems the problem is that predict03 and real03 have a different set of categories, as there are not pixels with category 3 in the predict03 raster:
unique(predict03) [1] 1 2 4 unique(real03) [1] 1 2 3 4
Both rasters should have the same set of categories. This is an assumption in the composite() function which is the function that actually prints the error.
I will probably change the message error to mention the number of categories, not the number of layers, which is not the actual problem, as in your case. Also I may include a conditional statement at the beginning of the differenceMR() code to test whether the input raster maps have the same set of categories.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/amsantac/diffeR/issues/1?email_source=notifications&email_token=ANAAN2KCINL3A3OHEAZJ543QXFKAJA5CNFSM4JV32BX2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGB4FSQ#issuecomment-562283210, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANAAN2P4CM7INVZBHXZ5PRTQXFKAJANCNFSM4JV32BXQ.
Dear Ali,
another issue (same code I had sent). With differenceMR, I get the same results whether I use percent = TRUE or percent = FALSE.
Regards
Victoria
Victoria Junquera Doctoral candidate Planning of Landscape and Urban Systems (PLUS), ETH Zürich www.plus.ethz.chhttp://www.plus.ethz.ch/de websitehttps://plus.ethz.ch/chair/people/person-detail.html?persid=219459 http://www.plus.ethz.ch/de +41 (0)44 633 6830 +41 (0)78 715 2160
From: Junquera Victoria Sent: Monday, December 9, 2019 2:34:23 PM To: amsantac/diffeR; amsantac/diffeR Cc: Author Subject: Re: [amsantac/diffeR] differenceMR error: "number of layers in input rasters must be equal" (#1)
Dear Ali,
Thanks a lot. Just a follow up question: The function only gives me an error when I use eval = "multiple"; when I use eval = "original" it gives me results, even though my rasters have different categories. I suppose that these results are still valid?
Thanks again so much Victoria
Victoria Junquera Doctoral candidate Planning of Landscape and Urban Systems (PLUS), ETH Zürich www.plus.ethz.chhttp://www.plus.ethz.ch/de websitehttps://plus.ethz.ch/chair/people/person-detail.html?persid=219459 http://www.plus.ethz.ch/de +41 (0)44 633 6830 +41 (0)78 715 2160
From: Ali Santacruz notifications@github.com Sent: Thursday, December 5, 2019 8:37:40 PM To: amsantac/diffeR Cc: Junquera Victoria; Author Subject: Re: [amsantac/diffeR] differenceMR error: "number of layers in input rasters must be equal" (#1)
It seems the problem is that predict03 and real03 have a different set of categories, as there are not pixels with category 3 in the predict03 raster:
unique(predict03) [1] 1 2 4 unique(real03) [1] 1 2 3 4
Both rasters should have the same set of categories. This is an assumption in the composite() function which is the function that actually prints the error.
I will probably change the message error to mention the number of categories, not the number of layers, which is not the actual problem, as in your case. Also I may include a conditional statement at the beginning of the differenceMR() code to test whether the input raster maps have the same set of categories.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/amsantac/diffeR/issues/1?email_source=notifications&email_token=ANAAN2KCINL3A3OHEAZJ543QXFKAJA5CNFSM4JV32BX2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGB4FSQ#issuecomment-562283210, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ANAAN2P4CM7INVZBHXZ5PRTQXFKAJANCNFSM4JV32BXQ.
Yes, the results for eval = "original" are still valid.
I fixed the bug for percent = FALSE when eval = "original". Now it should work as expected.
You may install the updated version (0.0-7) from GitHub running:
devtools::install_github("amsantac/diffeR")
Thanks
I am closing this issue. The percent bug is fixed. The error message printed by differenceMR() now says "set of unique pixel values in input rasters must be equal", which is more consistent with the actual error than the previous message. Thanks
I am using differenceMR with two rasters (predict03, real03) that have each the same resolution, CRS, and only one layer each (details below). I keep getting the error message: "Error in composite(comp, ref, factor) : number of layers in input rasters must be equal" Help would be appreciated, thanks. Victoria