title: R - convert SpatialLines into raster
body: <p>In R, we can take a <code>raster</code> and turn it into a <code>SpatialLinesDataFrame</code> with the function <code>rasterToCountour</code>:  </p>
  
  <pre><code>library(raster)
  f &lt;- system.file("external/test.grd", package="raster")
  r &lt;- raster(f)
  x &lt;- rasterToContour(r)
  class(x)
  
  [1] "SpatialLinesDataFrame"
  attr(,"package")
  [1] "sp"
  
  spplot(x)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/EZi0B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EZi0B.png" alt="enter image description here"></a></p>
  
  <h3>Within R, is there a way to do the opposite? Something like <code>contourToRaster</code>?</h3>
  
  <p>We can simply grab the field values associated with each point along the line, but I'm looking for something more general that interpolates between the lines and produces a full raster over a defined domain.</p>