Open Johnny987654321 opened 3 years ago
can you please provide a reproducible example?
I'm not sure how to do that but here are some codes I am using. The formaskSieve2 is the green patches extracted from the Raster data where patchy cost was created from. So while the patchyCost was the same raster data with resistance value the formaskSieve2 was just the green patches extracted with a value of 1 and NA. I apologize for my lapses as I just copy my codes from the grainscape manual.
patchyMPG <- MPG(patchyCost, patch= ( formaskSieve2== 1))
scalarAnalysis <- threshold(patchyMPG, weight = "lcpPerimWeight", nThresh = 10, doThresh = NULL)
kable(scalarAnalysis$summary,
caption = paste("The number of components ('nComponents') in the",
"minimum planar graph at ten automatically-selected",
"link thresholds ('maxLink)."))
I just worked through this, and I think I reporduced what you were seeing:
library(raster)
library(grainscape)
patchy <- raster(system.file("extdata/patchy.asc", package = "grainscape"))
isBecomes <- cbind(c(1, 2, 3, 4, 5), c(1, 10, 8, 3, 6))
patchyCost <- reclassify(patchy, rcl = isBecomes)
## orig version from vignette
patchyMPG0 <- MPG(patchyCost, patch = (patchyCost == 1))
scalarAnalysis0 <- threshold(patchyMPG0, weight = "lcpPerimWeight", nThresh = 5, doThresh = NULL)
scalarAnalysis0$summary
plot(patchyMPG0)
## your version
patchyMPG <- MPG(patchyCost, patch = (patchyCost == 6)) ## is this correct?
scalarAnalysis <- threshold(patchyMPG, weight = "lcpPerimWeight", nThresh = 10, doThresh = NULL)
scalarAnalysis$summary
plot(patchyMPG)
As you can see from the figures, your version's MPG is two separate subgraphs, so I think this is correct behaviour.
I think we can close this issue, unless @ecologics disagrees.
I wonder why I always end up with 2 as the max Number of components when it should have been 1. I wonder what it means? I am using a raster data that only contains green areas (and all other values are NA) as my patch in creatin an MPG file. When I replaced the patches with a different raster data having four types of landuse I ended up with 4. Is that normal?