From 9d891eeecdc921b1f98135cd51a09fb0014c405a Mon Sep 17 00:00:00 2001 From: florisvdh Date: Fri, 8 May 2020 17:37:40 +0200 Subject: [PATCH] read_GRTSmh*(): use full proj4string; fixes #67 --- NAMESPACE | 1 + R/GRTSmh.R | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 4116d49b..e5ee8de1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -78,6 +78,7 @@ importFrom(rprojroot,is_rstudio_project) importFrom(sf,"st_crs<-") importFrom(sf,read_sf) importFrom(sf,st_centroid) +importFrom(sf,st_crs) importFrom(sf,st_drop_geometry) importFrom(sf,st_transform) importFrom(stats,setNames) diff --git a/R/GRTSmh.R b/R/GRTSmh.R index 88495b8d..d5ad3921 100644 --- a/R/GRTSmh.R +++ b/R/GRTSmh.R @@ -309,6 +309,8 @@ convert_base4frac_to_dec <- #' } #' #' @export +#' @importFrom sf +#' st_crs #' @importFrom raster #' raster #' brick @@ -335,7 +337,7 @@ read_GRTSmh <- } result <- r } - crs(result) <- "+init=epsg:31370" + crs(result) <- st_crs(31370)$proj4string return(result) } @@ -425,6 +427,8 @@ read_GRTSmh <- #' } #' #' @export +#' @importFrom sf +#' st_crs #' @importFrom raster #' raster #' crs<- @@ -432,7 +436,7 @@ read_GRTSmh_base4frac <- function(path = fileman_up("n2khab_data"), file = "20_processed/GRTSmh_base4frac/GRTSmh_base4frac.tif") { r <- raster(file.path(path, file)) - crs(r) <- "+init=epsg:31370" + crs(r) <- st_crs(31370)$proj4string return(r) } @@ -575,6 +579,7 @@ read_GRTSmh_base4frac <- #' @importFrom stringr str_c #' @importFrom sf #' read_sf +#' st_crs #' st_crs<- #' @importFrom raster #' raster @@ -607,7 +612,7 @@ read_GRTSmh_diffres <- str_c("GRTSmh_diffres.", level, ".tif"))) names(r) <- str_c("level", level) - crs(r) <- "+init=epsg:31370" + crs(r) <- st_crs(31370)$proj4string r }