R levelplot,非连续的纬度和经度值
我有表示为纬度-经度的数据集和与每个纬度-经度对关联的值(名为“类”),我想将其表示为在“R”的“lattice”包下使用levelplot()或contourplot() ”。 示例数据集如下所示:
> data_2[510:520,]
lon lat class
510 -47.61849 40.00805 2
511 -47.36740 40.01180 1
512 -47.11629 40.01551 1
513 -46.86518 40.01918 1
514 -46.61404 40.02282 1
515 -46.36290 40.02642 3
516 -46.11173 40.02999 1
517 -45.86056 40.03352 1
518 -45.60937 40.03700 3
519 -45.35817 40.04045 3
520 -45.10695 40.04386 3
主数据集中的经度和纬度值不连续。
我的问题是我没有所有纬度-经度组合的“类”值,因此,当我尝试绘制上述值时,留下了很多空白空间。我想要的是获得一个连续的、填充的(对于所有经纬度组合)图。
以下是我尝试绘制的方法之一的示例:
levelplot(data_2$class ~ data_2$lon * data_2$lat,data = data_2,region = TRUE,aspect =“fill”)
levelplot() 或contourplot() 函数中是否有可用的选项可以用来实现此目的或者“R”中是否有其他包/方法可以帮助我提出这个解决方案?
I have data-set represented as latitude-longitude and a VALUE(named "class") associated with each latitude-longitude pair, which i want to represent as using levelplot() or contourplot() under the "lattice" package for "R".
sample dataset looks like this:
> data_2[510:520,]
lon lat class
510 -47.61849 40.00805 2
511 -47.36740 40.01180 1
512 -47.11629 40.01551 1
513 -46.86518 40.01918 1
514 -46.61404 40.02282 1
515 -46.36290 40.02642 3
516 -46.11173 40.02999 1
517 -45.86056 40.03352 1
518 -45.60937 40.03700 3
519 -45.35817 40.04045 3
520 -45.10695 40.04386 3
The longitude and latitude values in the main dataset are not continuous.
My problem is I do not have "class" value for all the latitude-longitude combinations, and due to this there are lot of empty spaces left when i am trying to plot the above values. What I want is to get a continuous, filled (for all lat-long combinations) plot.
The following is an example of one of the ways i am trying to plot:
levelplot(data_2$class ~ data_2$lon * data_2$lat, data = data_2, region = TRUE, aspect = "fill")
Are there any options available in the levelplot() or contourplot() functions which i can use to achieve this or is there any other package/method in "R" which could help me come up with this solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议您查看免费电子书“地统计绘图实用指南”(http://spatial-analyst.net/book/download),以回顾空间估计方法,其中包含大量 R 示例。
正如 Ben 指出的,您需要进行某种空间插值。以下是使用
intamap
包中的interpolate
函数的快速示例:I recommend taking a look at the free ebook "A Practical Guide to Geostatistical Mapping" (http://spatial-analyst.net/book/download) for a review of spatial estimation methods with plenty of examples in R.
As Ben pointed out, you'll need to do some sort of spatial interpolation. Here's a quick example using the
interpolate
function in theintamap
package:您需要首先进行某种插值。
akima
包可能是您最好的选择,请参阅?akima
中的示例。 gstat::krige 是另一种可能性。You need to do some kind of interpolation first. The
akima
package is probably your best bet, see the examples in?akima
.gstat::krige
is another possibility.