Skip to main content
added 21 characters in body
Source Link
fyec
  • 1
  • 3

For the future users' convinience, when you provide lat lon in get_elevation function, it gives the elevation.

import rasterio
elevation_file = 'Dem.tif'
def get_elevation(lat, lon):
    coords = ((lat,lon), (lat,lon))
    with rasterio.open(elevation_file) as src:
        vals = src.sample(coords)
        for val in vals:
            elevation=val[0]
            return elevation
get_elevation(34, 36)

For the future users' convinience, when you provide lat lon in get_elevation function, it gives the elevation.

elevation_file = 'Dem.tif'
def get_elevation(lat, lon):
    coords = ((lat,lon), (lat,lon))
    with rasterio.open(elevation_file) as src:
        vals = src.sample(coords)
        for val in vals:
            elevation=val[0]
            return elevation
get_elevation(34, 36)

For the future users' convinience, when you provide lat lon in get_elevation function, it gives the elevation.

import rasterio
elevation_file = 'Dem.tif'
def get_elevation(lat, lon):
    coords = ((lat,lon), (lat,lon))
    with rasterio.open(elevation_file) as src:
        vals = src.sample(coords)
        for val in vals:
            elevation=val[0]
            return elevation
get_elevation(34, 36)
Source Link
fyec
  • 1
  • 3

For the future users' convinience, when you provide lat lon in get_elevation function, it gives the elevation.

elevation_file = 'Dem.tif'
def get_elevation(lat, lon):
    coords = ((lat,lon), (lat,lon))
    with rasterio.open(elevation_file) as src:
        vals = src.sample(coords)
        for val in vals:
            elevation=val[0]
            return elevation
get_elevation(34, 36)