0

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_xgt[1] + i_ygt[2] Y = gt[3] + i_xgt[4] + i_ygt[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.

svv
  • 3
  • 2
  • 1
    Welcome to GIS SE. As a new user, please take the [Tour]. It is not possible to express a uniform conversion of degrees to meters, because all the meridians converge at the poles and even latitudes are not uniform due to oblateness. You can interpolate across three arc-second pixels, but the results are far from perfect. "Is it possible?" questions ask the wrong question -- what you really want is "How is it possible to..." We expect that your Question will include what you've tried. – Vince Sep 17 '22 at 14:22
  • 1
    Does this answer your question? Extracting data from a raster – snowman2 Sep 17 '22 at 15:59
  • I don't think this is a duplicate. The desired result seems to be an interpolation of Z values between cell centroids (e.g. 1, 2). – user2856 Sep 18 '22 at 09:35

1 Answers1

0

I recommend first resampling the raster to 10 meters, then extract the points.

Step 1: Resample raster to 10 meters

Step 2: Extract data Extracting data from a raster

snowman2
  • 7,321
  • 12
  • 29
  • 54