Skip to content

Commit

Permalink
Merge pull request #22 from MGousseff/ForReview4
Browse files Browse the repository at this point in the history
For review4
  • Loading branch information
MGousseff authored Aug 24, 2023
2 parents c7f3c17 + 838613f commit 26b0f06
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 22 deletions.
46 changes: 32 additions & 14 deletions R/confidSensib.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,30 @@ confidSensib<-function(inputDf="", filePath="", nPoints=5,
data$Kept<-factor(data$Kept,levels=c("confidence >= threshold","confidence < threshold"))
# graphics

etiquette<-paste0("average agreement percentage for LCZ with no confidence value : ",
NAPercAgr," \n (these ",nbOutCasted," geoms are excluded from computing other points)")

etiquette<-paste0("average agreement percentage for \n LCZ with no confidence value : ",
NAPercAgr,
" \n (these ",
nbOutCasted," geoms are excluded from computing other points)")
pointSize<-20/sqrt(nPoints)
confThreshPlot<-ggplot(data=data, aes(x=Confidence, y=Agreement, color=Kept, shape=Kept))+
labs(x="Confidence threshold", color = "Geom set", shape="Geom set")+
scale_fill_discrete(breaks=c("confidence >= threshold","confidence < threshold"),)+
labs(color = "Kept Geometries", shape="Kept Geometries")+
#scale_fill_discrete(breaks=c("confidence >= threshold","confidence < threshold"),)+
scale_color_manual(values =
c("confidence >= threshold" = "#00BFC4", "confidence < threshold" = "#F8766D"))+
geom_point() +
geom_text(aes(x=Confidence,y=Agreement,label=nbGeoms), nudge_y=-2)+
geom_point(size=rel(pointSize)) +
geom_text(aes(x=Confidence,y=Agreement,label=nbGeoms), nudge_y=-2,size=rel(pointSize),show.legend=FALSE)+
geom_hline(yintercept=NAPercAgr,linetype='dashed',color='grey')+
geom_text(aes(x=0.50,y=NAPercAgr,label=etiquette,vjust=1.5),inherit.aes=F,color='darkgrey',size=4)+
geom_text(aes(x=0.50,y=NAPercAgr,label=etiquette,vjust=1.5,),
inherit.aes=F,color='darkgrey',size=rel(6))+
ggtitle(label="Agreement according to the minimum confidence granted to LCZ level",
subtitle="Number of geoms used to compute agreement written under each point")
subtitle="Number of geoms used to compute agreement written under each point")+
theme(axis.title.x=element_text(size=rel(1.8)),
axis.title.y=element_text(size=rel(1.8)),
axis.text=element_text(size=rel(2)),
plot.title = element_text(size=rel(2)),
plot.subtitle = element_text(size=rel(2)),
legend.title=element_text(size=rel(1.8)),
legend.text = element_text(size=rel(1.5)) )

ctOut<-list(ctPlot=confThreshPlot,ctData=data)
return(ctOut)
Expand Down Expand Up @@ -180,17 +190,25 @@ typeLevels<-unique(echIntConf[,column1]) %>% as.vector
for (i in names(sortieParLCZ)){
output<-rbind(output,cbind(sortieParLCZ[[i]],LCZ=rep(i,nrow(sortieParLCZ[[i]]))))
}


