title: R: Calculate sill, range and nugget from a raster object
body: <p>I need to calculate the sill, range and nugget from a raster layer. I have explored gstat, usdm packages where one can create variogram however I couln't find a function which given a raster layer will estimate these parameters.In most of the functions these parameters have to be defined eg. krigging.</p>
  
  <p>I have raster data layers for different heights which looks similar to <a href="https://i.stack.imgur.com/A2p8m.png" rel="noreferrer"><img src="https://i.stack.imgur.com/A2p8m.png" alt="enter image description here"></a></p>
  
  <p>I would like get the sill, nugget and range from the parameters of semivariogram fitted to these data layers to create a plot similar to this:<a href="https://i.stack.imgur.com/2nMZO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/2nMZO.png" alt="enter image description here"></a></p>
  
  <p>The original data layers are available <a href="https://www.dropbox.com/s/06yq26ohmcyp97b/old_gap_.tif?dl=0" rel="noreferrer">here</a> as a multiband tiff. Here is a figure from <a href="https://www.dropbox.com/s/ufaz84p7v4xhwhn/Todd_2003_CJRS_Three-dimensional%20mapping%20of%20light%20transmittance%20and%20foliage.pdf?dl=0" rel="noreferrer">this</a> paper which further illustrates the concept. </p>
  
  <p><a href="https://i.stack.imgur.com/XSigw.png" rel="noreferrer"><img src="https://i.stack.imgur.com/XSigw.png" alt="enter image description here"></a></p>