Skip to content

Commit

Permalink
Add FAQs
Browse files Browse the repository at this point in the history
  • Loading branch information
dieghernan committed Apr 2, 2024
1 parent d35820a commit 7a49208
Show file tree
Hide file tree
Showing 19 changed files with 89 additions and 22 deletions.
1 change: 1 addition & 0 deletions .github/workflows/revdepcheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@ jobs:
git add -A
git commit -m 'revdepcheck' || echo "No changes to commit"
git push origin || echo "No changes to commit"
2 changes: 1 addition & 1 deletion R/arrange-SpatVector.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Order a `SpatVector` using column values
#'
#' @description
#' [arrange.SpatVector()] orders the geometries of a `SpatVector` by the
#' `arrange.SpatVector()` orders the geometries of a `SpatVector` by the
#' values of selected columns.
#'
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/fortify-Spat.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' @rdname fortify.Spat
#' @name fortify.Spat
#'
#' @seealso [sf::st_as_sf()], [as_tibble.Spat], [as_spatraster()],
#' @seealso [sf::st_as_sf()], [`as_tibble.Spat`], [as_spatraster()],
#' [ggplot2::fortify()].
#'
#' @section Methods:
Expand Down
Binary file modified R/sysdata.rda
Binary file not shown.
4 changes: 2 additions & 2 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.3.3 (2024-02-29 ucrt)",
"runtimePlatform": "R version 4.3.3 (2024-02-29)",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
Expand Down Expand Up @@ -332,7 +332,7 @@
"SystemRequirements": null
},
"keywords": ["r", "terra", "ggplot-extension", "r-spatial", "rspatial", "r-package", "rstats", "rstats-package", "cran", "cran-r"],
"fileSize": "2268.959KB",
"fileSize": "2233.048KB",
"citation": [
{
"@type": "ScholarlyArticle",
Expand Down
Binary file modified data/cross_blended_hypsometric_tints_db.rda
Binary file not shown.
Binary file modified data/hypsometric_tints_db.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion inst/schemaorg.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"runtimePlatform": "R version 4.3.3 (2024-02-29 ucrt)",
"runtimePlatform": "R version 4.3.3 (2024-02-29)",
"version": "0.5.2.9000"
}
2 changes: 1 addition & 1 deletion man/arrange.SpatVector.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/fortify.Spat.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified vignettes/aggregate-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 14 additions & 15 deletions vignettes/articles/INPUBS.bib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@article{bahlburg2023,
title = {An intercomparison of models predicting growth of {Antarctic} krill ({Euphausia superba}): The importance of recognizing model specificity},
title = {An intercomparison of models predicting growth of {Antarctic krill (Euphausia superba)}: The importance of recognizing model specificity},
author = {Bahlburg, Dominik and Thorpe, Sally E. and Meyer, Bettina and Berger, Uta and Murphy, Eugene J.},
year = 2023,
month = {07},
Expand All @@ -12,8 +12,8 @@ @article{bahlburg2023
url = {https://doi.org/10.1371/journal.pone.0286036}
}
@phdthesis{chavez_sonoran_2023,
title = {Sonoran {Desert} {Ex} {Situ} {Conservation} {Gap} {Analysis}: {Charting} the {Path} {Toward} {Conservation}.},
shorttitle = {Sonoran {Desert} {Ex} {Situ} {Conservation} {Gap} {Analysis}},
title = {{Sonoran} {Desert} Ex Situ Conservation Gap Analysis: Charting the Path Toward Conservation.},
shorttitle = {{Sonoran} {Desert} Ex Situ Conservation Gap Analysis},
author = {Chavez, Maria},
year = 2023,
doi = {10.34885/E2HA-QE07},
Expand All @@ -24,7 +24,7 @@ @phdthesis{chavez_sonoran_2023
keywords = {FOS: Biological sciences}
}
@book{gibson_targeted_2023,
title = {Targeted sampling of {Toxolasma} parvum ({Lilliput}) in southwestern {Ontario}, 2022},
title = {Targeted sampling of {Toxolasma parvum (Lilliput)} in southwestern {Ontario}, 2022},
author = {Gibson, Mandy P. and McNichols-O’Rourke, Kelly A. and Morris, Todd J.},
year = 2023,
publisher = {Ontario and Prairie Region, Fisheries and Oceans Canada, Great Lakes Laboratory for Fisheries and Aquatic Sciences},
Expand All @@ -35,7 +35,7 @@ @book{gibson_targeted_2023
language = {eng}
}
@article{Lacko2023,
title = {{RCzechia}: Spatial Objects of the {Czech} {Republic}},
title = {{RCzechia}: Spatial Objects of the {Czech Republic}},
author = {Jindra Lacko},
year = 2023,
journal = {Journal of Open Source Software},
Expand All @@ -50,15 +50,15 @@ @article{Leonardi2023.07.24.550358
title = {{tidysdm}: leveraging the flexibility of {tidymodels} for Species Distribution Modelling in {R}},
author = {Michela Leonardi and Margherita Colucci and Andrea Manica},
year = 2023,
journal = {bioRxiv},
journal = {{bioRxiv}},
publisher = {Cold Spring Harbor Laboratory},
doi = {10.1101/2023.07.24.550358},
url = {https://www.biorxiv.org/content/early/2023/07/26/2023.07.24.550358},
elocation-id = {2023.07.24.550358},
eprint = {https://www.biorxiv.org/content/early/2023/07/26/2023.07.24.550358.full.pdf}
}
@article{meister2023,
title = {Blue mussels in western Norway have vanished where in reach of crawling predators},
title = {Blue mussels in western {Norway} have vanished where in reach of crawling predators},
author = {Nadja Meister and Tom J. Langbehn and Øystein Varpe and Christian Jørgensen},
year = 2023,
month = 10,
Expand All @@ -71,8 +71,8 @@ @article{meister2023
langid = {en}
}
@book{moraga_spatial_2023,
title = {Spatial {Statistics} for {Data} {Science}: {Theory} and {Practice} with {R}},
shorttitle = {Spatial {Statistics} for {Data} {Science}},
title = {Spatial Statistics for Data Science: Theory and Practice with {R}},
shorttitle = {Spatial Statistics for Data Science},
author = {Moraga, Paula},
year = 2023,
month = nov,
Expand All @@ -86,7 +86,7 @@ @book{moraga_spatial_2023
language = {en}
}
@manual{R-nasaacces,
title = {{NASAaccess}: Downloading and Reformatting Tool for {NASA} Earth Observation Data Products},
title = {{NASAaccess}: Downloading and Reformatting Tool for {NASA} {Earth Observation Data} Products},
author = {Ibrahim Mohammed},
year = 2024,
address = {Greenbelt, Maryland},
Expand All @@ -100,7 +100,7 @@ @article{turner2024
year = 2024,
month = {jan},
day = 23,
journal = {{npj} {Ocean Sustainability}},
journal = {{npj Ocean Sustainability}},
volume = 3,
number = 1,
pages = 4,
Expand Down Expand Up @@ -138,7 +138,7 @@ @article{Marcantonio2024.02.07.579266
title = {The {rasterdiv} package for measuring diversity from space},
author = {Matteo Marcantonio and Elisa Thouverau and Duccio Rocchini},
year = 2024,
journal = {bioRxiv},
journal = {{bioRxiv}},
publisher = {Cold Spring Harbor Laboratory},
doi = {10.1101/2024.02.07.579266},
url = {https://www.biorxiv.org/content/early/2024/02/13/2024.02.07.579266},
Expand All @@ -157,7 +157,7 @@ @article{lukovic2024
url = {https://doi.org/10.1007/s00704-024-04893-y}
}
@article{Poyhonen2024,
title = {High Arctic "hotspots" for sperm whales ({Physeter macrocephalus}) off western and northern {Svalbard, Norway}, revealed by multi-year {Passive Acoustic Monitoring (PAM)}},
title = {High {Arctic} "hotspots" for sperm whales ({Physeter macrocephalus}) off western and northern {Svalbard, Norway}, revealed by multi-year {Passive Acoustic Monitoring (PAM)}},
author = {Pöyhönen, Viivi and Thomisch, Karolin and Kovacs, Kit M. and Lydersen, Christian and Ahonen, Heidi},
year = 2024,
month = {Mar},
Expand Down Expand Up @@ -208,7 +208,7 @@ @article{10.1371/journal.pone.0296881
abstract = {Maps showing the thickness of sediments above the bedrock (depth to bedrock, or DTB) are important for many geoscience studies and are necessary for many hydrogeological, engineering, mining, and forestry applications. However, it can be difficult to accurately estimate DTB in areas with varied topography, like lowland and mountainous terrain, because traditional methods of predicting bedrock elevation often underestimate or overestimate the elevation in rugged or incised terrain. Here, we describe a machine learning spatial prediction approach that uses information from traditional digital elevation model derived estimates of terrain morphometry and satellite imagery, augmented with spatial feature engineering techniques to predict DTB across Alberta, Canada. First, compiled measurements of DTB from borehole lithologs were used to train a natural language model to predict bedrock depth across all available lithologs, significantly increasing the dataset size. The combined data were then used for DTB modelling employing several algorithms (XGBoost, Random forests, and Cubist) and spatial feature engineering techniques, using a combination of geographic coordinates, proximity measures, neighbouring points, and spatially lagged DTB estimates. Finally, the results were contrasted with DTB predictions based on modelled relationships with the auxiliary variables, as well as conventional spatial interpolations using inverse-distance weighting and ordinary kriging methods. The results show that the use of spatially lagged variables to incorporate information from the spatial structure of the training data significantly improves predictive performance compared to using auxiliary predictors and/or geographic coordinates alone. Furthermore, unlike some of the other tested methods such as using neighbouring point locations directly as features, spatially lagged variables did not generate spurious spatial artifacts in the predicted raster maps. The proposed method is demonstrated to produce reliable results in several distinct physiographic sub-regions with contrasting terrain types, as well as at the provincial scale, indicating its broad suitability for DTB mapping in general.}
}
@article{10.3390/horticulturae10040326,
title = {Distribution of {Plasmopara viticola} Causing Downy Mildew in Russian Far East Grapevines},
title = {Distribution of {Plasmopara viticola} Causing Downy Mildew in {Russian} Far East Grapevines},
author = {Nityagovsky, Nikolay N. and Ananev, Alexey A. and Suprun, Andrey R. and Ogneva, Zlata V. and Dneprovskaya, Alina A. and Tyunin, Alexey P. and Dubrovina, Alexandra S. and Kiselev, Konstantin V. and Sanina, Nina M. and Aleynova, Olga A.},
year = 2024,
journal = {Horticulturae},
Expand All @@ -219,4 +219,3 @@ @article{10.3390/horticulturae10040326
doi = {10.3390/horticulturae10040326},
url = {https://doi.org/10.3390/horticulturae10040326}
}

67 changes: 67 additions & 0 deletions vignettes/articles/faqs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,73 @@ ggplot(aoi) +
)
```

## Hexagonal grids (and other `geoms`)

By concept the cells of a `SpatRaster` are rectangular, so it is not possible to
create a `SpatRaster` with i.e. hexagonal cells.

But it is possible to create a plot with hexagonal cells thanks to
`fortify.SpatRaster()` and `stat_summary_hex()`. Additional work is needed to
adjust the final plot, specifically it is needed also to use `coord_sf()`:

```{r hex_grid}
library(terra)
library(tidyterra)
library(ggplot2)
volcanotemp <- "volcano2hires.tif"
# Download example file
volcanourl <- paste0(
"https://github.com/dieghernan/tidyterra/blob/main/",
"data-raw/volcano2hires.tif?raw=true"
)
if (!file.exists(volcanotemp)) {
download.file(volcanourl, volcanotemp, mode = "wb")
}
r <- rast(volcanotemp)
# With hex grid
ggplot(r, aes(x, y, z = elevation)) +
stat_summary_hex(
fun = mean, color = NA, linewidth = 0,
# Bins size determines the number of cells displayed
bins = 30
) +
coord_sf(crs = pull_crs(r)) +
labs(
title = "Hexagonal SpatRaster",
subtitle = "Using fortify (implicit) and stat_summary_hex",
x = NULL, y = NULL
)
```

Note that there is no need to make a direct call to `fortify.SpatRaster()`,
since this function is implicitly invoked by **ggplot2** when using
`ggplot(data = a_spatraster)`.

Thanks to this extension mechanism, it is possible to use additional `geoms` and
`stats` provided by **ggplot2**:

```{r alt_points}
# Point plot
ggplot(r, aes(x, y, z = elevation), maxcell = 1000) +
geom_point(aes(size = elevation, alpha = elevation),
fill = "darkblue",
color = "grey50", shape = 21
) +
coord_sf(crs = pull_crs(r)) +
scale_radius(range = c(1, 5)) +
scale_alpha(range = c(0.01, 1)) +
labs(
title = "SpatRaster as points",
subtitle = "Using fortify (implicit)",
x = NULL, y = NULL
)
```

## Session info

<details>
Expand Down
Binary file modified vignettes/contourlines-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/faceted-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/hypso-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/lux_ggplot-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/rgb-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified vignettes/spatraster-example1-1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7a49208

Please sign in to comment.