Skip to content

Commit

Permalink
Check tests : some files still created and to be deleted after testing.
Browse files Browse the repository at this point in the history
Check references
Check author references.
  • Loading branch information
MGousseff committed Oct 24, 2023
1 parent 6fbe1f3 commit 00dccda
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 20 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: lczexplore
Title: lczexplore
Version: 0.0.1.0002
Version: 0.0.1.0003
Authors@R: c(
person("Matthieu", "Gousseff", , "[email protected]", role = c("aut", "cre")),
person(, "Centre National de la Recherche Scientifique, Lab-Sticc", role = "cph", comment = c(ORCID = "0000-0002-7106-2677"))
Expand Down
6 changes: 4 additions & 2 deletions docs/articles/joss/paper.bib
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,8 @@ @article{demuzere2022global
volume={2022},
pages={1--57},
year={2022},
publisher={G{\"o}ttingen, Germany}
publisher={G{\"o}ttingen, Germany},
doi = {10.5194/ems2022-83}
}

@article{demuzere2020combining,
Expand All @@ -267,5 +268,6 @@ @article{demuzere2020combining
number={1},
pages={264},
year={2020},
publisher={Nature Publishing Group UK London}
publisher={Nature Publishing Group UK London},
doi = {10.1038/s41597-020-00605-z}
}
8 changes: 5 additions & 3 deletions docs/articles/joss/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ One can then feed `compareLCZ` function these new groups, setting `repr="alter"

### Import and explore categorical variable (other than LCZ classifications)

This package focuses on LCZ maps comparison, but more often than not, people working on LCZ maps also
describe their area of interest with other categorical indicators.
The workflow of comparison of LCZ maps can be used for any pair of maps of categorical variables,
under certain limitations:
- there must not be more than 36 levels for the categorical variable to explore
Expand Down Expand Up @@ -354,7 +356,7 @@ deals with standard values of LCZ levels and colors.

# Plot the LCZ levels on the Redon Area using the default color set
# from the sf object produced by importLCZvect function
showLCZ(
map1<-showLCZ(
sf=redonOSM, column="LCZ_PRIMARY", repr="standard",
title="LCZ Classification on the French City of Redon")

Expand Down Expand Up @@ -519,7 +521,7 @@ It is the possible to perform the same analysis as on standard LCZ classificatio
as shown in the following example:

```r
showLCZ(redonOSMgrouped, column="grouped",repr="alter",
map2<-showLCZ(redonOSMgrouped, column="grouped",repr="alter",
title="Regrouped Categories for the city of Redon",
LCZlevels = c("urban","industry","vegetation","impervious","pervious","water"),
colors=c("red","black","green","grey","burlywood","blue"))
Expand Down Expand Up @@ -548,7 +550,7 @@ utrfRedonBDT<-importQualVar(dirPath=paste0(
system.file("extdata", package = "lczexplore"), "/bdtopo_2_2/Redon"),
file="rsu_utrf_area.geojson", column="TYPO_MAJ")

showLCZ(sf=utrfRedonBDT, column="TYPO_MAJ",repr="alter",
map3<-showLCZ(sf=utrfRedonBDT, column="TYPO_MAJ",repr="alter",
title = " UTRF classification of the French city of Redon")
```
![An example of some qualitative variable: Urban Typology by Random Forest (UTRF)](importQualVarUTRF.png)
Expand Down
54 changes: 53 additions & 1 deletion inst/tinytest/test_importLCZraster.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,66 @@ upCorner<-st_point(c(-117.227554,32.864593))
outBbox<-st_sfc(lowCorner,upCorner,crs=4326)
#importLCZraster("/home/gousseff/Documents/2_CodesSources/Wudapt/WudaptEurope/",bBox=outBbox)


# test bounding box not intersecting with rastet
expect_error(current = test<-importLCZraster(dirPath = system.file("extdata", package = "lczexplore"),fileName="redonWudapt.tif",bBox=outBbox),
"The bounding box doesn\'t intersect ")


# test chosing wich band of the raster is imported
redonWudapt2<-importLCZraster(
system.file("extdata", package = "lczexplore"),
fileName="redonWudapt.tif",bBox=redonBbox,
LCZband=1, LCZcolumn="LCZ")
str(redonWudapt2)

sidneyOSM<-importLCZvect(
dirPath = system.file("extdata/osm/2022/Sidney", package = "lczexplore"), file="sidney_rsu_lcz.geojson",
confid="LCZ_UNIQUENESS_VALUE",
geomID="ID_RSU")

sidneyBbox<-importLCZvect(
system.file("extdata/osm/2022/Sidney", package = "lczexplore"), file="sidney_rsu_lcz.geojson",
,output = "bBox")

# test default import

expect_warning(sidneyWudapt<-importLCZraster(system.file("extdata", package = "lczexplore"),
fileName="rasterMD.tif",bBox=sidneyBbox),
"attribute variables are assumed to be spatially constant throughout all geometries")

# test default specifying band number

expect_warning(sidneyWudapt<-importLCZraster(system.file("extdata", package = "lczexplore"),
fileName="redonWudapt.tif",bBox=redonBbox, LCZband=1, LCZcolumn='EU_LCZ_map'),
"attribute variables are assumed to be spatially constant throughout all geometries")


expect_error(sidneyWudapt<-importLCZraster(system.file("extdata", package = "lczexplore"),
fileName="redonWudapt.tif",bBox=redonBbox, LCZband=4, LCZcolumn='EU_LCZ_map'),
"invalid name")

# test importing a band that doesn't exist (wrong name)
expect_error(sidneyWudapt<-importLCZraster(system.file("extdata", package = "lczexplore"),
fileName="redonWudapt.tif",bBox=redonBbox, LCZband="Ski shoe", LCZcolumn='EU_LCZ_map'),
"invalid name")

# test importing several bands of the raster is imported, one being the confidence, one being numeric and the other the name of a band

expect_warning(sidneyWudapt<-importLCZraster(system.file("extdata", package = "lczexplore"),
fileName="rasterMD.tif", LCZband=1, LCZcolumn = "LCZraster",
confidenceBand = 3, confidenceColumn = "confidence",
bBox = sidneyBbox ),
"attribute variables are assumed to be spatially constant")

expect_warning(sidneyWudapt<-importLCZraster(system.file("extdata", package = "lczexplore"),
fileName="rasterMD.tif", LCZband="lcz", LCZcolumn = "LCZraster",
confidenceBand = 3, confidenceColumn = "confidence",
bBox = sidneyBbox ),
"attribute variables are assumed to be spatially constant")

# test importing several bands, one being wrong

expect_error(sidneyWudapt<-importLCZraster(system.file("extdata", package = "lczexplore"),
fileName="rasterMD.tif",bBox=sidneyBbox, LCZband=1, LCZcolumn='EU_LCZ_map',
confidenceBand = "skishoe", confidenceColumn = "confidence"),
"invalid name")
8 changes: 4 additions & 4 deletions vignettes/lczexplore_alter.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ redonOSMgrouped<-groupLCZ(redonOSM,column="LCZ_PRIMARY",
levCol(sf=redonOSMgrouped,column="grouped",LCZlevels = c("urban","industry","vegetation","impervious","pervious","water"),
colors=c("red","black","green","grey","burlywood","blue"))
showLCZ(redonOSMgrouped, column="grouped",repr="alter",wf="OSM",
map1<-showLCZ(redonOSMgrouped, column="grouped",repr="alter",wf="OSM",
LCZlevels = c("urban","industry","vegetation","impervious","pervious","water"),
colors=c("red","black","green","grey","burlywood","blue"))
Expand Down Expand Up @@ -168,7 +168,7 @@ utrfRedonBDT<-importQualVar(dirPath=paste0(
summary(utrfRedonBDT)
summary(utrfRedonBDT$TYPO_MAJ)
showLCZ(sf=utrfRedonBDT, column="TYPO_MAJ",repr="alter",
map3<-showLCZ(sf=utrfRedonBDT, column="TYPO_MAJ",repr="alter",
title = " UTRF classification of the French city of Redon",
colors=c("red","black","green","grey","burlywood","blue","orange","lightgreen","brown"))
```
Expand Down Expand Up @@ -231,7 +231,7 @@ If the values of the grouping vectors cover the original values of the datasets,

```{R, fig.dim = c(8, 6), echo = TRUE}
showLCZ(sf=redonBDT, column="LCZ_PRIMARY", repr="alter",
map4<-showLCZ(sf=redonBDT, column="LCZ_PRIMARY", repr="alter",
urban=c("1","2","3","4","5","6","7","8","9"),
industry="10",
vegetation=c("101","102","103","104"),
Expand All @@ -250,5 +250,5 @@ compareLCZ(sf1=redonBDT, column1="LCZ_PRIMARY",
```
This is meant as an exploratory tool, as the resulting grouped columns are not actually kept after the analysis.

Please feel free to contact us if some case are not handled by the package.
Please feel free to contact us if some cases are not handled by the package.

12 changes: 6 additions & 6 deletions vignettes/lczexplore_fr.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ L'argument `repr=standard` (valeur par défaut), permet de gérer les niveaux de
des cartes mises en forme avec des couleurs standardisées.

```{r, echo=FALSE, fig.dim = c(8, 6)}
showLCZ(sf=redonOSM, wf="OSM", column="LCZ_PRIMARY", repr="standard")
map1<-showLCZ(sf=redonOSM, wf="OSM", column="LCZ_PRIMARY", repr="standard")
```

On remarque que par défaut, tous les niveaux attendus d'une classification LCZ sont présents, ce qui peut faciliter l'exploration
Expand All @@ -101,7 +101,7 @@ Si on souhaite ne représenter que les niveaux présents dans les données, il s
niveaux absents ne seront pas représentés.

```{r, fig.dim = c(8, 6), echo = FALSE}
showLCZ(sf=redonOSM,wf="OSM",column="LCZ_PRIMARY",repr="standard",drop=TRUE)
map2<-showLCZ(sf=redonOSM,wf="OSM",column="LCZ_PRIMARY",repr="standard",drop=TRUE)
```


Expand All @@ -123,7 +123,7 @@ et les niveaux déduits des valeurs présentes.
```{r, fig.dim = c(8, 6), echo = FALSE}
# Choix d'un vecteur de couleurs alternatif aléatoire
testCol <- palette.colors(n=17, palette="Polychrome 36")
showLCZ(sf=redonOSM,wf="OSM",column="LCZ_PRIMARY",repr="alter",colors=testCol, useStandCol = FALSE)
map3<-showLCZ(sf=redonOSM,wf="OSM",column="LCZ_PRIMARY",repr="alter",colors=testCol, useStandCol = FALSE)
```

Expand All @@ -135,7 +135,7 @@ qui n'est pas présent dans les données, et on laisse la fonction choisir des c
```{r, fig.dim = c(8, 6), echo = FALSE}
LCZlevels<-c(2, 3, 5, 6, 8, 9, 10, 101, 102, 104, 105, 107)
showLCZ(sf=redonOSM,wf="OSM",column="LCZ_PRIMARY",repr="alter", LCZlevels = LCZlevels,drop=FALSE)
map4<-showLCZ(sf=redonOSM,wf="OSM",column="LCZ_PRIMARY",repr="alter", LCZlevels = LCZlevels,drop=FALSE)
```

On peut également renseigner le vecteur des couleurs qu'on souhaite utiliser en renseignant l'argument`colors`.
Expand All @@ -149,7 +149,7 @@ On peut renseigner les noms de couleurs connues de R ou un code RGB.
LCZlevels<-c(2, 3, 5, 6, 8, 9, 101, 102, 104, 105, 107)
couleurs<-c("red","brown1","orange","coral","grey","darkgreen","chartreuse4","springgreen3",
"darkolivegreen","black","#6d67fd")
showLCZ(sf=redonOSM,wf="OSM",column="LCZ_PRIMARY",repr="alter",drop=TRUE,LCZlevels=LCZlevels,colors=couleurs)
map5<-showLCZ(sf=redonOSM,wf="OSM",column="LCZ_PRIMARY",repr="alter",drop=TRUE,LCZlevels=LCZlevels,colors=couleurs)
```

Expand All @@ -175,7 +175,7 @@ redonOSMgrouped<-groupLCZ(redonOSM,column="LCZ_PRIMARY",
industry="10",
vegetation=c("101","102","103","104"),
impervious="105",pervious="106",water="107",colors=c("red","black","green","grey","burlywood","blue"))
showLCZ(redonOSMgrouped, column="grouped",repr="alter",wf="OSM",
map6<-showLCZ(redonOSMgrouped, column="grouped",repr="alter",wf="OSM",
LCZlevels = c("urban","industry","vegetation","impervious","pervious","water"),
colors=c("red","black","green","grey","burlywood","blue"))
Expand Down
6 changes: 3 additions & 3 deletions vignettes/lczexplore_raster_vector.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ For standard LCZ types, one sets the argument `repr="standard"`, and the functio


```{r, fig.dim = c(8, 6)}
showLCZ(sf = redonWudapt,column = 'EU_LCZ_map', repr= "standard")
map1<-showLCZ(sf = redonWudapt,column = 'EU_LCZ_map', repr= "standard")
```


Expand All @@ -119,8 +119,8 @@ summary(redonOSM$LCZ_PRIMARY)
```
## Visualize the resulting LCZ types with the function showLCZ
The resulting object is an sf object and can therefore also be visualized with the showLCZ function.
```{r, echo = TRUE }
showLCZ(sf = redonOSM, repr="standard")
```{r, fig.dim = c(8, 6), echo = TRUE }
map2<-showLCZ(sf = redonOSM, repr="standard")
```

Expand Down

0 comments on commit 00dccda

Please sign in to comment.