Search code examples
rrasterprojectionnetcdf

What's the proj4string for lambert conformal projection from this netcdf file


What I'm doing I'm using R. I'm creating a raster from a NetCDF file. This is a weather forecast product from NAM model.

What's the problem I don't know how to specify the proj4string parameter when I create the SpatialPoints. For example, I'm looking for something like this:

+proj=aea +lat_1=20 +lat_2=60 +lat_0=40 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs

And I have the grid information at grid description. However, I don't know what do these parameters mean and how to match them up to lat_0 and etc.

Therefore, to create the right projection information for the raster I created from the NetCDF file, how do I specify the projection for NetCDF?

The partial output from print(nc_open('NAM_forecast.nc')) is as follow:

float gridlat_0[xgrid_0,ygrid_0]   
            La1: 12.1899995803833
            Lo1: 226.541000366211
            Lov: 265
            Dx: 12.1909999847412
            Dy: 12.1909999847412
            Latin1: 25
            Latin2: 25
            units: degrees_north
            grid_type: Lambert Conformal (secant, tangent, conical or bipolar)
            long_name: latitude
            corners: 12.1899995803833
             corners: 14.3420877456665
             corners: 57.3284339904785
             corners: 54.5653381347656
float gridlon_0[xgrid_0,ygrid_0]   
            La1: 12.1899995803833
            Lo1: 226.541000366211
            Lov: 265
            Dx: 12.1909999847412
            Dy: 12.1909999847412
            Latin1: 25
            Latin2: 25
            units: degrees_east
            grid_type: Lambert Conformal (secant, tangent, conical or bipolar)
            long_name: longitude
            corners: -133.458999633789
             corners: -65.1255569458008
             corners: -49.4160041809082
             corners: -152.878616333008

Thank you very much.


Solution

  • I'd like to answer my own question since it looks like it didn't intrigue much interest.

    I have created a gist on Github for solving the problem.