R/pr_read_riceatlas.R

Defines functions read_riceatlas

Documented in read_riceatlas

#' @title FUNCTION_TITLE
#' @description FUNCTION_DESCRIPTION
#' @param in_txt PARAM_DESCRIPTION
#' @param in_riceatlas_shp PARAM_DESCRIPTION
#' @param ISO PARAM_DESCRIPTION
#' @return OUTPUT_DESCRIPTION
#' @details DETAILS
#' @examples
#' \dontrun{
#' if(interactive()){
#'  #EXAMPLE1
#'  }
#' }
#' @rdname pr_read_riceatlas
#' @export
#' @author Lorenzo Busetto, phD (2017) <lbusett@gmail.com>
#' @importFrom dplyr filter left_join
#' @importFrom sf st_sf
#' @importFrom sprawl read_vect
read_riceatlas <- function(in_txt,
                           in_riceatlas_shp,
                           ISO){
  require(sf)
  in_data <- data.table::fread(in_txt)
  names(in_data)[1] = "OBJECTID"
  in_shape <- sprawl::read_vect(in_riceatlas_shp) %>%
    dplyr::filter(ISO == !!ISO)
  in_shape_geom <- in_shape[1]
  in_shape_long <- in_shape_geom %>%
    dplyr::left_join(in_data) %>%
    sf::st_sf(sf_column_name = "geometry")
  in_shape_long <- subset(in_shape_long, ISO == ISO)
  return(in_shape_long)
}
lbusett/phenoriceR documentation built on May 18, 2019, 9:17 p.m.