Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
We have developed a new version of the gDefrag package. The previous version has been retired from CRAN due to dependencies on outdated packages. This updated version is still under development and may contain limitations. Please exercise caution when using it. I have just uploaded a new version of the package gDefrag on GitHub. It will still be some time for it to go to CRAN again.
What is the package all about?
Roads (and other linear infrastructures) fragment natural habitats. This package provides a set of tools to help the de-fragmentation process. It works by prioritizing the different sections of linear infrastructures (e.g. roads, power lines) to increase the available amount of a given resource (e.g. habitat).
If you want to know more, we published a paper describing the package and another demonstrating its usability. Additionally here’s the manual of a previous version.
Demonstration
Let’s begin with a brief demosntration. The first step is the installation of the package:
library(devtools) devtools::install_github("FMestre1/gDefrag")
Then, manually download the shapefile files from our sample dataset. Go to this link and download all files (road_P.shp
, road_P.shx
, road_P.dbf
, road_P.prj
, etc.).
Load them to your environment:
road_P <- terra::vect("road_P.shp")
The next step is obtaining a vector file of the nodes, by running the function node.creation:
out1 <- node.creation(land_polyg = road_P, value_col = "frst_sm", scale_nodes = 10, col_nodes = "pink", cex_labels = 1)
This will create a SpatVector object and plot the following figure:
Then you have to create the edges spatVector by running edge.creation:
out2 <- edge.creation(nodes = out1, land_polyg = road_P, min_length = 0, min_pol_area = 0)
Which will create teh following plot, with the edges in blue:
The next, and final step, is running the function prioritize to prioritize the edges to de-fragment the landscape. The you can plot the whole results:
out3 <- prioritize(nodes = out1, edges = out2, method = "value") #Plot the results: plotgraph(nodes = out1, edges = out3, land_polyg = road_P, main = "Habitat value")
This will create the following plot:
That’s it! You have to check the manual for information about each function’s specific arguments.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.