dimitri-justeau / rflsgen

Neutral landscape generator that allows users to set targets on landscape indices.
https://dimitri-justeau.github.io/rflsgen/
11 stars 0 forks source link

rflsgen throws a Java fatal error in R 4.2.0, RStudio 2022.02.1 Build 461. #1

Closed Mbinford closed 2 years ago

Mbinford commented 2 years ago

Dimitri:

When rflsgen tries to load Java it throws a Java fatal error. I'm running Java RE 8u331 with the JDK-18 with Windows 10, and R 4.2 in RStudio 2022.02.1 Build 461. I had to revert back to R 4.1.2 to make rflsgen work.

I hope that this is enough information. Help, please.

Mike Binford, University of Florida

dimitri-justeau commented 2 years ago

Hello,

Thank you for raising this issue ! I will investigate to see what's wrong with R 4.2. It has just been released so it might also be a problem with the dependencies. I will let you know as soon as the problem is fixed !

Best regards,

Dimitri Justeau-Allaire.

Mbinford commented 2 years ago

Hi, Dmitri:

Thank you for your note. It must be difficult to keep up with all of the revisions. I do like rflsgen!

Michael W. Binford, Professor Department of Geography Land Use and Environmental Change Institute University of Florida Gainesville, FL 32611 http://people.clas.ufl.edu/mbinford/

My pronouns: he/himhttps://www.mypronouns.org/he-him The what + why of pronoun sharinghttps://www.mypronouns.org/what-and-why

From: Dimitri Justeau-Allaire @.> Sent: Monday, May 2, 2022 6:38 AM To: dimitri-justeau/rflsgen @.> Cc: Binford, Michael W. @.>; Author @.> Subject: Re: [dimitri-justeau/rflsgen] rflsgen throws a Java fatal error in R 4.2.0, RStudio 2022.02.1 Build 461. (Issue #1)

[External Email]

Hello,

Thank you for raising this issue ! I will investigate to see what's wrong with R 4.2. It has just been released so it might also be a problem with the dependencies. I will let you know as soon as the problem is fixed !

Best regards,

Dimitri Justeau-Allaire.

— Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_dimitri-2Djusteau_rflsgen_issues_1-23issuecomment-2D1114711664&d=DwMCaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=Puzypihz8joT43VtV8RRSSKD6YAnUsikl0lMpYFfVz0&m=B9gzsuIvoltOcNaZlGT_AHdbMIqds0E-NRk5UAlK43kYYJ3fjM1apO2ydW0BaF5-&s=bUC0zS9o48qblJe8PXPgaBIy2j6RdOmAy5R6BgSU5ms&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AHLBXLZVXAFGD3KXML2YFO3VH6WA5ANCNFSM5UPP3VPA&d=DwMCaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=Puzypihz8joT43VtV8RRSSKD6YAnUsikl0lMpYFfVz0&m=B9gzsuIvoltOcNaZlGT_AHdbMIqds0E-NRk5UAlK43kYYJ3fjM1apO2ydW0BaF5-&s=DzspRHOuQRHCFlov0Bn_UpkG08qnuUu-lf4nc07XXMI&e=. You are receiving this because you authored the thread.Message ID: @.**@.>>

dimitri-justeau commented 2 years ago

Thank you for this positive feedback :-) Do not hesitate to open an issue if you feel like some features are missing, I will be happy to improve the package according to users' needs!

Dimitri Justeau-Allaire.

Mbinford commented 2 years ago

Hello, Dmitri. I've run into a problem for which I cannot find any solution in your documentation. I'm trying to generate a landscape with 4 classes and a large area of noData, but as a neutral landscape that has the statistical landscape properties of an original landscape but in different configurations. The problem seems to be that the raster landscape has a specific shape (the coastal plain and piedmont of the southeastern US - a total of 9,815,227 250-m pixels with data in a total raster dataset that would 6784 rows and 7487 columns if it were rectangular) but when I try to read the landscape structure with flsgen_extract_structure_from_raster it doesn't allow the use of a raster mask. Then, I think that because the original raster data were of a different shape than the assumed rectangle that the JSON script assumes.

I'm a beginning R coder, but the code that I've been working with is below, and the data file is attached as Neutral_Landscapes_SEUS.zip. You should know that I've been going through your examples and having success, but when I do my own data, it doesn't seem to work very well. Thank you for any help you can give me. I don't expect full consultation, just help going in the right direction.

######### My code follows

This is code from the README file for rflsgen

https://cran.r-project.org/web/packages/rflsgen/readme/README.html#generate

First clear all files and data

rm(list=ls())

Increase Java memory space from

https://stackoverflow.com/questions/34624002/r-error-java-lang-outofmemoryerror-java-heap-space

options(java.parameters = "-Xmx8g")

Install and run rflsgen, terra, and graphics

install.packages("terra") install.packages("graphics") install.packages("rflsgen") install.packages("rjson") library(terra) library(graphics) library(rflsgen) library(rjson)

Set the working directory to my Documents folder on the Dell Laptop

setwd("C:/Users/mbinford/Documents/Macrosystems_Work")

Plot the forest management map

SEUS_forest_management <- rast("SEUS_forest_mgmt_20160602_135815.tif")

plot(SEUS_forest_management)

Plot the management mask map

