# difference in elevation between closest pixel of another layer or 3d distance

I want to find the closest point of water to each forest pixel, and the difference in elevation, to see how deep should a channel be dug in order to get water to the mangrove.

My aim is to obtain a raster with the values of the subtraction between a layer and its closest point in another elevation layer

I want to keep it raster (finding closest distance between polygons may take hours, while it needs just a couple of minutes in raster). It can be in GRASS, R, QGIS or python. I've been trying with r.distance and library(raster) without success. It may be a 3d distance I guess.

• Is there a R equivalent to Euclidean Allocation? You could construct Thiessen (Voronoi) polygons rdocumentation.org/packages/dismo/versions/1.1-4/topics/voronoi from the elevation point data then rasterize the polygons, after that it's a raster subtraction. – Michael Stimson Nov 13 '17 at 23:24
• So your two layers are rasters, but the grid cells don't line up? If the two rasters had the same extent and size you could just subtract them cell-by-cell? Would it be okay to warp one layer to the other one's shape and subtract cell-by-cell? – Spacedman Nov 14 '17 at 6:38
• It's not about alignment, I want to find the closest point of water to each forest pixel, and the difference in elevation, to see how deep should a channel be dug in order to get water to the mangrove patch – Elio Diaz Nov 14 '17 at 15:28
• I believe you need to work one at time with distance and elevation. I assume water resource is higher than forest area. For elevation data if you find the difference between forested area (max) and water resource (min). That is pretty much equals to your max channel depth. If you dig more water would backflow. Once you divert water to max elevation of the forest, you can divert again to lower areas. Contraril, if you reach to lower areas first you need to pump the water to higher elevation. Then you need to use a tool equivalent to eucllidean distance (arcgis) to find the closest distance – Amadeus Nov 14 '17 at 20:36
• water is mostly lower than the mangroves, which need to be flooded during some months of the year; purpose is to choose or classify places (with or without any mangrove) according to the feasibility for restoration, if the place is to high above the closest water body or if they have pretty much the same elevation but the water body is far away this places will not be suitable for restoration – Elio Diaz Nov 14 '17 at 21:18