I am trying to find elevation of points from the .csv file by taking in the lat and long coordinates for those points and finding the related pixel in the DEM (tif file). But I am getting an error and I don’t know how to resolve this. Error queries in internet are like “index x is out of bounds for axis 0 with size x”, but none suits my issue. Please help me with this. This is the link to the datafiles - data
import geopandas as gp
import matplotlib.pyplot as plt
import rasterio as rio
import shapely as sh
import pandas as pd
raster = rio.open('montreal_30m.tif')
band = raster.read()
POI = pd.read_csv('montreal_poi.csv',header=None)
# find elevation for each POI
for i in range(len(POI)):
px,py=raster.index(POI[3][i],POI[2][i])
elevation = band[px,py] ------------------------------------- # index 156 is out of bounds for axis 0 with size 1# This is the error
print(elevation)