ghdc/Deploy/shud/Rfunction/nc2fishnet.R
2024-10-23 16:30:58 +08:00

11 lines
345 B
R

nc.fishnet <- function(x){
# fid = ncdf4::nc_open(fn)
# x=readnc.CMFD(ncid=fid, varid = varid)
# ncdf4::nc_close(fid)
res = mean(round(diff(x$x), 4))
xlim = range(x$x) + c(-1, 1)*res*0.5
ylim = range(x$y) + c(-1, 1)*res*0.5
spx = rSHUD::fishnet(xx=seq(xlim[1], xlim[2], by=res), yy=seq(ylim[1], ylim[2], by=res))
return(spx)
}