R:as.double(y) 中的错误:无法将类型“S4"强制转换为“double"类型的向量——栅格数据 [英] R: Error in as.double(y) : cannot coerce type 'S4' to vector of type 'double'-- raster data

查看:199
本文介绍了R:as.double(y) 中的错误:无法将类型“S4"强制转换为“double"类型的向量——栅格数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Studio 中使用光栅 .tif 图像.我看过有关使用下面的代码绘制栅格的教程,但是它对我不起作用.我收到错误:

Im working in Studio with a raster .tif image. I have watched a tutorial on plotting the raster with the code below, however it does not work for me. I get the error:

as.double(y) 中的错误:无法将类型S4"强制转换为double"类型的向量

我已经加载了必要的包(rasterrgdal)我也试过加载 arulesViz,但得到同样的错误

I have loaded the necessary packages(raster and rgdal) I have also tried loading the arulesViz, yet get the same error

YIELD <- raster("//Users//DevinOsborne//Desktop//Thesis//QGIS projects //Project//Rasters//Images//Yield_wheat.tif")

plot(YIELD,main= "Yield map")

推荐答案

要扩展 @Chelmy88 的答案,请尝试 sp::plot()您首先需要 sp 包;install.packages("sp")

To expand on @Chelmy88 s answer, try sp::plot() You will first need the sp package; install.packages("sp")

我能够使用 graphics::plot()

我相信当你加载 raster 库时,sp 也会被加载.

I believe that when you load raster library sp will also be loaded.

这篇关于R:as.double(y) 中的错误:无法将类型“S4"强制转换为“double"类型的向量——栅格数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