Geographic Information Systems Asked by Ballybee on January 16, 2021
I am new to GIS in Python and want to perform a simple band calculation from Sentinel-2 imagery using rasterio and numpy – specifically, I want to divide Sentinel Band 11 (SWIR) by Band 8 (NIR) to map snow/ice.
I have written the following code:
import numpy as np
import rasterio as rio
band11 = rio.open('filename_b11.jp2', driver = 'JP2OpenJPEG') #swir
band8 = rio.open('filename_b8.jp2', driver = 'JP2OpenJPEG') #nir
# convert to float
swir = band11.read(1).astype('float64')
nir = band8.read(1).astype('float64')
# divide swir by nir
band_calc = (swir / nir)
This produces the following error:
ValueError: operands could not be broadcast together with shapes (5490,5490) (10980,10980)
How do I handle this error (i.e. where the shapes of the two bands are not matching) to perform the band calculation, and similar calculations such as the NDSI?
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP