title: R: How do I loop through spatial points with a specific buffer?
body: <p>So my problem is quite difficult to describe so I hope I can make my question as clear as possible.<br>
  I use the <code>rLiDAR package</code> to load a <code>.las</code> file into R and afterwards convert it into a SpatialPointsDataFrame using the <code>sp package</code>. 
  So my SpatialPointsDataFrame is quite dense.</p>
  
  <p>Now I want to define a buffer of 0.5 meters and loop (iterate) with him (the buffer) through the points, choosing always the point with the highest Z value within the buffer, as the next point to jump to.This should be repeated until there isn't any point within the buffer with an higher Z value as the current. <strong>All values</strong> (or perhaps the X and Y values) of this "found" point should then be written into a list/dataframe and the process should be repeated until all such highest points are found.
  Thats the code I got so far:</p>
  
  <pre><code>&gt;library(rLiDAR)
  &gt;library(sp)
  &gt;rLAS&lt;-readLAS("Test.las",short=FALSE)
  &gt;PointCloud&lt;- data.frame(rLAS) 
  &gt;coordinates(PointCloud) &lt;- c("X", "Y")
  </code></pre>
  
  <p>Well I googled extensively but I could not find any clues how to proceed further...<br>
  I dont even know which packages could be of help, I guess perhaps <code>spatstat</code> as my question would probably go into the spatial point pattern analysis.<br>
  Does anyone have some ideas how to archive something like that in R? Or is something like that not possible? (Do I perhaps have to skip to python to make something like this work?)<br>
  Help would gladly be appreciated.</p>