【问题标题】:Plotting Data Points and Interpolating绘制数据点和插值
【发布时间】:2017-10-26 00:51:13
【问题描述】:

我想在地图上绘制数据并对其进行插值,但我不知道如何在 r 中执行此操作。这是我到目前为止所做的。

library(ggmap)

gc <- geocode("Rakiraki,Fiji")
Information from URL : http://maps.googleapis.com/maps/api/geocode/json?address=Rakiraki,Fiji&sensor=false
map <- get_map(gc)
Map from URL : http://maps.googleapis.com/maps/api/staticmap?center=-17.399264,178.070532&zoom=10&size=640x640&scale=2&maptype=terrain&language=en-EN&sensor=false
(bb <- attr(map, "bb"))
     ll.lat   ll.lon   ur.lat   ur.lon
1 -17.81878 177.6318 -16.9801 178.5107
(bbox <- bb2bbox(bb))
     left    bottom     right       top 
177.63177 -17.81878 178.51067 -16.98010 
ggmap(map) 
+ geom_point(
+ + aes(x = lon, y = lat),
+ + data = gc, colour = "red", size = 3
Error: unexpected '=' in:
"+ aes(x = lon, y = lat),
+ data ="
+ )
Error: unexpected ')' in "+ )"
data1 <-read.csv(file.choose(),header=T)
data1
  Longitude Latitude Wind.Speed
1     177.8    -17.6        4.0
2     177.5    -17.5        3.5
3     178.0    -17.4        4.5
4     178.1    -17.6        4.0
5     178.2    -17.3        6.0
6     178.3    -17.7        6.5
7     178.3    -17.5        5.0
8     178.4    -17.6        5.5

谁能告诉我如何绘制这些数据以及如何在地图上插值。

我希望最终的地图看起来像这样。请找附件enter image description here

【问题讨论】:

    标签: r google-maps unicode spatial-interpolation


    【解决方案1】:

    您问题中的代码存在很多问题。 geom_point 末尾的括号没有闭合,并且存在不应该存在的 + 符号。

    我假设您想将data1 中的数据添加到地图中,不同位置的风速。像这样的东西应该可以工作:

    ggmap(map) + 
      geom_point(aes(x = Longitude,
                     y = Latitude,
                     size = Wind.Speed),
                 data = data1, 
                 colour = "red")
    

    不清楚您所说的“插值”究竟是什么意思,但也许像 stat_density2d 这样的东西是您的想法?将其添加到上面的代码中:

    + stat_density2d(data = data1, 
                     aes(x = Longitude, y = Latitude))
    

    【讨论】:

    • 我想制作一个等值线图。你能告诉我如何去做吗?谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-08
    • 1970-01-01
    • 2021-04-21
    • 2021-05-30
    • 2016-03-20
    相关资源
    最近更新 更多