将三个向量(lat,lon,value)转换为R中的栅格对象

时间:2016-08-13 13:05:55

标签: r raster

我有三个数字向量描述:

  • lat - lattitude
  • long-longitute
  • value - 指定点的值(对于由pai lat和long定义的特定位置的点)

如何从中创建栅格对象? 我试图用cbind来组合它们:

# I prefer pacman::p_load(raster) to load package
library('raster')

# Sample very small subset of data:
lat <- c(84.6564178466797, 84.6564178466797, 83.3252105712891, 82.2175979614258, 
80.3753433227539, 78.830451965332, 83.3252105712891)
long <- c(-145.316390991211, -70.6275939941406, -135.606842041016, -113.573654174805, 
-102.370330810547, -104.610992431641, -79.5902481079102)
value <- c(0.379887759685516, 0.297680675983429, 0.259096682071686, 0.195639669895172, 
0.259653329849243, 0.278579145669937, 0.333345)

myMatrix <- cbind(lat,long,value)

#this raster seems to be *incorrect*, because it shows: values: -145.3164, 84.65642  (min, max)
raster(myMatrix)

#Following causes an error (x cell sizes are not regular):
rasterFromXYZ(myMatrix)

但创建的对象存储的值不正确。

我是否需要先创建一个矩阵,如this主题中所述?

0 个答案:

没有答案