I want to extract the elevation at any point in longitude/latitude from GeoTIFF, similar to Global Mapper. Using GDAL and rasterio, I get an image with a size of (6000, 6000) points. And the distance between each point, when translated into meters, is 90 meters, and I need a step between the points of 10 meters. Is it possible using raster libraries to get a result where the elevation is calculated based on the gradient of the raster, as Global Mapper does?
I use simple code:
from osgeo import gdal
import os
import geopy.distance
gdal_data = gdal.Open("./n50e045_dem.tif", gdal.GA_ReadOnly)
raster_band = gdal_data.GetRasterBand(1)
raster = raster_band.ReadAsArray()
print(raster.size, raster.shape)
>>> 36000000 (6000, 6000)
width = gdal_data.RasterXSize
height = gdal_data.RasterYSize
i_x = 4315
i_y = 861
X = gt[0] + i_x*gt[1] + i_y*gt[2]
Y = gt[3] + i_x*gt[4] + i_y*gt[5]
Z = raster[i_y, i_x] # in array elevations
coords_1 = (54.282916666666665, 48.595416666666665)
coords_2 = (Y, X)
print (geopy.distance.geodesic(coords_1, coords_2).m)
>>> 92.75854901199543
I need 10 meters instead of 90.