connectscape/Makurhini

Unable to load patches Data for ECA connectivity analysis

Closed this issue · 1 comments

Hi there,

I am attempting to run the ECA connectivity analysis. However, im unable to load my patches data (files.shp) from qgis. I have tried to convert these data to .rda files since I saw in the example file that this was the format but haven´t been succesful.

I wanted to know how can I organize my shp files that contain my patches data in order to be able to load it with the function data.

This is the warning message that I´m receiving.

Warning message:
In data(List_Patches, package = "Makurhini") :
data set ‘List_Patches’ not found

I have the List_Patches loaded. However, I feel that I dont have the rigth format.

I would appreciate any help and thank you so much in advance

Hello. Nice to read you and an apology for the delay in answering, I had some personal problems but I'm back.

This is an excellent question. What you need to do is load each shapefile and then make a list. An example: https://drive.google.com/drive/folders/1e1ivFjOKkn4Ni043DJ_lr8XBSly7vNtm?usp=sharing

In the folder you will find four shapefiles (four times) like the ones that come out of qgis that should be projected: parches_T1.shp, parches_T2.shp, parches_T3.shp and parches_T4.shp

Shapefiles have fragments/patches of primary vegetation.

#Replace .shp path
T1 <- shapefile("G:/Mi unidad/Clase_IB_2021/Clase_UNAM/Ejercicio2/Datos/parches_T1.shp")
T2 <- shapefile("G:/Mi unidad/Clase_IB_2021/Clase_UNAM/Ejercicio2/Datos/parches_T2.shp")
T3 <- shapefile("G:/Mi unidad/Clase_IB_2021/Clase_UNAM/Ejercicio2/Datos/parches_T3.shp")
T4 <- shapefile("G:/Mi unidad/Clase_IB_2021/Clase_UNAM/Ejercicio2/Datos/parches_T4.shp")

#We create a list, you can change the names, example, "T1", "T2", etc., but it is not necessary.
lista_parches <- list("T1" = T1, "T2" = T2, "T3" = T3, "T4" = T4)

par(mfrow=c(2,2))
plot(lista_parches$T1, col = "forestgreen", main = "T1")
plot(lista_parches$T2, col = "forestgreen", main = "T2")
plot(lista_parches$T3, col = "forestgreen", main = "T3")
plot(lista_parches$T4, col = "forestgreen", main = "T4")

The attribute we will use for the patches is their area (assumption = the larger the patch the greater its intra-patch connectivity).
Thus, the maximum attribute in the landscape will be the area of the entire study area.

#Replace .shp path
area_estudio <- shapefile("G:/Mi unidad/Clase_IB_2021/Clase_UNAM/Ejercicio2/Datos/area_estudio.shp")
#Maximum attribute
Max_atributo <- area(area_estudio) * 0.0001 # Hectares
Max_atributo
#> [1] 279164.3

Apply the function:

dECA_test <- MK_dECA(nodes= lista_parches, attribute = NULL, area_unit = "ha",
distance = list(type= "centroid"), metric = "PC",
probability = 0.05, distance_thresholds = 30000,
LA = Max_atributo, plot= c("T1", "T2", "T3", "T4"),
intern = FALSE)

dECA_test

In the example of the MK_dECA function and others, we use the rdata so that the spatial files can be stored inside the package and the user can run examples. The important thing is to load the shapefiles (or other vector formats), raster, etc. and you can make use of the raster and sf packages. I hope it is still helpful.

Cheers,