diff --git a/code/A98_PredictorsExtract.R b/code/A98_PredictorsExtract.R index fd9e1b3fe38f3fdfceb2cd5eeec8da15eec17e78..7b8aad7b91c56400a747021728484947191c5b65 100644 --- a/code/A98_PredictorsExtract.R +++ b/code/A98_PredictorsExtract.R @@ -7,11 +7,14 @@ PredExtr <- function(x.shp, myfunction=NA, output, require(doParallel) require(raster) require(rgeos) - + require(rgdal) + print(paste("Loading", typp, "data :", toextract)) if(typp=="raster"){ mypredictor <- raster(toextract)} else mypredictor <- readOGR(toextract) header.shp <-readOGR(x.shp) + crs(mypredictor) <- crs(header.shp) #should be verified beforehand! + ## Divide in chunks if requested if(chunkn>1 & !is.na(chunk.i)){ print(paste("divide in chunks and run on chunk n.", chunk.i)) @@ -41,6 +44,8 @@ PredExtr <- function(x.shp, myfunction=NA, output, } else { 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")) + nearest <- foreach(i=1:length(toassign), .packages=c('raster'), .combine=rbind) %dopar% { nearest.tmp <- geosphere::dist2Line(toassign[i,], mypredictor) diff --git a/code/cli_A98.r b/code/cli_A98.r index 5e0e49e7a2bf0af91d5be0a77ef58f1271bee4cf..178e1c1e4140f457502545007f14e354a3b9fef1 100644 --- a/code/cli_A98.r +++ b/code/cli_A98.r @@ -30,7 +30,7 @@ options <- list ( metavar = "4" ), make_option( - opt_str = c("-c", "--chunkn"), + opt_str = c("-n", "--chunkn"), dest = "chunkn", type = "integer", default = 1, diff --git a/code/submit-A98.sh b/code/submit-A98.sh index 0a54ff1edf72766ad78199df8fa80b88f1f43f32..28b7664cf47ef69548bbb94ee351c22b31560bd3 100644 --- a/code/submit-A98.sh +++ b/code/submit-A98.sh @@ -7,9 +7,9 @@ #$ -j y #$ -l h_rt=00:30:00:00 -#$ -l h_vmem=3G +#$ -l h_vmem=1G -#$ -pe smp 4-32 +#$ -pe smp 8-32 #$ -cwd @@ -26,10 +26,10 @@ output=/work/$USER/output_pred/$(basename $filename .shp).csv Rscript \ cli_A98.r \ --cores ${NSLOTS:-1} \ - --typp \ + --typp "shp" \ --chunk.i $SGE_TASK_ID \ --chunkn 99 \ - /data/splot/_data/header.shp.RData \ + /data/splot/_data_splot3/header.shp.shp \ robust.mean \ "$output" \ - "$filename" \ No newline at end of file + "$filename"