From ad1e6425dc6347ae8dcc4cb526379bc0ba2b863f Mon Sep 17 00:00:00 2001 From: lbusett Date: Tue, 9 Jun 2020 10:11:49 +0200 Subject: [PATCH] improve accordance of basegeo with envi --- R/prisma_basegeo.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R/prisma_basegeo.R b/R/prisma_basegeo.R index aedf3d7..840792c 100644 --- a/R/prisma_basegeo.R +++ b/R/prisma_basegeo.R @@ -48,13 +48,15 @@ prisma_basegeo <- function(band, lon, lat, fill_gaps = TRUE) { minlat <- min(lat, na.rm = TRUE) vals <- raster::values(band) - columns <- round((lon - minlon) / psize_x) + columns <- round((lon - minlon) / psize_x) + 1 rows <- nrows - round((lat - minlat) / psize_y) # columns <- round((lon - minlon) / psize_x) + 1 # rows <- nrows - round((lat - minlat) / psize_y) - 1 - # columns[columns > ncols] <- 0 - # rows[rows > nrows] <- 0 + + #♫ remove data if out of bounds to avoid potential crashes + columns[columns > ncols] <- 0 + rows[rows > nrows] <- 0 for (indpix in 1:(numlines*numcols)) { out_grd[rows[indpix], columns[indpix]] <- vals[indpix]