Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not all patches linked by MPG() #32

Closed
achubaty opened this issue Dec 2, 2016 · 5 comments
Closed

not all patches linked by MPG() #32

achubaty opened this issue Dec 2, 2016 · 5 comments
Assignees

Comments

@achubaty
Copy link
Owner

achubaty commented Dec 2, 2016

Using the NA test case from #28, note that not all patches end up linked:

f <- "naErrorExample.asc"
r <- raster(f)
c <- r
p <- (r == 1)

mpg <- MPG(cost = c, patch = p)
plot(mpg)

naerrorexample

@achubaty
Copy link
Owner Author

achubaty commented Mar 2, 2017

@samdoctolero @ecologics poking at this more, I think we mis-diagnosed this bug:

First, update to the latest version of the package to ensure the new test cases and test data are available to you.

library(igraph)
library(raster)
devtools::load_all("~/GitHub/grainscape")

naError <- raster(system.file("extdata/naErrorExample.asc", package = "grainscape"))
naErrorMPG <- MPG(cost = naError, patch = (naError == 1))

## plotting the result, it appears the top right patches aren't connected
plot(naErrorMPG)

## however, the underlying igraph object looks correct
g <- naErrorMPG$mpg
#g <- simplify(g, remove.multiple = TRUE, remove.loops = TRUE)
count_components(g) ## equals 1, despite the plot above showing 2 subgraphs
plot(g) ## also shows all nodes connected

To me it suggests that either the igraph object (naErrorMPG$mpg) differs from the raster that is produced (and then plotted) OR that the plotting is screwing up (though this seems unlikely because it's simply plotting the raster using base R, i.e., nothing we coded).

Thoughts?

achubaty added a commit that referenced this issue Mar 2, 2017
@samdoctolero the test passes, which suggests the spatial graph is being correctly built, but the raster is incorrect or being plotted incorrectly.
@achubaty
Copy link
Owner Author

achubaty commented Mar 5, 2017

fixed in 5a5292a

@achubaty achubaty closed this as completed Mar 5, 2017
@achubaty
Copy link
Owner Author

achubaty commented Mar 5, 2017

thanks @samdoctolero for tracking this down and fixing

@achubaty
Copy link
Owner Author

achubaty commented Mar 5, 2017

@cxfauvelle @ecologics please update your machines to the latest grainscape, which fixes the patch-linking bug

@ecologics
Copy link
Collaborator

ecologics commented Mar 5, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants