R/lxy.proj.add.R

#' Specify the projection system for a LoCoH-xy object
#'
#' @param lxy \link{LoCoH-xy} object
#' @param proj4string An object of class "CRS", projection string 
#'
#' @return A \link{LoCoH-xy} object 
#'
#' @details This function will add projection information to a \link{LoCoH-xy} object. Note this does 
#' not reproject coordinates, it only adds or changes the projection information. Any existing projection
#' information will be overwritten.
#' 
#' @seealso \code{\link{CRS-class}} for arguments accepted by the \code{\link{CRS}} function.
#' @examples
#' # lxy <- lxy.proj.add(lxy, CRS("+proj=utm +south +zone=34"))
#'
#' @export
#' @import sp

lxy.proj.add <- function(lxy, proj4string=CRS(as.character(NA))) {

    if (!inherits(lxy, "locoh.lxy")) stop("lxy should be of class \"locoh.lxy\"")

    ## See if the proj4string is valid type
    if (!is(proj4string, "CRS")) stop("proj4string should be a class 'CRS'")
    
    lxy[["pts"]]@proj4string <- proj4string 
    
    return(lxy)
}

Try the tlocoh package in your browser

Any scripts or data that you put into this service are public.

tlocoh documentation built on May 2, 2019, 5:27 p.m.