Learn R Programming

ncdf4.helpers (version 0.3-7)

nc.get.proj4.string: Gets the proj4 string for a file

Description

Gets the proj4 string for a file.

Usage

nc.get.proj4.string(f, v)

Value

A string containing the proj4 string, or NULL if a translator is not available for the given projection.

Arguments

f

The file (an object of class ncdf4)

v

The name of a variable

Details

Most NetCDF files are stored without any projection information as a lat-long grid. However, some files -- particularly those from RCMs -- are on a projected grid. This function returns a proj4 string, suitable for use with the 'proj4' library, which can be used to perform forward and inverse projections.

Given a file and a variable, this function returns the proj4 string for the given file should be. If no projection data is found, it returns an empty string. It currently supports Lambert Conformal Conic, Transverse Mercator, Polar Sterographic, and Rotated Pole projections, plus the latitude_longitude pseudo-projection.

References

http://cfconventions.org/Data/cf-conventions/cf-conventions-1.8/cf-conventions.html#grid-mappings-and-projections

Examples

Run this code
## Get the proj4 string for a hypothetical file.
if (FALSE) {
f <- nc_open("pr.nc")
proj4.string <- nc.get.proj4.string(f, "pr")
nc_close(f)
}

Run the code above in your browser using DataLab