Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: fasterRaster
Type: Package
Title: Faster Raster and Spatial Vector Processing Using 'GRASS'
Version: 8.4.1.1
Date: 2025-11-18
Version: 8.4.1.2
Date: 2026-04-17
Authors@R:
c(
person(
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export(grassInfo)
export(grassStarted)
export(installAddon)
export(is.polygons)
export(makeGRaster)
export(makeGVector)
export(mow)
export(pcs)
export(print)
Expand Down
14 changes: 12 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# fasterRaster 8.4.1.2 (2026-04-17)
### New functions and functionality
o `makeGRaster()` and `makeGVector()` are now public and allow users to create `G`-objects from files in **GRASS**. (feature request https://github.com/adamlilith/fasterRaster/issues/137 -- thank you, @JacobusS!)
o Updated citation to peer-reviewed journal article

### Bug fixes
o `app()` is more robust. Previously, short raster could have caused improper function. (issue https://github.com/adamlilith/fasterRaster/issues/138 -- thank you, @laurapoggio-sptools!)
o `bioclims()` properly calculates progress bar width so you know how long you have to go get a coffee.
o `resample()` correctly calculates number of rows in output raster.

# fasterRaster 8.4.1.1 (2025-11-18)
### New functions and functionality
o `+` can now combine any two `GVector`s with the same geometry type (points, lines, polygons).
Expand Down Expand Up @@ -261,7 +271,7 @@ o `rast()`: Attaches the `GRaster`'s levels table to the `SpatRaster` output.
o **+** `rasterize()`: Rewritten to perform (nearly) the same as `terra::rasterize()`.
o `predict()`: Can accommodate models with two-way interactions between categorical rasters and between a categorical predictor and a scalar.
o `scalepop()`: Scales `GRaster`s by population standard deviation.
o Stops with a somewhat informative error when a `GRaster` fails to be created (in hidden function `.makeGRaster()`)
o Stops with a somewhat informative error when a `GRaster` fails to be created (in hidden function `makeGRaster()`)

### Issues
o `writeRaster()`: Correctly assign `datatype` to `CELL` rasters.
Expand Down Expand Up @@ -315,7 +325,7 @@ o Updated `README` for 8.3.0.7013!

### Bug fixes
o `[` works consistently for `GVector`s!!!!!
o Hidden function `.makeGVector()` now catches cases with zero extent for polygons.
o Hidden function `makeGVector()` now catches cases with zero extent for polygons.
o Fixed installation issue related to `activeCat()<-` and `addCats()<-` (thank you, `@kbondo1`!)
o Fixed bug in `arithmetic` when determining data type of an input raster.
o `crds()` works when the **GRASS** vector has an attribute table.
Expand Down
16 changes: 10 additions & 6 deletions R/00d_GRaster_class.r
Original file line number Diff line number Diff line change
Expand Up @@ -144,22 +144,26 @@ methods::setValidity("GRaster",
} # EOF
)

#' Create a GRaster
#' Create a GRaster from a GRASS raster
#'
#' @description Create a `GRaster` from a raster existing in the current **GRASS** session.
#'
#' @param src Character (name of the raster in **GRASS) or a `rastInfo` object.
#' @param names Character: Name of the raster.
#' @param src Character: The name of the raster in **GRASS**.
#' @param names Character: Name of the raster (cf. [names()]).
#' @param levels `NULL` (default), a `data.frame`, `data.table`, an empty string (`""`), or a list of `data.frame`s, `data.table`s, and/or empty strings: These become the raster's [levels()]. If `""`, then no levels are defined.
#' @param ac Vector of numeric/integer values >=1, or `NULL` (default): Active category column (offset by 1, so 1 really means the second column, 2 means the third, etc.). A value of `NULL` uses an automated procedure to figure it out.
#' @param fail Logical: If `TRUE` (default), and the raster either has a 0 east-west or north-south extent, then exit the function with an error. If `fail` is `FALSE`, then display a warning and return `NULL`.
#'
#' @returns A `GRaster`.
#'
#' @seealso [.makeGVector()]
#' @seealso [makeGVector()]
#'
#' @keywords internal
.makeGRaster <- function(src, names = "raster", levels = "", ac = NULL, fail = TRUE) {
#' @example man/examples/ex_fast.r
#'
#' @aliases makeGRaster
#' @rdname makeGRaster
#' @export makeGRaster
makeGRaster <- function(src, names = "raster", levels = "", ac = NULL, fail = TRUE) {

if (inherits(src, "rastInfo")) {
info <- src
Expand Down
14 changes: 9 additions & 5 deletions R/00e_GVector_class.r
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ methods::setValidity("GVector",
} # EOF
)

#' Create a GVector
#' Create a GVector from a GRASS vector
#'
#' @description Create a `GVector` from a vector existing in the current **GRASS** session.
#'
Expand All @@ -58,16 +58,20 @@ methods::setValidity("GVector",
#'
#' @param extensive Logical: If `TRUE`, do extensive topological checks using `v.build`. The default is `FALSE`.
#'
#' @param cats `NULL` (default) or an integer vector: Values of the "cats" (categories) of the vector in **GRASS**. This is useful *only* for speeding up the `GVector` creation process when the "cats" have already been ascertained.
#' @param cats `NULL` (default) or an integer vector: Values of the "cats" (categories) of the vector in **GRASS**. This is useful *only* for speeding up the `GVector` creation process when the "cats" have already been ascertained. For most users, this will be better left as `NULL`.
#'
#' @param fail Logical: If `TRUE` (default), and the vector either has a 0 east-west or north-south extent, then exit the function with an error. If `fail` is `FALSE`, then display a warning and return `NULL`.
#'
#' @returns A `GVector` (or `NULL` if `fail` is `TRUE` and the `GVector` would be invalid).
#'
#' @seealso [.makeGRaster()]
#' @seealso [makeGRaster()]
#'
#' @keywords internal
.makeGVector <- function(src, table = NULL, build = TRUE, extensive = FALSE, cats = NULL, fail = TRUE) {
#' @example man/examples/ex_fast.r
#'
#' @aliases makeGVector
#' @rdname makeGVector
#' @export makeGVector
makeGVector <- function(src, table = NULL, build = TRUE, extensive = FALSE, cats = NULL, fail = TRUE) {

if (inherits(table, "GVector")) table <- table@table
if (is.null(table)) table <- data.table::data.table(NULL)
Expand Down
2 changes: 1 addition & 1 deletion R/04_arithmetic.r
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ methods::setMethod(
.genericArithRast <- function(name, src, ex) {

rgrass::execGRASS(cmd = "r.mapcalc", expression = ex, flags = c(.quiet(), "overwrite"))
.makeGRaster(src, name)
makeGRaster(src, name)

}

Expand Down
16 changes: 8 additions & 8 deletions R/05_GRaster_functions_by_layer.r
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ setMethod(
)

}
.makeGRaster(srcs, names(x))
makeGRaster(srcs, names(x))

} # EOF
)
Expand Down Expand Up @@ -101,7 +101,7 @@ methods::setMethod(
)

}
.makeGRaster(srcs, names(x))
makeGRaster(srcs, names(x))

}
)
Expand Down Expand Up @@ -251,7 +251,7 @@ setMethod(
)

}
.makeGRaster(srcs, names(x))
makeGRaster(srcs, names(x))

} # EOF
)
Expand All @@ -278,7 +278,7 @@ setMethod(
)

}
.makeGRaster(srcs, names(x))
makeGRaster(srcs, names(x))

} # EOF
)
Expand Down Expand Up @@ -404,7 +404,7 @@ setMethod(
)

}
.makeGRaster(srcs, names(x))
makeGRaster(srcs, names(x))

}

