在scala中调用http时出现Netcdf错误

时间:2018-07-09 08:12:37

标签: scala netcdf

我正在尝试使用NetCDF获取http://dd.weather.gc.ca/ensemble/naefs/grib2/raw/12/018/CMC_naefs-geps-raw_RH_TGL_2m_latlon0p5x0p5_2018070712_P018_allmbrs.grib2文件:

 def read(path: String): NetcdfDataset = {
    NetcdfDataset.openDataset(path)
  }

但我知道

  

java.nio.file.InvalidPathException:索引4处的非法char <:>:   http://dd.weather.gc.ca/ensemble/naefs/grib2/raw/12/018/CMC_naefs-geps-raw_RH_TGL_2m_latlon0p5x0p5_2018070712_P018_allmbrs.grib2

我有"edu.ucar" % "netcdfAll" % "4.6.3"。我应该怎么做才能得到这个文件?我已经尝试过使用这种方法从磁盘加载grib2文件,一切正常。

1 个答案:

答案 0 :(得分:1)

函数NetcdfDataset.openDataset似乎不接受URL,而仅接受本地路径。建议您将.grib2文件下载到计算机上,然后将下载文件的路径传递给openDataset函数,

例如

NetcdfDataset.openDataset("/home/kuba/Downloads/CMC_naefs-geps-raw_RH_TGL_2m_latlon0p5x0p5_2018070712_P018_allmbrs.grib2")