You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
raster_url <- "ftp://ftp.data.pgc.umn.edu/elev/dem/setsm/REMA/mosaic/v1.1/200m/REMA_200m_dem.tif"
readfrom_file <- tempfile(pattern = "readfrom", fileext = ".tif")
writeto_file <- tempfile(pattern = "writeto", fileext = ".tif")
## file size is 1.3Gb
curl::curl_download(raster_url, readfrom_file)
## this now makes a copy of the 1.3Gb file, so we have two of them
fs::file_copy(readfrom_file, writeto_file)
Now we want the tiling
info <- vapour::vapour_raster_info(readfrom_file)
tiling <- list(dimension = info$dimXY, tiles = info$tilesXY)
fac <- 100
fac * tiling$tiles
if (tiling$tiles[2] == 1) {
## let's take fac scanlines at a time
tiling$tiles[2] <- fac
}
calc_steps <- function(dimension, tiles) {
bounds_x <- seq(0, dimension, by = tiles)
steps_x <- rep(tiles, length.out = length(bounds_x)-1)
dangle_x <- sum(steps_x) -dimension
if (dangle_x > 0) steps_x[length(steps_x)] <- steps_x[length(steps_x)] - dangle_x
list(head(bounds_x, -1), steps_x)
}
x_step <- calc_steps(tiling$dimension[1], tiling$tiles[1])
y_step <- calc_steps(tiling$dimension[2], tiling$tiles[2])
y_step
system.time({
for (i in seq_along(x_step[[1]])) {
startx <- x_step[[1]][i]
countx <- x_step[[2]][i]
for (j in seq_along(y_step[[1]])) {
starty <- y_step[[1]][j]
county <- y_step[[2]][j]
## now read
offset <- c(startx, starty)
dimension <- c(countx, county)
vals <- vapour:::vapour_read_raster_block(readfrom_file, offset = offset, dimension = dimension, band_output_type = info$datatype, band = 1)[[1L]]
## do something to the values
if (any(na.omit(vals) > info$nodata_value)) {
vals <- vals * -1
vapour:::vapour_write_raster_block(writeto_file, vals, offset, dimension, band = 1, overwrite = TRUE)
}
}
}
The text was updated successfully, but these errors were encountered:
mdsumner
changed the title
compare this tiling schemed
compare this tiling scheme
May 5, 2022
started a blog post, compare with .tilescheme
Now we want the tiling
The text was updated successfully, but these errors were encountered: