我想在rasterVis中使用levelplot函数在栅格时间系列对象(rts)中显示结果。
这是一个简短的代码frome rts包:
library(raster)
library(rasterVis)
library(rts)
path <- system.file("external", package="rts")
lst <- list.files(path=path,pattern='.asc$',full.names=TRUE)
r <- stack(lst)
d <- c("2000-02-01","2000-03-01","2000-04-01","2000-05-01") # corresponding dates to 4 rasters
d <- as.Date(d)
# creating a RasterStackTS object:
rt <- rts(r,d)
从.rts强制攻击我使用的栅格:
r=rt@raster
proj=CRS("+proj=longlat +datum=NAD27 +no_defs +ellps=clrk66 +nadgrids=@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat")
proj4string(r) <- proj
wgs84.p4s <- CRS("+proj=longlat +datum=NAD83 +ellps=GRS80 +no_defs")
从r
UTM coordinates to latlong coordinates
rx <- projectRaster(from=r, crs=wgs84.p4s@projargs, method="ngb")
writeRaster(rt, file="myfile100.tif", format="GTiff", overwrite=TRUE)
ras = raster("myfile100.tif")
如何阅读myfile100.tif
中的所有4个图层?
ras = raster("myfile100.tif")
仅读取layer 1
proj4string(ras) <- proj
plot(ras)
levelplot(ras)
我收到此错误:
Error in projectExtent(from, projto) : cannot do this transformation
In addition: Warning message:
In rgdal::rawTransform(projfrom, projto, nrow(xy), xy[, 1], xy[, :
146 projected point(s) not finite
我该如何解决这个问题? 也许甚至有一个更短,更合理的方法来做到这一点。 谢谢你的建议。