# Finding geodesically flat regions in DEM data

I'm interested to find regions in some DEM data for Earth that are what I call geodesically flat, i.e. flat in the way that the path light travels is flat in the absence of strong gravitational fields. This is in contrast to a geographically flat region of the Earth which follows the curvature of the Earth. Thus, a geodesically flat region on Earth would look like a plane section of a sphere (like a chord on a circle but in 3D): I believe DEM data is typically specified as the distance from the surface of a sphere concentric with the centre of the Earth with radius equal to global average sea level (or some similar definition). This means that "flat" regions on DEM data are not geodesically flat. I think I first need to transform the DEM to add an offset based on the curvature of the Earth away from some reference point. I have made a diagram below showing what I think I must do, but in 1D. Each point on the DEM along the x-axis would need to have `Δh(x₀) - Δh(x)` height added. Then I can compute the local slope of the DEM and find the minimum, as outlined for instance in this question. Unfortunately because this approach computes the offsets for each reference point `x₀`, it will require a lot of computation. Before I get started, I wanted to ask whether anyone knows of existing GIS tools that can find such geodesically flat regions in DEM data, following this or another approach. I am also interested whether it's possible to perform the required DEM transform using `gdal` or similar - applying the offsets to each point based on the height at a particular reference point.