Skip to content

Commit

Permalink
fix factor handling #18
Browse files Browse the repository at this point in the history
  • Loading branch information
tgoodbody committed Jul 19, 2022
1 parent 34cb0de commit a6a5fcf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/sample_strat.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ sample_strat <- function(sraster,
if(!is.null(terra::cats(sraster)[[1]])){
message("'sraster' has factor values. Converting to allow mapping.")

#--- change suggested by R Hijmans ---#
sraster_cats <- cats(sraster) %>%
as.data.frame()
colnames(sraster_cats)[1] <- "value"

}

Expand Down Expand Up @@ -333,8 +335,6 @@ sample_strat <- function(sraster,

### --- sampling ---###

### --- RULE 1: select only cells surrounded by cells with same strata ---###

suppressWarnings(strat_mask <-
terra::focal(
strata_m,
Expand Down

0 comments on commit a6a5fcf

Please sign in to comment.