-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compareMultiple ouputs a long form of agreements by pair of workflows…
… for each intersected geometries. workflowAgreeAreas outputs the areas summed on where any pair of workflows agreee / disagree To do : compute the summed areas when pairs of LCZ values agree / disagree
- Loading branch information
Showing
26 changed files
with
403 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,8 @@ Imports: RColorBrewer, | |
rlang, | ||
grDevices, | ||
DescTools, | ||
caret, | ||
confintr, | ||
methods | ||
Suggests: | ||
tinytest, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#' Take sf files with an lcz_primary column, and concatenates them in a single sf object, | ||
#' adding a column for location and workflow names | ||
#' @param sfList the list of LCZ sf objects | ||
#' @param workflowNames sets the names of workflows and define the name of the files which will be loaded and intersected | ||
#' @param location the name of the location at which all LCZ are created | ||
#' @importFrom ggplot2 geom_sf guides ggtitle aes | ||
#' @import sf dplyr cowplot forcats units tidyr RColorBrewer utils grDevices rlang | ||
#' @return returns graphics of comparison and an object called matConfOut which contains : | ||
#' matConfLong, a confusion matrix in a longer form, | ||
#' matConfPlot is a ggplot2 object showing the confusion matrix. | ||
#' percAgg is the general agreement between the two sets of LCZ, expressed as a percentage of the total area of the study zone | ||
#' pseudoK is a heuristic estimate of a Cohen's kappa coefficient of agreement between classifications | ||
#' If saveG is not an empty string, graphics are saved under "saveG.png" | ||
#' @export | ||
#' @examples | ||
concatAlocationWorkflows<-function(sfList, location, refCrs = 1){ | ||
if (is.null(location)){ | ||
location<- sfList[[1]]["location"][1] | ||
} | ||
concatDf<-data.frame( | ||
matrix(ncol=4, nrow=0) | ||
) | ||
names(concatDf)<-c("lcz_primary", "location", "wf", "geometry") | ||
refCrs<-st_crs(sfList[[refCrs]]$geometry) | ||
for (i in 1:length(sfList)){ | ||
inSf<-st_transform( | ||
sfList[[i]], | ||
crs = refCrs) | ||
concatDf<-rbind(concatDf,inSf) | ||
} | ||
concatSf<-st_as_sf(concatDf) | ||
rm(concatDf) ; gc() | ||
concatSf<-mutate(concatSf, area = st_area(concatSf), .before = geometry) | ||
return(concatSf) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#' In a given directory (or a list of directories) the function looks for LCZ datafiles, intersects them and return a datasets with intersected geometries and LCZ values for each workflow | ||
#' @param dirList the list of directories for which the different LCZ files will be intersected | ||
#' @param workflowNames sets the names of workflows and define the name of the files which will be loaded and intersected | ||
#' @param for each diretory from dirList, a location name must be fed to the function | ||
#' @importFrom ggplot2 geom_sf guides ggtitle aes | ||
#' @import sf dplyr cowplot forcats units tidyr RColorBrewer utils grDevices rlang | ||
#' @return returns graphics of comparison and an object called matConfOut which contains : | ||
#' matConfLong, a confusion matrix in a longer form, | ||
#' matConfPlot is a ggplot2 object showing the confusion matrix. | ||
#' percAgg is the general agreement between the two sets of LCZ, expressed as a percentage of the total area of the study zone | ||
#' pseudoK is a heuristic estimate of a Cohen's kappa coefficient of agreement between classifications | ||
#' If saveG is not an empty string, graphics are saved under "saveG.png" | ||
#' @export | ||
#' @examples | ||
#' | ||
concatIntersectedLocations<-function(dirList, locations, workflowNames = c("osm","bdt","iau","wudapt")){ | ||
concatIntersectedDf<-data.frame( | ||
matrix(ncol=length(workflowNames)+3, nrow=0) | ||
) | ||
names(concatIntersectedDf)<-c(workflowNames,"area", "location", "geometry") | ||
|
||
for (i in 1:length(dirList)){ | ||
print(locations[i]) | ||
concatIntersectedDf<-rbind(concatIntersectedDf, | ||
intersectAlocation( | ||
dirPath = dirList[i], workflowNames = workflowNames, location = locations[i]) | ||
) | ||
} | ||
concatIntersectedDf$location<-factor(concatIntersectedDf$location) | ||
concatIntersectedSf<-concatIntersectedDf %>% st_as_sf() | ||
return(concatIntersectedSf) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.