google earth - R code that evaluates line-of-sight (LOS) between two (lat, lon) points -
Let me line up between two (latitude, lawn) points, about the approach of this problem within the line code Any advice in this will be appreciated. I would like to use R package - raster - to read in the terrain partial data. It appears that the Springdridge package can be leveraged (on the basis), but I wanted to save GIS from loading. Thank you.
If you just want to know that point A can see point B. Then again, the sample line of the large number of samples in ABC To join, create a geo-profile and then see if the line from A to B penetrates the polygon created by that profile. If it does not happen, then you can see the AB coding which is quite trivial. On the contrary, you can sample multiple digits sampling along the straight line of A to B and see that any of them has an elevation below the height of the terrain.
If you have a large number of points to calculate, or if your raster is too wide, or if you want to show the entire area from one point, it may take some time to run .
Also, unless your data is not on the large part of the Earth, convert it to a regular metric grid (for example UTM zone) and take a flat earth.
I do not know any of the existing packages with this functionality, but using Grace is not really a big problem.
Here are some code that uses the raster
and plyr
:
canse & lt; - Function (r, xy1, xi2, h1 = 0, h2 = 0) {### Can xy1 see xi 2 on dim r? ### R is a DEM in x, y, z units ### xy1 and xy2 are the two-length vectors of x, ### H1 and H2 are extra height offsets ### (e.g. above the mast , Observer at a staircase) xyz = raster profile (r, xy1, xy2) np = enyro (xyz) -1 h1 = xyz $ z [1] + h1h2 = xyz $ z [np] + h2 hpith = H1 + (0: Np) * (h2-h1) / np return (Anyone (hpath & lt; xyz $ z)) View & Lt; - Function (r, xy, xy2, h1 = 0, h2 = 0, progress = "none") {## xy2 X, Y.Coors requires a matrix (not data frame) (Peer) Apley ( Xy2, 1, function (d) {casi (r, xi, d, h1, h2)} progress = progress)} rasterprofile & lt; - Function (r, xy1, xy2) {### Sampling a raster with a straight line between two points ### Try to match sample size raster resolution dx = sqrt ((xy1 [1] - Xy2 [1]) ^ 2 + (xy1 [2] -xy2 [2]) ^ 2) nesteps = 1 + round (dx / min (race (r)) xc = xy1 [1] + (0: nsteps) * (Xy2 [1] -xy1 [1]) / nsteps yc = xy1 [2] + (0: nsteps) * (xy2 [2] -xy1 [2]) / nsteps data.frame (x = xc), y = Yc, z = r [cellFromXY (r, cbind (xc, yc))]}}
Hope is quite self-explanatory but maybe some actual documents are required . I have created it with:
Which one Is a map of points where the person 50 meters high can see the tower 2 meter high at the red point. Yes, I was wrong in this number when I took part in it for about 20 minutes to run on my 4 year old PC. I suspect that GRASS can do it almost immediately and more correctly
Comments
Post a Comment