title: How can I put a coordinate system into a NetCDF using R?
body: <p>I have been working with NetCDF files from Daymet and my project involves extracting data from various files, modifying them and creating new files in R which will then be analyzed in Arcmaps.  Using the make NetCDF raster layer tool with with x and y as the dimensions works fine with unmodified data from day met but does nothing to the files I made myself.  Using coordinate variables works for both of them but the product comes out distorted.  Looking at the differences between the files I created the only difference is that the ones I created don't have any spatial reference coordinates.  </p>
  
  <p>There is an existing spatial reference or projection in the unmodified file, which looks like in the metadata:</p>
  
  <blockquote>
    <p>'
     5 variables (excluding dimension variables):<br>
            float time_bnds[nv,time]<br>
                time: days since 1980-01-01 00:00:00 UTC   </p>
    
    <p>'
    short lambert_conformal_conic[]<br>
                grid_mapping_name: lambert_conformal_conic<br>
                longitude_of_central_meridian: -100<br>
                latitude_of_projection_origin: 42.5<br>
                false_easting: 0<br>
                false_northing: 0<br>
                standard_parallel: 25<br>
                 standard_parallel: 60<br>
                semi_major_axis: 6378137<br>
                inverse_flattening: 298.257232666016  </p>
  </blockquote>
  
  <p>With the netcdf r package was able to create something similar looking this code:</p>
  
  <blockquote>
    <p>'
    corddef &lt;- ncvar_def("lambert_conformal_conic","", list(), prec="short")
    ncatt_put(ncout, "lambert_conformal_conic", "grid_mapping_name", "lambert_conformal_conic")
    ncatt_put(ncout,"lambert_conformal_conic","longitude_of_central_meridian", "-100")
    ncatt_put(ncout,"lambert_conformal_conic","latitude_of_projection_origin", "42.5")
    ncatt_put(ncout,"lambert_conformal_conic","false_easting", "0")
    ncatt_put(ncout,"lambert_conformal_conic","false_northing", "0")
    ncatt_put(ncout,"lambert_conformal_conic","standard_parallel", "25")
    ncatt_put(ncout,"lambert_conformal_conic","standard_parallel_2", "60")
    ncatt_put(ncout,"lambert_conformal_conic","semi_major_axis", "6378137")
    ncatt_put(ncout,"lambert_conformal_conic","inverse_flattening", "298.257232666016")</p>
  </blockquote>
  
  <p>Which gives this:</p>
  
  <blockquote>
    <p>'
    5 variables (excluding dimension variables):<br>
            float time_bnds[time]   (Chunking: [1])<br>
                units: days since 1980-01-01 00:00:00 UTC<br>
     short lambert_conformal_conic[]   (Contiguous storage)<br>
                grid_mapping_name: lambert_conformal_conic<br>
                longitude_of_central_meridian: -100<br>
                latitude_of_projection_origin: 42.5<br>
                false_easting: 0<br>
                false_northing: 0<br>
                standard_parallel: 25<br>
                standard_parallel_2: 60<br>
                semi_major_axis: 6378137<br>
                inverse_flattening: 298.257232666016   </p>
  </blockquote>
  
  <p>Trying to make a raster out of it in Arcmaps still doesn't do anything though so I was wondering if there was a better way to put the information about the projection directly into the new file I'm creating so that arcmaps can automatically read the information.</p>