I want to open the fs variable which is under Retrieval category and convert that into raster grid.

file <- "http://co2web.jpl.nasa.gov/thredds/fileServer/OCO-2/B7101Ar_r02/2014/09/06/LtCO2/oco2_LtCO2_140906_B7101Ar_150909171225s.nc4"

var <- nc_open(file,"Retrieval/fs")
  • 'file' and 'var' are both pre-existing functions. You might consider using other names.
    – Dave X
    Nov 19 '15 at 19:20

The server at https://co2web.jpl.nasa.gov/thredds/catalog/OCO-2/B7101Ar_r02/2014/09/06/LtCO2/catalog.html?dataset=nasa.jpl.oco2/B7101Ar_r02/2014/09/06/LtCO2/oco2_LtCO2_140906_B7101Ar_150909171225s.nc4 doesn't appear to be serving them up through OpenDAP such that ncdf4 can read them remotely. Try copying it locally and doing the extraction with:

fn <- 'oco2_LtCO2_140906_B7101Ar_150909171225s.nc4'
nc <- nc_open(fn)
vn <- 'Retrieval/fs'
x <- ncvar_get(nc,vn)

> system(paste('md5',fn))
MD5 (/tmp/oco2_LtCO2_140906_B7101Ar_150909171225s.nc4) =   aba9389fe3bb0cf9dfe321c24fc211b4
> summary(x)
Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
0.000   0.074   0.165   0.270   0.317  11.600   17782 

An extract of the 'nc' output:

 65 variables (excluding dimension variables):
    float latitude[sounding_id]   (Contiguous storage)  
        units: degrees_north
        long_name: latitude
        missing_value: -999999
        comment: center latitude of the measurement
    float longitude[sounding_id]   (Contiguous storage)  
        units: degrees_east
        long_name: longitude
        missing_value: -999999
        comment: center longitude of the measurement
    double time[sounding_id]   (Contiguous storage)  
        units: seconds since 1970-01-01 00:00:00
        long_name: time
        missing_value: -999999

If they were serving it up as OpenDAP, it could work remotely like:

uri <- 'http://geoport.whoi.edu/thredds/dodsC/examples/bora_feb.nc'
nc2 <- nc_open(uri)
  • Thanks! I have that on local drive, but ncdf and ncdf4 libraries can not read the file. I get the Error in nc_open trying to open file error. Which library did you use?
    – Geo-sp
    Nov 19 '15 at 18:55
  • I used library(ncdf4). I edit my code a bit and added the md5sum of the file I opened, and some summary() info on the result.
    – Dave X
    Nov 19 '15 at 19:20
  • Thanks! the ncvar_get functions helps. Would you complete the code and convert that into raster gird?
    – Geo-sp
    Nov 19 '15 at 19:37
  • 1
    No thanks. From browsing the output of 'nc', it looks like these are individual point observations, each with a corresponding latitude, longitude, and time. Subsetting and interpolating random point data to a regular grid is a problem with many solutions.
    – Dave X
    Nov 19 '15 at 19:47

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .