It could be written. There is a dataset of world elevations at 1km resolution that I saw being used for calculating the horizon distance from arbitrary points. Searching just now it turns out that was low resolution data, 30-arcseconds and 1 arcsecond, 30m resolution is available! https://www.usgs.gov/faqs/where-can-i-get-global-elevation-d...