[R] graphing netCDF files

Steve_Friedman at nps.gov Steve_Friedman at nps.gov
Thu Sep 18 20:14:16 CEST 2008


Hello

I'm working with a large hydrological data set stored in a netCDF format.
The file stores x and y coordinates in the UTM projected coordinate system,
yet when I use image to graphically display the z variable, the image is
distorted in the sense that it does not plot the map in the correct spatial
organization.

I'm wondering if I need to define the projection of the netCDF file with
rgdal or proj4 routines first before I send it to the graphics device.

My code is as follows:

 q1_2001 <- open.ncdf("H:\\SKF_DESKTOP FILES\\My
Documents\\EDEN\\EDEN\\Surfaces\\2000_q1.nc", readunlimi=FALSE) #opens ncdf
file for reading
   wat.data2000q1 <- get.var.ncdf(q1_2001,  verbose=FALSE ) # gets the real
information

 # GENERAL EXAMINATION OF HEADER DATA in the wat.data file
   day <- get.var.ncdf(q1_2001, "time")   # length(day) 91 days in quarter
   UTMx <-   get.var.ncdf(q1_2001, "x")   # columns (eastings)  # should
return 405
   UTMy <-   get.var.ncdf(q1_2001, "y")   # rows (northings)       #
should return 287

# plot first 91 days (3 months of the year)
    for(i in 1:91) {
       !is.na( image(UTMx, UTMy, z = wat.data2001q1[,,i], col=brewer.pal(8,
"YlGnBu"),
         axes=T, pty="s", ylab="UTM Northing", xlab="UTM Easting",
         main = "First Quater 2001")  )
         }

As I indicated above the map is displayed on the graphics device. However
the orientation is distorted pulling the x axis to wide and the y axis too
tall.  How can I set the graphics device to know the orientation and
scaling (if these are the correct terms) in order to display this map
correctly?

All insights will be greatly appreciated.

Thanks
Steve

Steve Friedman Ph. D.
Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

Office (305) 224 - 4282
Steve_Friedman at nps.gov



More information about the R-help mailing list