在GIS软件中,此过程仅需几秒钟。我在R中尝试执行此操作会占用大量内存,然后失败。我的代码中有什么问题吗,还是R不能做的事情?我已经读过R可以在Grass内部使用,我可以从R内部使用Grass函数吗?
library(raster)
# I have many environmental rasters in this format
new_r <- raster(ncol=615, nrow=626, xmn=-156.2, xmx=-154.8, ymn=18.89, ymx=20.30)
res(new_r) <- 0.00225
projection(new_r) <- "+proj=longlat +ellps=GRS80 +datum=NAD83 +no_defs +towgs84=0,0,0"
R> new_r ### not too big with a few hundred cells per side
class : RasterLayer
dimensions : 627, 622, 1 (nrow, ncol, nlayers)
ncell : 389994
resolution : 0.00225, 0.00225 (x, y)
projection : +proj=longlat +ellps=GRS80 +datum=NAD83 +no_defs +towgs84=0,0,0
extent : -156.2, -154.8, 18.89, 20.3 (xmin, xmax, ymin, ymax)
values : none
# I get the DEM at much higher resolution (zipfile is 182Mb)
zipurl <- "ftp://soest.hawaii.edu/coastal/webftp/Hawaii/dem/Hawaii_DEM.zip"
DEMzip <- download.file(zipurl, destfile = "DEMzip")
unzip("DEMzip", exdir = "HIDEM")
HIDEM <- raster("HIDEM/hawaii_dem")
R> HIDEM ### 10m resolution, file is way too big
class : RasterLayer
dimensions : 15067, 13136, 1 (nrow, ncol, nlayers)
ncell : 197920112
resolution : 10, 10 (x, y)
projection : +proj=utm +zone=5 +ellps=GRS80 +datum=NAD83 +units=m +no_defs +towgs84=0,0,0
extent : 179066, 310426, 2093087, 2243757 (xmin, xmax, ymin, ymax)
values : HIDEM/hawaii_dem
min value : 0
max value : 4200
# the following line fails (after a long time)
new_HIDEM <- projectRaster(HIDEM, new_r)
只是好奇,您使用的是什么软件包?
—
djq 2011年
@celenius:此软件包称为
—
J. Win。
raster