0

我想使用 rasterVis 中的 levelplot 函数在栅格时间序列对象 (rts) 中显示结果。

这是来自 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")

如何读取所有 4 层myfile100.tifras = 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

我怎样才能解决这个问题?也许还有一种更短更合理的方法来做到这一点。感谢您的建议。

4

0 回答 0