Skip to content

Commit 9db86da

Browse files
authored
Merge pull request #136 from adamlilith/intuitive_fasterRaster
*fasterRaster* 8.4.1.1 (2025-11-18)
2 parents 4315f94 + 9489793 commit 9db86da

36 files changed

Lines changed: 395 additions & 177 deletions

.Rbuildignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ CODE_OF_CONDUCT.md
1212
^\.vscode
1313
^README\.Rmd$
1414
^.lintr$
15-
^fasterRaster.code-workspace
1615
^_pkgdown\.yml$
1716
^docs$
1817
^pkgdown$
1918
^\.github$
2019
^\vignettes\^junk
2120
junk
22-
fasterRaster_workspace.code-workspace
21+
workspace_fasterRaster.code-workspace
2322
^doc$
2423
^Meta$

.Rproj.user/shared/notebooks/paths

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
C:/Kaji/R/fasterRaster/DESCRIPTION="BE5F8589"
2+
C:/Kaji/R/fasterRaster/NEWS.md="B2E56A81"

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Package: fasterRaster
22
Type: Package
33
Title: Faster Raster and Spatial Vector Processing Using 'GRASS'
4-
Version: 8.4.1.0
5-
Date: 2025-06-19
4+
Version: 8.4.1.1
5+
Date: 2025-11-18
66
Authors@R:
77
c(
88
person(
@@ -47,4 +47,4 @@ VignetteBuilder: knitr
4747
Encoding: UTF-8
4848
LazyData: true
4949
LazyLoad: yes
50-
RoxygenNote: 7.3.2
50+
RoxygenNote: 7.3.3

NEWS.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
# fasterRaster 8.4.1.1 (2025-11-18)
2+
### New functions and functionality
3+
o `+` can now combine any two `GVector`s with the same geometry type (points, lines, polygons).
4+
o `installAddon()` checks to see if addon is already installed, and if so, uninstalls it before re-installing.
5+
o Minor documentation updates.
6+
7+
### Bug fixes
8+
o `fast()` correctly adds names to `GRaster`s loaded from disk when a `_names.csv` file exists.
9+
o `geomorphons()` now works when `mode = '2'`.
10+
o `rbind()` combines `GVector` data tables when each vecto has the same number of rows in its table as geometries.
11+
o `scale()` and `scalepop()` work when `center` and/or `scale` are numeric.
12+
o `sf` example data objects (`madCoast0`, `madCoast4`, and `madRivers`) have had their CRSs harmonized with the example raster objects. This had caused some of the examples not to work.
13+
14+
### Other
15+
o Added error checking in `fragmentation()` related to limits on size of window `w` for calculation of fragmentation indices.
16+
117
# fasterRaster 8.4.1.0 (2025-06-17)
218

319
### Code-breaking changes

R/04_arithmetic.r

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#' `*` operator: Same as [intersect()]\cr
99
#' `/` operator: Same as [xor()]\cr
1010
#'
11-
#' @param e1,e2 `GRaster`s, `numeric`s, `integer`s, or `logical`s.
11+
#' @param e1,e2 `GRaster`s, `GVector`s, `numeric`s, `integer`s, or `logical`s.
1212
#'
1313
#' @return A `GRaster`.
1414
#'
@@ -428,13 +428,21 @@ methods::setMethod(
428428
signature(e1 = "GVector", e2 = "GVector"),
429429
function(e1, e2) {
430430

431+
gtype1 <- geomtype(e1)
432+
gtype2 <- geomtype(e2)
433+
if (gtype1 != gtype2) stop("Vectors must be of the same type (polygons, lines, or points).")
434+
431435
compareGeom(e1, e2)
432436
.locationRestore(e1)
433437

434438
oper <- as.vector(.Generic)[1L]
435439

436440
if (oper == "+") {
437-
out <- union(e1, e2)
441+
if (gtype1 == "polygons" & gtype2 == "polygons") {
442+
out <- union(e1, e2)
443+
} else {
444+
out <- rbind(e1, e2)
445+
}
438446
} else if (oper == "-") {
439447
out <- erase(e1, e2)
440448
} else if (oper == "*") {

R/addons.r

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,24 @@ addons <- function(x = NULL) {
3636
installAddon <- function(x, check = TRUE) {
3737

3838
if (check) {
39+
40+
# is it available?
3941
avails <- rgrass::execGRASS("g.extension", flags = c("l", .quiet()), intern = TRUE)
4042
if (!(x %in% avails)) {
43+
4144
warning("The addon is not available on the official GRASS addon repository.")
4245
return(invisible(FALSE))
46+
4347
}
4448
}
4549

50+
# remove addon before re-installing
51+
if (addons(x)) removeAddon(x, check = FALSE)
52+
4653
rgrass::execGRASS("g.extension", operation = "add", extension = x, flags = .quiet())
47-
invisible(TRUE)
54+
success <- addons(x)
55+
if (!success) warning("Addon could not be installed.")
56+
invisible(success)
4857

4958
}
5059

R/backdoor.r

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,32 @@
22
#'
33
#' This is a secret function to be used for faster development of **fasterRaster**. It calls [faster()] to set the install directory for **GRASS**, increases default memory, and number of cores. The function assumes development is on a Windows machine.
44
#'
5+
#' @param start Logical: If `TRUE`, start the **GRASS** session by creating the `madElev` `GRaster`.
56
#' @param ver Character: **GRASS**: e.g., "83" or "84".
67
#'
78
#' @returns `TRUE` (invisibly).
89
#'
910
#' @keywords internal
10-
.backdoor <- function(ver = "84") {
11+
.backdoor <- function(start = FALSE, ver = "84") {
1112

1213
verNice <- paste0(substr(ver, 1L, 1L), ".", substr(ver, 2L, 2L))
1314

1415
faster(
1516
grassDir = paste0("C:/Program Files/GRASS GIS ", verNice),
16-
addonsDir = 'C:/Users/adame/AppData/Roaming/GRASS8/addons',
17+
addonsDir = "C:/Users/adame/AppData/Roaming/GRASS8/addons",
1718
memory = 1024 * 8,
1819
cores = 2,
1920
useDataTable = TRUE,
2021
verbose = TRUE
2122
)
22-
invisible(TRUE)
23+
24+
if (start) {
25+
madElev <- fastData("madElev")
26+
elev <- fast(madElev)
27+
out <- elev
28+
} else {
29+
out <- TRUE
30+
}
31+
32+
invisible(out)
2333
}

R/fast.r

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,16 @@ methods::setMethod(
179179

180180
xRast <- terra::rast(x)
181181
nLayers <- terra::nlyr(xRast)
182+
182183
xNames <- names(xRast)
184+
fileExtension <- .fileExt(x)
185+
nc <- nchar(fileExtension) + 1
186+
namesFile <- substr(x, 1, nchar(x) - nc)
187+
namesFile <- paste0(namesFile, '_names.csv')
188+
if (file.exists(namesFile)) {
189+
xNames <- utils::read.csv(namesFile)
190+
xNames <- xNames$name
191+
}
183192

184193
location <- .locationFind(xRast, match = "crs")
185194

R/fastData.r

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
#' @param x The name of the raster or spatial vector to get. All of these represent a portion of the eastern coast of Madagascar.
66
#'
77
#' Spatial vectors (objects of class `sf` from the **sf** package):
8-
#' * [madCoast0]: Outline of the region (polygon)
9-
#' * [madCoast4]: Outlines of the Fokontanies (Communes) of the region (polygons)
10-
#' * [madDypsis]: Records of plants of the genus *Dypsis* (points)
11-
#' * [madRivers]: Major rivers (lines)
8+
#' * [madCoast0][madCoast0]: Outline of the region (polygon)
9+
#' * [madCoast4][madCoast4]: Outlines of the Fokontanies (Communes) of the region (polygons)
10+
#' * [madDypsis][madDypsis]: Records of plants of the genus *Dypsis* (points)
11+
#' * [madRivers][madRivers]: Major rivers (lines)
1212
#'
1313
#' Rasters (objects of class `SpatRaster` from the **terra** package, saved as GeoTIFF files):
14-
#' * [madChelsa]: Bioclimatic variables
15-
#' * [madCover]: Land cover
16-
#' * [`madElev`][madElev]: Elevation
17-
#' * [madForest2000]: Forest cover in year 2000
18-
#' * [madForest2014]: Forest cover in year 2014
19-
#' * [madLANDSAT]: Surface reflectance in 2023
20-
#' * [madPpt], [madTmin], [madTmax]: Rasters of mean monthly precipitation, and minimum and maximum temperature.
14+
#' * [madChelsa][madChelsa]: Bioclimatic variables
15+
#' * [madCover][madCover]: Land cover
16+
#' * [madElev][madElev]: Elevation
17+
#' * [madForest2000][madForest2000]: Forest cover in year 2000
18+
#' * [madForest2014][madForest2014]: Forest cover in year 2014
19+
#' * [madLANDSAT][madLANDSAT]: Surface reflectance in 2023
20+
#' * [madPpt][madPpt], [madTmin][madTmin], [madTmax][madTmax]: Rasters of mean monthly precipitation, and minimum and maximum temperature.
2121
#'
2222
#' Data frames
23-
#' * [appFunsTable]: Table of functions usable by [app()]
24-
#' * [madCoverCats]: Land cover values and categories for [madCover]
25-
#' * [vegIndices]: Vegetation indices that can be calculated with [vegIndex()]
23+
#' * [appFunsTable][appFunsTable]: Table of functions usable by [app()]
24+
#' * [madCoverCats][madCoverCats]: Land cover values and categories for `madCover`
25+
#' * [vegIndices][vegIndices]: Vegetation indices that can be calculated with [vegIndex()]
2626
#'
2727
#' @return A `SpatRaster`, `sf` spatial vector, or a `data.frame`.
2828
#'

R/fasterRaster.r

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,11 @@
322322
#' * Vignette on **fasterRaster** hidden functions: `vignette("hidden_functions", package = "fasterRaster")`
323323
#'
324324
#' ## Classes
325-
#' * [`GLocation`]: Fundamental class; points to a "location/project" in **GRASS**
326-
#' * [`GSpatial`]: Basic class of any spatial object
327-
#' * [`GRegion`]: Points to a "region" of a "location/project" in **GRASS**
328-
#' * [`GRaster`]: Raster class
329-
#' * [`GVector`]: Spatial vector class
325+
#' * [GLocation][GLocation]: Fundamental class; points to a "location/project" in **GRASS**
326+
#' * [GSpatial][GSpatial]: Basic class of any spatial object
327+
#' * [GRegion][GRegion]: Points to a "region" of a "location/project" in **GRASS**
328+
#' * [GRaster][GRaster]: Raster class
329+
#' * [GVector][GVector]: Spatial vector class
330330
#'
331331
#' @author Adam B. Smith
332332
#' @name fasterRaster

0 commit comments

Comments
 (0)