# libraries library(foreign) # to import .dbf files from ArcMap library(stats) # to extract coefficient of the nls function dir<- "" # path directory start = # number = begining of the dilatation process stop = # number = end of the dilatation process step = # number = step by step dilatation # Import the results from all "extract_files" (see SIG process in Appendix of Arcaute et al., 2016) and create a new data.frame # For all "extract_files" calculate the maximun number of street intersection and add it in a data.frame Table<-data.frame(t=seq(start,stop,step),N=NA, dN=0) # new data frame with a colomne "t" = distance and a empty colomne "N" to put the maximum number of intersections for (i in seq(start,stop,step)) { data<-read.dbf(paste(dir,i,".dbf",sep="")) data$Nombre<-1 data<-aggregate(data$Nombre, by=list(data$RASTERVALU),FUN=sum) Table[(i/step),2]<-max(data[,2]) } # for a sequence of number according to "extract_files" (see SIG process) : # import a specific extract_files # add a colomn -> each ligne of a extract_files corresponding to 1 intersection in 1 group (call RASTERVALU) # aggregate de new colomn by the RASTERVALU colomn # take the maximum of the aggregate object (maximum of intersection in the larger groupe) and stock it in the "N" data.frame # If you want to write the final data.frame in a xlsx files write.table(N,"Percolation_Empirical.csv", row.names = F, sep=";") # Interpolate the logistic function # 1. at which distance (dilatation step), the evolution of number of intersection is maximum ? # calculation of the derivative for (i in 1:(nrow(Table)-1)) { Table[i,3]<-Table[i+1,2]-Table[i,2] } plot(Table$t,Table$dN, type="l") # identification of a peak at a "distance_peak" # if only one peak : t0 = Table$t[Table$dN == max(Table$dN)] # if two or more peak (see paper), choose manualy de first one, etc. # 2. Substet of N with distance < to "distance_peak"(t0) to evaluate de r parameter of the equation (1) Data<-subset(Table, Table$t