Read Raster Band Data

from osgeo import gdal

fn_dem = r"..\data\input\USGS_one_meter_x64y486_ID_FEMAHQ_2018.tif"
fn_img = r"..\data\input\m_4311515_ne_11_1_20150908_20160104.jp2"

ds = gdal.Open(fn_dem)

# get data for the entire band
band_data = ds.GetRasterBand(1).ReadAsArray()

print(band_data[:5, :5])
print('\n\nno data value:', ds.GetRasterBand(1).GetNoDataValue(), '\n\n')

# get data for a window of the raster
window_data = ds.GetRasterBand(1).ReadAsArray(2, 2, 3, 3) #(x/col offset, y/row offset, x win size, y win size)
print(window_data)