0

I would like to load the following geospatial file in R: ftp://ftp.nodc.noaa.gov/pub/data.nodc/icoads/1930s/1930s/ICOADS_R3.0.0_1930-10.nc. The problem is that using the subsequent code I only obtain one dimension, even though I should obtain three:

require("raster")
require("ncdf4")

nc_data <- nc_open("ICOADS_R3.0.0_1930-10.nc")

id.array <- ncvar_get(nc_data, "ID")
dim(id.array)

How do I fix this?

Thank you for any comments and suggestions.

Chr
  • 1,017
  • 1
  • 8
  • 29
  • 1
    Why do you think you should have 3 dimensions? I downloaded the file and examined the header with ncdump -h and the variable ID is a single dimension array of character strings, char ID(obs, ID_len) ; Where ID_len is the string length of 9 characters. Your code is working fine, it is just that you file does not have what you expect. – ClimateUnboxed Nov 29 '18 at 22:59

1 Answers1

0

Does this give you what you expect?

library(tidync)
library(magrittr)

tfile <- tempfile(fileext = ".nc")
download.file("ftp://ftp.nodc.noaa.gov/pub/data.nodc/icoads/1930s/1930s/ICOADS_R3.0.0_1930-10.nc", tfile) 

id <- tidync(tfile) %>% activate("ID") %>% hyper_tibble()
dim(id)

[1] 69779 3

tidync is only on Github: https://github.com/hypertidy/tidync

jsta
  • 3,216
  • 25
  • 35