Skip to content
Snippets Groups Projects
Commit 7012e0e3 authored by Francesco Sabatini's avatar Francesco Sabatini
Browse files

Changed A97 to skip malfunctionng tiles

parent 3a5ebefd
No related branches found
No related tags found
No related merge requests found
...@@ -486,10 +486,10 @@ done <- NULL ...@@ -486,10 +486,10 @@ done <- NULL
done <- as.numeric(unlist(regmatches(myfiles, gregexpr("[[:digit:]]+", myfiles)))) done <- as.numeric(unlist(regmatches(myfiles, gregexpr("[[:digit:]]+", myfiles))))
todo <- 1:nlevels(header.tiles$tilenam) todo <- 1:nlevels(header.tiles$tilenam)
todo <- todo[-which(todo %in% done)] todo <- todo[-which(todo %in% done)]
todo <- sample(todo, replace=F) #todo <- sample(todo, replace=F)
#foreach(i = 1:nlevels(header.sp$tilenam)) %do% { #foreach(i = 1:nlevels(header.sp$tilenam)) %do% {
foreach(i = todo) %dopar% { #foreach(i = todo) %dopar% {
#for(i in todo){ for(i in todo){
#create sp and project data #create sp and project data
if(nrow(header.tiles %>% if(nrow(header.tiles %>%
filter(tilenam %in% levels(header.tiles$tilenam)[i])) ==0 ) next() filter(tilenam %in% levels(header.tiles$tilenam)[i])) ==0 ) next()
...@@ -508,10 +508,12 @@ foreach(i = todo) %dopar% { ...@@ -508,10 +508,12 @@ foreach(i = todo) %dopar% {
tryCatch(raster.tile <- get_elev_raster(sp.tile, z=9, expand=max(sp.tile$`Location uncertainty (m)`), clip="bbox"), tryCatch(raster.tile <- get_elev_raster(sp.tile, z=9, expand=max(sp.tile$`Location uncertainty (m)`), clip="bbox"),
error = function(e){e} error = function(e){e}
) )
if(inherits(raster.tile, "error")) { if(!exists("raster.tile")) {
raster.tile <- NA raster.tile <- NA
save(raster.tile, file = paste("../_derived/elevatr/Failed_tile_", i, ".RData", sep="")) save(raster.tile, file = paste("../_derived/elevatr/elevation_tile_", i, "failed.RData", sep=""))
next(paste("tile", i, "doesn't work!, skip to next")) message(paste("tile", i, "doesn't work!, skip to next"))
rm(raster.tile)
next
} }
# clip dem tile with continent shape # clip dem tile with continent shape
raster.tile <- mask(raster.tile, continent.high.merc) raster.tile <- mask(raster.tile, continent.high.merc)
......
...@@ -74,10 +74,12 @@ ElevationExtract <- function(header, output, ncores){ ...@@ -74,10 +74,12 @@ ElevationExtract <- function(header, output, ncores){
tryCatch(raster.tile <- get_elev_raster(sp.tile, z=9, expand=max(sp.tile$lc_ncrt), clip="bbox"), tryCatch(raster.tile <- get_elev_raster(sp.tile, z=9, expand=max(sp.tile$lc_ncrt), clip="bbox"),
error = function(e){e} error = function(e){e}
) )
if(inherits(raster.tile, "error")) { if(!exists("raster.tile")) {
raster.tile <- NA raster.tile <- NA
save(raster.tile, file = paste(output, "elevation_tile_", i, "failed.RData", sep="")) save(raster.tile, file = paste(output, "elevation_tile_", i, "failed.RData", sep=""))
next(paste("tile", i, "doesn't work!, skip to next")) message(paste("tile", i, "doesn't work!, skip to next"))
rm(raster.tile)
next
} }
# clip dem tile with continent shape # clip dem tile with continent shape
raster.tile <- mask(raster.tile, continent.high.merc) raster.tile <- mask(raster.tile, continent.high.merc)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment