BenioffOceanInitiative/bbnj

Error in magick_image_read path when knitting a scenario

Closed this issue · 6 comments

bbest commented

From @mvisalli:

hmmm when I try running the scenario you were working on but adding another layer (vents) I get an Error in magick_image_readpath

I think it has something to do with Cairo which I can't get to load for some reason

bbest commented

Hi @mvisalli,

I used png(..., res=300, type="cairo") inside function report_solution() because otherwise the png produced would only ever be in default 72 dpi and we want 300 dpi for manuscript figures.

Here's the line:
https://github.com/ecoquants/bbnj/blob/1d832cb147efd772b098b9cc4d9cd0371a493dc6/R/prioritizr.R#L193

You could try removing type="cairo" argument from the function, use devtools::load_all() instead of library(bbnj) to see if that gets you past it. Would be great if we could figure out: 1) how to properly install Cairo (do you just need to install.packages("Cairo") per Cairo); and 2) construct an if/else statement to use it if available (or add dependency on Cairo package to bbnj).

You can see from this commit e149a2b that I was able to add vents and knit scenario s00b.bio.30pct.gl.mol50km

I think the issue I'm having is described here and is related to XQuartz: https://stackoverflow.com/questions/38952427/include-cairo-r-on-a-mac

Do you have XQuartz on your Mac @bbest ?

bbest commented

Ah, that's annoying. If you're running low on disk space, I'd say skip it, otherwise please try installing
with download from https://www.xquartz.org, then install.packages("Cairo")

@bbest Ok Cairo is working now! Are the maps updating for you when knitting a scenario? I just ran a seamount-only scenario but the map output looks the same (but reporting metrics are different -- just not map)

Nvm got it! I can create maps in new scenarios. However, when modifying and knitting existing scenarios, the maps don't update. Not sure if that's intentional but maybe b/c of this line?

https://github.com/ecoquants/bbnj/blob/e149a2b04eec1bf40af868db1d95f0027e57d176/R/prioritizr.R#L180

bbest commented

Good eye @mvisalli! Just updated the function so you can now use the redo argument in report_solution() at the end of your scenario, similar to solve_log():

report_solution(tif, redo=redo)