在R中使用ggplot打印netcdf网格文件

在R中使用ggplot打印netcdf网格文件,r,plot,ggplot2,maps,netcdf,R,Plot,Ggplot2,Maps,Netcdf,我想使用正确的经度和纬度(在中求解)以及R的函数ggplot绘制一个netcdf文件 数据依赖于x,y,sigma。因此,选择了某个sigma(‘深度’)级别(sigma=20),将对其进行绘图(保存为变量sigma_绘图中的x*y双矩阵)。每个x和y对应于特定的经度(plon)和纬度(plat) 现在可以通过三种方式获得数据(如果需要详细信息,请查看上述问题): 答:这是一个长度为x*y*3的数组,其中3表示plon、plat和数据 B:x*y*3双矩阵 C:是一个列表[3],其中包含每个经

我想使用正确的经度和纬度(在中求解)以及R的函数ggplot绘制一个netcdf文件

数据依赖于x,y,sigma。因此,选择了某个sigma(‘深度’)级别(sigma=20),将对其进行绘图(保存为变量sigma_绘图中的x*y双矩阵)。每个x和y对应于特定的经度(plon)和纬度(plat)

现在可以通过三种方式获得数据(如果需要详细信息,请查看上述问题):

  • 答:这是一个长度为x*y*3的数组,其中3表示plon、plat和数据
  • B:x*y*3双矩阵
  • C:是一个列表[3],其中包含每个经纬度对应的绘图值,插入标准网格(xo=seq(-180180,1),yo=seq(-90,90,by=1))
然而,我不知道ggplot需要什么来正确地可视化这些。我尝试了以下方法:(我对ggplot不熟悉)

返回:

Error: ggplot2 doesn't know how to deal with data of class numeric
Error in `$<-.data.frame`(`*tmp*`, "xmin", value = numeric(0)) : 
  replacement has 0 rows, data has 180
In addition: Warning messages:
1: In min(x, na.rm = na.rm) :
  no non-missing arguments to min; returning Inf
2: In max(x, na.rm = na.rm) :
  no non-missing arguments to max; returning -Inf
3: In min(diff(sort(x))) : no non-missing arguments to min; returning Inf
4: In min(x, na.rm = na.rm) :
  no non-missing arguments to min; returning Inf
5: In max(x, na.rm = na.rm) :
  no non-missing arguments to max; returning -Inf
6: In min(diff(sort(x))) : no non-missing arguments to min; returning Inf
以及:

返回

Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous
Don't know how to automatically pick scale for object of type data.frame. Defaulting to continuous
Error in data.frame(x = list(x = c(-180, -179, -178, -177, -176, -175,  : 
  arguments imply differing number of rows: 361, 181
对我来说,这似乎是最符合逻辑的:

返回:

Error: ggplot2 doesn't know how to deal with data of class numeric
Error in `$<-.data.frame`(`*tmp*`, "xmin", value = numeric(0)) : 
  replacement has 0 rows, data has 180
In addition: Warning messages:
1: In min(x, na.rm = na.rm) :
  no non-missing arguments to min; returning Inf
2: In max(x, na.rm = na.rm) :
  no non-missing arguments to max; returning -Inf
3: In min(diff(sort(x))) : no non-missing arguments to min; returning Inf
4: In min(x, na.rm = na.rm) :
  no non-missing arguments to min; returning Inf
5: In max(x, na.rm = na.rm) :
  no non-missing arguments to max; returning -Inf
6: In min(diff(sort(x))) : no non-missing arguments to min; returning Inf

“$中的
错误有人对此有建议吗?也许@Paul Hiemstra对此有一些建议?他回答的其他问题有点不同,但我想他会知道一个解决方案吗?
Error in `$<-.data.frame`(`*tmp*`, "xmin", value = numeric(0)) : 
  replacement has 0 rows, data has 180
In addition: Warning messages:
1: In min(x, na.rm = na.rm) :
  no non-missing arguments to min; returning Inf
2: In max(x, na.rm = na.rm) :
  no non-missing arguments to max; returning -Inf
3: In min(diff(sort(x))) : no non-missing arguments to min; returning Inf
4: In min(x, na.rm = na.rm) :
  no non-missing arguments to min; returning Inf
5: In max(x, na.rm = na.rm) :
  no non-missing arguments to max; returning -Inf
6: In min(diff(sort(x))) : no non-missing arguments to min; returning Inf