I am working with a maximum water elevation raster in which, similarly to using r.grow.distance, I am trying to extract the distance from the each null cell to the nearest water elevation cell. However I need both the x and y distances, which are not provided by r.grow.distance. I looked into the source code for this function and found that the x and y distances are calculated within the code but r.grow.distance can only provide results in euclidean, squared, maximum, manhattan, or geodesic formats. Is there an easy way to extract these x and y distance values? If so, I am working on a real-time storm surge model so it would be ideal to be able to calculate these values in as little time as possible. I also looked into r.distance but this does not seem like an option that would work for me.
I was able to use r.mapcalc to create a raster for all of the x and y values of the original maximum elevation raster. For example:
Then I used r.grow.distance to extrapolate the x and y values, covering all null cells. Finally, I used r.mapcalc and simply found the difference between the x() and y() moving-window values and the values extrapolated using r.grow.distance.
This gave me the x and y components of the euclidean distances between each null cell and its closest non-null cell.