Unmixing S2

This describes how to unmix a large number of Sentinel-2 images from ENVI-formatted reflectance, and simultaneously compute three output images:


To do this, you already need to have the following things in hand:


Once this is ready, execute the following steps:

for i in *L2A_e.hdr; do sed 's/bands   = 11/bands   = 11/' ${i} > ${i%????}_Modeled.hdr; done


for i in *_Modeled.hdr; do sed -i.bak 's/data type = 12/data type = 4/' ${i}; done


for i in *L2A_e.hdr; do sed 's/bands   = 11/bands   = 11/' ${i} > ${i%????}_MixtureResidual.hdr; done


for i in *_MixtureResidual.hdr; do sed -i.bak 's/data type = 12/data type = 4/' ${i}; done


for i in *L2A_e.hdr; do sed 's/bands   = 11/bands   = 3/' ${i} > ${i%????}_Unmixed.hdr; done


for i in *_Unmixed.hdr; do sed -i.bak 's/data type = 12/data type = 4/' ${i}; done


for i in *_Unmixed.hdr; do sed -i.bak 's/Band 1,/Substrate,/g' ${i}; sed -i.bak 's/Band 2,/Vegetation,/g' ${i}; sed -i.bak 's/Band 3,/Dark}/g' ${i}; sed -i.bak 's/Band 4,//g' ${i}; sed -i.bak 's/Band 5,//g' ${i}; sed -i.bak 's/Band 6,//g' ${i}; sed -i.bak 's/Band 7,//g' ${i}; sed -i.bak 's/Band 8,//g' ${i}; sed -i.bak 's/Band 9,//g' ${i}; sed -i.bak 's/Band 10,//g' ${i}; sed -i.bak 's/Band 11}//g' ${i}; done ; rm -v -r *.bak