Description Usage Arguments Value Author(s) See Also Examples
View source: R/downscaleautonet.R
This function is the iterative implementation of downscaling with autoencoder based residual network.
1 2 | ResautoDownscale(r2, fpredict0, c.grid, ss = 0.2, nepoch = 30,
cores = 1, thresh = 0.01, ntime = 5)
|
r2 |
Stack for the covariates for downscaling |
fpredict0 |
Target fine-resolution image to be downscaled, you can just provide a NA image data (this function can fill this NA) or an initial predictions obtained by other methods. |
c.grid |
Coarsely resolved grid |
ss |
Sampling propotion for independent test |
nepoch |
Numder of epoch for residual network training (default: 30) |
cores |
Number of CPU cores used for computing (default: 1) |
thresh |
Stopping creation shreshold (default: 0.01) |
ntime |
Maximum number of iterations (default: 5) |
List(performance metrics such as R2, RMSE, and downscaled images)
Lianfa Li lspatial@gmail.com
AutoEncoderModel
for the residual network function used in downscaling.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #Load the high-resolution raster of a covariate,
# elevation to be used for downscaling
eleFile=file.path(system.file(package = "downscaledl"), "extdata", "sample_ele.tif")
ele=raster::raster(eleFile)
#Load the coarse-resolution raster of the target variable to be downscaled
coarseFile=file.path(system.file(package = "downscaledl"), "extdata", "sample_coarse_res.tif")
coarseRst=raster::raster(coarseFile)
#Extract x and y to be used as two predictors in downscaling
xRast=ele
yRast=ele
pos=raster::rasterToPoints(ele,spatial=TRUE)
cell=raster::cellFromXY(xRast,pos)
xyc=sp::coordinates(pos)
xRast[cell]=xyc[,"x"]
yRast[cell]=xyc[,"y"]
#Merge the covariates
covStk=raster::stack(xRast,yRast,ele)
names(covStk)=c("x","y","ele")
#Use the fine-resolution covariate (elevation) as the target image
fineTarget=ele
#Set the paramneters and start to downscale ...
ares=ResautoDownscale(covStk,fineTarget,coarseRst,ss= 0.2, cores= 5, thresh = 0.01,ntime=3)
#Show the iteration results
message(paste(capture.output(ares$diogRMSE), collapse = "\n",sep=""))
#Show the optimal results in the final predictions
message(paste("test R2:",round(ares$r2,2),",test RMSE:",round(ares$rmse,4),sep=""))
#Obtain the downscaled
downscaled_img=ares$raster
#Save the current par setting
curpar = par(no.readonly = TRUE)
#Set the new par setting
par(mfrow=c(1,2),mar=c(1,1,1,1))
#Show the final predictions of fine resolution and
# original coarse-resolution image for a comparison
raster::plot(coarseRst)
raster::plot(downscaled_img)
#Restore the previous par setting
par(curpar)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.