Skip to content

Commit

Permalink
migrate add_coords function to package
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewkling committed Sep 11, 2019
1 parent 2c9c338 commit e82202c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
12 changes: 12 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ add_lat <- function(x){
stack(lat, x)
}

#' Augment a raster object, adding layers containing cell row-column indices.
#'
#' @param x raster layer or stack
#' @return the input layer, with an additional layer of latitude values
add_coords <- function(windrose){
rows <- cols <- windrose[[1]]
rows[] <- rep(1:nrow(rows), each=ncol(rows))
cols[] <- rep(1:ncol(rows), nrow(rows))
windrose <- stack(windrose, rows, cols)
names(windrose) <- c("SW", "W", "NW", "N", "NE", "E", "SE", "S", "row", "col")
return(windrose)
}

#' Get neighbor names for a windrose object
#'
Expand Down
17 changes: 17 additions & 0 deletions man/add_coords.Rd

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

0 comments on commit e82202c

Please sign in to comment.