diff --git a/R/CDORemap.R b/R/CDORemap.R index 8a210ca11948e994214eff7c053b19eec2330ce6..d0895228d52184e24410f202d1f43250ec552100 100644 --- a/R/CDORemap.R +++ b/R/CDORemap.R @@ -227,7 +227,8 @@ CDORemap <- function(data_array = NULL, lons, lats, grid, method, left_is_min <- TRUE prev_lon <- predict(lon_model, data.frame(i = 0)) first_lon_cell_width <- (tmp_lon[1] - prev_lon) - lon_extremes[1] <- tmp_lon[1] - first_lon_cell_width / 2 + # 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) } else { lon_extremes[1] <- min(tmp_lon) } @@ -235,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] <- tmp_lon[length(tmp_lon)] + last_lon_cell_width / 2 + lon_extremes[2] <- signif(tmp_lon[length(tmp_lon)] + last_lon_cell_width / 2, 6) } else { lon_extremes[2] <- max(tmp_lon) } @@ -282,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] <- tmp_lat[1] - (tmp_lat[1] - prev_lat) / 2 + lat_extremes[1] <- signif(tmp_lat[1] - (tmp_lat[1] - prev_lat) / 2, 6) } 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] <- tmp_lat[length(tmp_lat)] + (next_lat - tmp_lat[length(tmp_lat)]) / 2 + lat_extremes[2] <- signif(tmp_lat[length(tmp_lat)] + (next_lat - tmp_lat[length(tmp_lat)]) / 2, 6) } else { lat_extremes[2] <- max(tmp_lat) }