I have a DEM(.tiff) file and I need to know the altitude of certain points(coordinates).

I opened it like this:

import tifffile as tiff
import matplotlib.pyplot as plt
import rasterio

tfile = tiff.imread('ms.tif')

Then I've got this image:

enter image description here

I just need some function to get altitude to my points, not the full code.


2 Answers 2


That's a easy task with rasterio. For each band the data is accessible as a kind of array.


import rasterio

# Which band are you interested. 
# 1 if there is only one band
band_of_interest = 1

# Row and Columns of the raster you want to know
# the value
row_of_interest = 30
column_of_interest = 50

# open the raster and close it automatically
# See https://stackoverflow.com/questions/1369526
with rasterio.open('example.tif') as dataset:
    band = dataset.read(band_of_interest)
    value_of_interest = band(row_of_interest, column_of_interest)

I think you need to create a points dataset from the coordinates then use the Extract Values To Points tool, if using ArcMap or ArcGIS Pro.

Not the answer you're looking for? Browse other questions tagged or ask your own question.