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

Minor adjustments to A98 and launched in array

parent f9ffacf5
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ PredExtr <- function(x.shp, myfunction=NA, output,
require(rgdal)
print(paste("Loading", typp, "data :", toextract))
print(paste("output will be:", output))
if(typp=="raster"){ mypredictor <- raster(toextract)} else
mypredictor <- readOGR(toextract)
header.shp <-readOGR(x.shp)
......@@ -45,13 +46,14 @@ PredExtr <- function(x.shp, myfunction=NA, output,
out <- sp::over(x=header.shp, y=mypredictor)
toassign <- header.shp[which(is.na(out[,1])),]
print(paste(length(toassign), "plots not matched directely - seek for NN"))
if(length(toassign)>0){
nearest <- foreach(i=1:length(toassign), .packages=c('raster'), .combine=rbind) %dopar% {
nearest.tmp <- geosphere::dist2Line(toassign[i,], mypredictor)
return(nearest.tmp)
}
out[which(is.na(out[,1])),] <- mypredictor@data[nearest[,"ID"],]
}
write.csv(out, file=output)
}
stopCluster(cl)
......
......@@ -3,7 +3,7 @@
#$ -S /bin/bash
#$ -N PredictorExtract
#$ -o /work/$USER/$JOB_NAME-$JOB_ID.log
#$ -o /work/$USER/$JOB_NAME-$JOB_ID-$TASK_ID.log
#$ -j y
#$ -l h_rt=00:30:00:00
......@@ -21,7 +21,7 @@ module load R
filename="$1"
shift
output=/work/$USER/output_pred/$(basename $filename .shp).csv
output=/data/splot/_data_splot3/output_pred/$(basename $filename .shp)-$SGE_TASK_ID.csv
Rscript \
cli_A98.r \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment