diff --git a/R/CDORemap.R b/R/CDORemap.R index d0895228d52184e24410f202d1f43250ec552100..49bd9dbe1d280f64248442f9a66c37b3c741682f 100644 --- a/R/CDORemap.R +++ b/R/CDORemap.R @@ -228,7 +228,7 @@ CDORemap <- function(data_array = NULL, lons, lats, grid, method, prev_lon <- predict(lon_model, data.frame(i = 0)) first_lon_cell_width <- (tmp_lon[1] - prev_lon) # The signif is needed because cdo sellonlatbox crashes with too many digits - lon_extremes[1] <- signif(tmp_lon[1] - first_lon_cell_width / 2, 6) + lon_extremes[1] <- tmp_lon[1] - first_lon_cell_width / 2 } else { lon_extremes[1] <- min(tmp_lon) } @@ -236,7 +236,7 @@ CDORemap <- function(data_array = NULL, lons, lats, grid, method, right_is_max <- TRUE next_lon <- predict(lon_model, data.frame(i = length(tmp_lon) + 1)) last_lon_cell_width <- (next_lon - tmp_lon[length(tmp_lon)]) - lon_extremes[2] <- signif(tmp_lon[length(tmp_lon)] + last_lon_cell_width / 2, 6) + lon_extremes[2] <- tmp_lon[length(tmp_lon)] + last_lon_cell_width / 2 } else { lon_extremes[2] <- max(tmp_lon) } @@ -283,13 +283,13 @@ CDORemap <- function(data_array = NULL, lons, lats, grid, method, lat_extremes <- c(NA, NA) if (which.min(tmp_lat) == 1) { prev_lat <- predict(lat_model, data.frame(i = 0)) - lat_extremes[1] <- signif(tmp_lat[1] - (tmp_lat[1] - prev_lat) / 2, 6) + lat_extremes[1] <- tmp_lat[1] - (tmp_lat[1] - prev_lat) / 2 } else { lat_extremes[1] <- min(tmp_lat) } if (which.max(tmp_lat) == length(tmp_lat)) { next_lat <- predict(lat_model, data.frame(i = length(tmp_lat) + 1)) - lat_extremes[2] <- signif(tmp_lat[length(tmp_lat)] + (next_lat - tmp_lat[length(tmp_lat)]) / 2, 6) + lat_extremes[2] <- tmp_lat[length(tmp_lat)] + (next_lat - tmp_lat[length(tmp_lat)]) / 2 } else { lat_extremes[2] <- max(tmp_lat) } @@ -508,8 +508,10 @@ CDORemap <- function(data_array = NULL, lons, lats, grid, method, } sellonlatbox <- '' if (crop) { - sellonlatbox <- paste0('sellonlatbox,', lon_extremes[1], ',', lon_extremes[2], - ',', lat_extremes[1], ',', lat_extremes[2], ' -') + sellonlatbox <- paste0('sellonlatbox,', format(lon_extremes[1], scientific = FALSE), + ',', format(lon_extremes[2], scientific = FALSE), + ',', format(lat_extremes[1], scientific = FALSE), + ',', format(lat_extremes[2], scientific = FALSE), ' -') } err <- try({ system(paste0("cdo -s ", sellonlatbox, "remap", method, ",", grid, " ", tmp_file, " ", tmp_file2))