title: Building a buffer over a terrain model
body: <p>I have a polygon and a terrain model (can be either grid or TIN).  I'd like to a build, say, a 1km buffer so that the 1km is measured over the surface of the terrain, i.e. not planimetric.   The buffer must always be at least 1km from the polygon and prefer a measure over the flattest part of the terrain.</p>
  
  <p>Anyone know a good way to do this that is robust for all the edge cases you get with real terrain?  </p>
  
  <p>An algorithm or solution using FOSS tools is preferred.</p>