pointSize<-13/sqrt(nPoints)
byLCZPLot<-ggplot(data=output, aes(x=Confidence, y=Agreement, color=Kept, shape=Kept))+
labs(x="Confidence threshold", color = "Geom set", shape="Geom set")+
labs(x="Confidence threshold", color = "Geom set", shape="Geom set",size=rel(1.3))+
scale_fill_discrete(breaks=c("confidence >= threshold","confidence < threshold"),)+
scale_color_manual(values =
c("confidence >= threshold" = "#00BFC4", "confidence < threshold" = "#F8766D"))+
geom_point() +
geom_text(aes(x=Confidence,y=Agreement,label=nbGeoms), nudge_y=-4.3)+
geom_point(size=rel(pointSize)) +
geom_text(aes(x=Confidence,y=Agreement,label=nbGeoms), nudge_y=-6.3,show.legend=FALSE,size=rel(pointSize))+
ggtitle(label="Agreement by minimum confidence within LCZ level",
subtitle="Number of geoms used to compute agreement written under each point")+
facet_wrap(~LCZ, drop=TRUE)
facet_wrap(~LCZ, drop=TRUE)+
theme(axis.title.x=element_text(size=rel(1.8)),
axis.title.y=element_text(size=rel(1.8)),
axis.text=element_text(size=rel(1.6)),
plot.title = element_text(size=rel(2)),
plot.subtitle = element_text(size=rel(1.8)),
legend.title=element_text(size=rel(1.8)),
legend.text = element_text(size=rel(1.5)))


if (plot==TRUE){
Expand Down
5 changes: 2 additions & 3 deletions R/produceAnalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ produceAnalysis<-function(location="Redon",
wf1="bdtopo_2_2",
wf2="osm",refYear1="2022",refYear2="2022",repr="standard",saveG=location,...)
{
wd<-getwd()
#setwd(outDir)

args<-list(...)
indSep<-names(args)
indCol<-grep(x=indSep,pattern="colors")
Expand Down Expand Up @@ -106,7 +105,7 @@ if(repr=="standard"){
nameG<-paste0(location,"_",wf1,"_",wf2,"_",repr)

# Compare LCZ
condition<-((wf1=="osm" | wf1=="bdtopo_2_2") & (wf2=="bdtopo_2_2" | wf2=="osm"))

if((wf1=="osm" | wf1=="bdtopo_2_2") & (wf2=="bdtopo_2_2" | wf2=="osm")){
print("compareLCZ called")

Expand Down
5 changes: 4 additions & 1 deletion inst/tinytest/test_confidSensib.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ confidTest1<-confidSensib(inputDf=testSourceFact, filePath="", nPoints=5,
"containing missing values")

expect_warning(
confidTest2<-confidSensib(filePath=paste0(system.file("extdata", package = "lczexplore"),"/bdtopo_2_2_osm.csv"), nPoints=5,
confidTest2<-confidSensib(filePath=paste0(
system.file("extdata", package = "lczexplore"),
"/bdtopo_2_2_osm.csv"),
nPoints=5,
wf1="bdtopo_2_2", wf2="osm",
geomID1="ID_RSU", column1="LCZ_PRIMARY", confid1="LCZ_UNIQUENESS_VALUE",
geomID2="ID_RSU.1",column2="LCZ_PRIMARY.1", confid2="LCZ_UNIQUENESS_VALUE.1",
Expand Down
2 changes: 1 addition & 1 deletion vignettes/lczexplore_alter.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ knitr::opts_chunk$set(
comment = "#>"
)
if (!require("png")) {
install.packages("png")
install.packages("png",repos = "http://cran.us.r-project.org")
library("png")
}
Expand Down
2 changes: 1 addition & 1 deletion vignettes/lczexplore_en.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ knitr::opts_chunk$set(
comment = "#>"
)
if (!require("png")) {
install.packages("png")
install.packages("png",repos = "http://cran.us.r-project.org")
library("png")
}
Expand Down
2 changes: 1 addition & 1 deletion vignettes/lczexplore_fr.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ knitr::opts_chunk$set(
)
if (!require("png")) {
install.packages("png")
install.packages("png",repos = "http://cran.us.r-project.org")
library("png")
}
Expand Down
2 changes: 1 addition & 1 deletion vignettes/lczexplore_raster_vector.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ knitr::opts_chunk$set(
comment = "#>"
)
if (!require("png")) {
install.packages("png")
install.packages("png",repos = "http://cran.us.r-project.org")
library("png")
}
Expand Down

0 comments on commit 26b0f06

Please sign in to comment.