Expand All @@ -430,7 +430,7 @@ setMethod(
)
}

.makeGRaster(srcs, names(x))
makeGRaster(srcs, names(x))

}

Expand Down Expand Up @@ -459,7 +459,7 @@ setMethod(
)

}
.makeGRaster(srcs, names(x))
makeGRaster(srcs, names(x))

}

Expand Down Expand Up @@ -488,6 +488,6 @@ setMethod(
flags = c(.quiet(), "overwrite")
)
}
.makeGRaster(srcs, fx)
makeGRaster(srcs, fx)

}
12 changes: 6 additions & 6 deletions R/06_GRaster_functions_across_layers.r
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ setMethod(

.rm(c(srcSS, srcCount), type = "raster", warn = FALSE)

out <- .makeGRaster(src, "sd")
out <- makeGRaster(src, "sd")

# population standard deviation
} else {
Expand Down Expand Up @@ -307,7 +307,7 @@ setMethod(
)

.rm(c(srcSS, srcCount), type = "raster", warn = FALSE)
.makeGRaster(src, "var")
makeGRaster(src, "var")

} # EOF
)
Expand Down Expand Up @@ -401,7 +401,7 @@ setMethod(
if (na.rm) args$flags <- c(args$flags, "n")

do.call(rgrass::execGRASS, args = args)
.makeGRaster(src, fxName)
makeGRaster(src, fxName)

} # EOF
)
Expand All @@ -424,7 +424,7 @@ setMethod(
ex <- paste(ex, collapse = " | ")
ex <- paste0(src, " = ", ex)
rgrass::execGRASS("r.mapcalc", expression = ex, flags = c(.quiet(), "overwrite"))
.makeGRaster(src, "layer")
makeGRaster(src, "layer")

} # EOF
)
Expand All @@ -448,7 +448,7 @@ setMethod(
ex <- paste(ex, collapse = " & ")
ex <- paste0(src, " = ", ex)
rgrass::execGRASS("r.mapcalc", expression = ex, flags = c(.quiet(), "overwrite"))
.makeGRaster(src, "layer")
makeGRaster(src, "layer")

} # EOF
)
Expand Down Expand Up @@ -487,7 +487,7 @@ setMethod(
} else {
levels <- NULL
}
out <- .makeGRaster(src, fxName, levels = levels)
out <- makeGRaster(src, fxName, levels = levels)
} else if (return == "source") {
out <- src
} else {
Expand Down
4 changes: 2 additions & 2 deletions R/07_comparison.r
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ methods::setMethod(
}

} # next layer
out <- .makeGRaster(srcs, "logical", levels = cats(e1), ac = activeCats(e1))
out <- makeGRaster(srcs, "logical", levels = cats(e1), ac = activeCats(e1))
out

} # EOF
Expand Down Expand Up @@ -446,7 +446,7 @@ methods::setMethod(
}

} # next layer
out <- .makeGRaster(srcs, "logical", levels = cats(e2), ac = activeCats(e2))
out <- makeGRaster(srcs, "logical", levels = cats(e2), ac = activeCats(e2))
out

} # EOF
Expand Down
4 changes: 2 additions & 2 deletions R/aggregate.r
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ methods::setMethod(
levs <- NULL
}

this <- .makeGRaster(srcs[i], names = names(x)[i], levels = levs)
this <- makeGRaster(srcs[i], names = names(x)[i], levels = levs)
if (i == 1L) {
out <- this
} else {
Expand Down Expand Up @@ -210,7 +210,7 @@ methods::setMethod(

} # if data table has >= 2 rows

.makeGVector(src, table = aggTable)
makeGVector(src, table = aggTable)

} # EOF
)
Expand Down
Loading
Loading