title: netCDF to raster and projection
body: <p>I've recently started using R for spatial data. I'd be really grateful if you could could help me with this. Thanks!</p>
  
  <p>I've extracted data from a multidimensional netCDF file. This file had longitude, latitude and temperature data (for 12 months of a specific year).</p>
  
  <p>From this netCDF I've got a data frame for January with these variables: longitude, latitude, temperature.</p>
  
  <p>With this data frame I've created a raster. </p>
  
  <pre><code># Packages
  library("sp")
  library("raster") 
  library("rgdal")
  library("ncdf")
  library("maptools")
  library("rgeos")
  library("sm")
  library("chron")
  
  # Dataframe to raster
  # Create spatial points data frame
  coordinates(tmp.df01) &lt;- ~ lon + lat
  # Coerce to SpatialPixelsDataFrame
  gridded(tmp.df01) &lt;- T
  # Coerce to raster
  rasterDF1 &lt;- raster(tmp.df01)
  &gt; print(tmp.df01)
  class       : SpatialPixelsDataFrame 
  dimensions  : 103, 241, 24823, 1  (nrow, ncol, npixels, nlayers)
  resolution  : 0.02083333, 0.02083333  (x, y)
  extent      : 5.739583, 10.76042, 45.73958, 47.88542  (xmin, xmax, ymin, ymax)
  coord. ref. : NA 
  names       :           TabsM_1 
  min values  : -18.1389980316162 
  max values  :  2.26920962333679 
  </code></pre>
  
  <p>There is no value for 'coord. ref.'</p>
  
  <p>The projection of the original netCDF was WGS84. So I gave this projection to the raster.</p>
  
  <pre><code>proj4string(rasterDF1) &lt;- "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"
  </code></pre>
  
  <p>Then, I wanted to reproject my raster to another projection:</p>
  
  <pre><code># Reprojecting into CH1903_LV03
  # First, change the coordinate reference system (crs)
  proj4string(rasterDF1) &lt;- "+init=epsg:21781"
  # Second, reproject the raster
  rasterDF1.CH &lt;- spTransform(rasterDF1, crs("+init=epsg:21781"))
  </code></pre>
  
  <p>At this point I get the following error:</p>
  
  <pre><code>Error in spTransform(rasterDF1, crs("+init=epsg:21781")) : 
    load package rgdal for spTransform methods
  </code></pre>
  
  <p>But the package rgdal is already uploaded! It must be something wrong in the code!</p>