[NARCCAP-discuss] NARCCAP NetCDFs and gdal_translate redux

Seth McGinnis mcginnis at ucar.edu
Sat May 5 11:58:15 MDT 2012


Hi Audrey,

I don't know anything about gdal, but the process in that document seems
unnecessarily complex.  If you want to pull netCDF data into R to plot or
process it, you don't need to pre-process it with gdal, you can just use one of
the netcdf libraries for R, like so:

  library(ncdf4)
  fin <- nc_open("tasmax_WRFG_cgcm3_1968010106.nc")
  var <-  fin$var[["tasmax"]]
  data <- ncvar_get(fin,var)

(And even that is slightly more elaborate than necessary, because I'm doing it
in a way that avoids the dropping of degenerate dimensions.)

Cheers,

--Seth

P.S.: If you are required to go the circuitous gdal route, my guess based on
the error message is that it wants a space after the colon in the last line of
your gdal command.


On Fri, 4 May 2012 13:40:06 -0700
 Audrey Rager <ahrager at gmail.com> wrote:
>Hello everyone,
>
>For some reason, my question didn't post. So, I'm trying it again.
>
>I'm new to using the NARCCAP data.  I'm following along with "Downloading
>and processing NARCCAP climate data" by P. Delamater and A. Finley to try
>to import some data into an *.img format.  I'm working with WRFC, CGCM3
>current, table 1 data.
>
>When I try to follow the gdal_translate example on page 5 with the
>following command (I had to change some of the command because these data
>are in Lamber Conformal Conic):
>
>gdal_translate -of HFA -b 1 -a_ullr -25000 5425000 6675000 -25000 -a_srs
>'+proj=lcc +lat_2=60 +lat_0=47.5 +lat0=-97 +x_0=3325000 +y_0=2700000
>+no_defs +a=6378137 +rf=298.257223563 +towgs84=0,0,0,0,0,0,0 +to_meter=1'
>NETCDF:"tasmax_WRFG_cgcm3_1968010106.nc" tasmax_WRFG_cgcm3_1968010106.img
>
>I get this error message:
>
>ERROR 1: Failed to parse NETCDF: prefix string into expected three fields.
>GDALOpen failed - 1
>Failed to parse NETCDF: prefix string into expected three fields.
>
>
>I've tried searching google to get some clues as to what I'm doing wrong,
>but I can't find anything.  Any suggestions?
>
>Thanks,
> Audrey
>_______________________________________________
>narccap-discuss mailing list
>narccap-discuss at mailman.ucar.edu
>http://mailman.ucar.edu/mailman/listinfo/narccap-discuss



More information about the narccap-discuss mailing list