nc_prj_to_gridmapping: Get NetCDF-CF grid mapping from projection

View source: R/nc-gridmapping.R

nc_prj_to_gridmappingR Documentation

Get NetCDF-CF grid mapping from projection

Description

Takes a proj4 string and returns a NetCDF-CF projection as a named list of attributes.

Usage

nc_prj_to_gridmapping(prj)

Arguments

prj

character PROJ string as used in raster, sf, sp, proj4, and rgdal packages.

Value

A named list containing attributes required for that grid_mapping.

References

  1. https://en.wikibooks.org/wiki/PROJ.4

  2. https://trac.osgeo.org/gdal/wiki/NetCDF_ProjectionTestingStatus

  3. http://cfconventions.org/cf-conventions/cf-conventions.html#appendix-grid-mappings

Examples

prj <- "+proj=longlat +datum=NAD27 +no_defs"
nc_prj_to_gridmapping(prj)
p1 <- "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96"
p2 <- "+x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"
prj2 <- sprintf("%s %s", p1, p2) 
nc_prj_to_gridmapping(prj2)

nc_prj_to_gridmapping("+proj=longlat +a=6378137 +f=0.00335281066474748 +pm=0 +no_defs")


ncmeta documentation built on June 22, 2024, 7:36 p.m.