SEUS_forest_mask <- rast("SEUS_forest_mgmt_20160602_135815_mask_1_raster.tif")

plot (SEUS_forest_mask)

Get the structure from "SEUS_forest_mgmt_20160602_135815.tif", convert from JSON

and print the file

SEUS_struct <- flsgen_extract_structure_from_raster("SEUS_forest_mgmt_20160602_135815.tif", focal_classes=c(nodata, 1, 2, 3, 4))

SEUS_struct_out <- fromJSON(SEUS_struct)

print(SEUS_struct_out) # to see what the JSON structure looks like.

Now generate landscapes from the SEUS_struct instruction

SEUS_forest_management_landscape2 <- flsgen_generate(SEUS_struct, mask_raster = SEUS_forest_mask) plot(SEUS_forest_management_landscape2)

And the data are as follows. You are welcome to use the data in any way that you wish. They have been published in Marsik, M., Staub, C. G., Kleindl, W. J., Hall, J. M., Fu, C.-S., Yang, D., Stevens, F. R., & Binford, M. W. (2018). Regional-scale management maps for forested areas of the Southeastern United States and the US Pacific Northwest. Scientific Data, 5(1), 180165. https://doi.org/10.1038/sdata.2018.165 and are available from the Pangaea data repository.

Again, thank you for any help that you can give me.

Mike Binford

Neutral_Landscapes_SEUS.zip

dimitri-justeau commented 2 years ago

Hello ! I am really sorry, I am just seeing your message now, I will have a look on your dataset, do you have a specific error message? Given the size of the raster, I suspect that it may be a RAM issue. I will get back to you as soon as possible !

Also, I just tried to run the package with R 4.2, everything seems ok now, I think it was only necessary to wait until the dependencies had properly migrated to the new R version.

Mbinford commented 2 years ago

Hi, Dimitri:

It was a RAM issue, or more accurately a memory allocation issue. When I increased the memory available to R it worked fine and it is still working well in 4.2.

Your package is a very useful tool for our study. We are studying how forest management affects carbon cycle, water yield, and biodiversity in all the forested areas of the United States. We mapped management classes in all the forests and are now doing experiments by varying the proportions, locations, and landscape configuration of the management classes, which is where rflsgen comes in. To see our first efforts in mapping, you can look at

Marsik, M., Staub, C. G., Kleindl, W. J., Hall, J. M., Fu, C.-S., Yang, D., Stevens, F. R., & Binford, M. W. (2018). Regional-scale management maps for forested areas of the Southeastern United States and the US Pacific Northwest. Scientific Data, 5(1), 180165. https://doi.org/10.1038/sdata.2018.165 The data and code are there.

Thank you for creating this package and for getting back to me.

Dr. Michael W. Binford Department of Geography, TUR 3131 Land Use and Environmental Change Institute University of Florida Gainesville, FL 32601

From: Dimitri Justeau-Allaire @.> Sent: Thursday, June 16, 2022 10:01 AM To: dimitri-justeau/rflsgen @.> Cc: Binford, Michael W. @.>; Author @.> Subject: Re: [dimitri-justeau/rflsgen] rflsgen throws a Java fatal error in R 4.2.0, RStudio 2022.02.1 Build 461. (Issue #1)

[External Email]

Hello ! I am really sorry, I am just seeing your message now, I will have a look on your dataset, do you have a specific error message? Given the size of the raster, I suspect that it may be a RAM issue. I will get back to you as soon as possible !

Also, I just tried to run the package with R 4.2, everything seems ok now, I think it was only necessary to wait until the dependencies had properly migrated to the new R version.

— Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_dimitri-2Djusteau_rflsgen_issues_1-23issuecomment-2D1157696229&d=DwMCaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=Puzypihz8joT43VtV8RRSSKD6YAnUsikl0lMpYFfVz0&m=Ce8bcLh2ItxFUjQSctbN8msm-gqvZxwgf0t97Z6gZLhGQ_ZBuB1AkAYCHoQJCZuu&s=d8_pi6HBdu8w6FNdnh8jRpDcscYqv_OVG2qf8zJ4rhk&e=, or unsubscribehttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AHLBXL4QEHLZ4DBPONYDLVTVPMXQJANCNFSM5UPP3VPA&d=DwMCaQ&c=sJ6xIWYx-zLMB3EPkvcnVg&r=Puzypihz8joT43VtV8RRSSKD6YAnUsikl0lMpYFfVz0&m=Ce8bcLh2ItxFUjQSctbN8msm-gqvZxwgf0t97Z6gZLhGQ_ZBuB1AkAYCHoQJCZuu&s=7PileaWYB7Zam19NyXuymTKe8l3BUN0Ob9kvaSw5Avk&e=. You are receiving this because you authored the thread.Message ID: @.**@.>>

dimitri-justeau commented 2 years ago

Hi,

I'm happy to know that you solved your issue! Thank you for sharing your experience and your research, it gives us many ideas for our current project in New Caledonia, which is focused on forest regeneration in New Caledonia, and aims at providing managers with plans to conserve and restore forests, including tradeoffs between natural, assisted, and active reforestation.

PS: You may have already seen it, but just in case the article describing rflsgen is now open-access: https://besjournals.onlinelibrary.wiley.com/doi/10.1111/2041-210X.13859

Best regards,

Dimitri.