Works on Linux and MacOS, not under Windows

Reading NetCDF directly from OPeNDAP using R
Example: Oxygen concentrations at station VOLKRK02

# Load the packages:
library("ncdf4")
#library("ncdf") ## oude versie

url_grid <- "http://opendap.deltares.nl/thredds/dodsC/opendap/rijkswaterstaat/waterbase/O2/id360-VOLKRK02.nc"

## open connection
VOLKRK02_O2 <- nc_open(url_grid)

## Look what's inside
str(ncatt_get(VOLKRK02_O2, "O2"))
str(ncatt_get(VOLKRK02_O2, "time"))

## Get time series data
G.time <- ncvar_get(VOLKRK02_O2,"time")
G.O2 <- ncvar_get(VOLKRK02_O2,'O2')

## Convert G.time to real date
date <- as.Date(G.time, origin = "1970-01-01 00:00:00 +01:00")

## Plot data against time
plot(date, G.O2,"l", main = "Oxygen in VOLKERAK02")

##close connection
nc_close(VOLKRK02_O2)
  • No labels