User Tools

Site Tools


Exercise 6: Create the cloud mask

In this exercise, the following tools will be used:

  • pktools: pkgetmask, pkfilter, pkreclass, pkdsm2shadow
  • bash: cat, redirect

Create a directory for this exercise

mkdir -p ${OUTPUTDIR}/exercise6

Create a colour table

cat > ${OUTPUTDIR}/exercise6/cloudmask_ct.txt <<EOF
0 0 0 0 255
1 255 255 255 255

Create the cloud mask using the thresholds found in exercise 5a

pkgetmask -i ${LANDSATDIR}/${LANDSATIMG} -ot Byte -b 0 -min 0 -max 150 -b 3 -min 0 -max 150 -b 6 -min 140 -max 256 -o ${OUTPUTDIR}/exercise6/cloudmask.tif -data 0 -nodata 1 -ct ${OUTPUTDIR}/exercise6/cloudmask_ct.txt

Dilate cloud mask with circular kernel of size 5x5

pkfilter -i ${OUTPUTDIR}/exercise6/cloudmask.tif -o ${OUTPUTDIR}/exercise6/cloudmask_dil.tif -f dilate -dx 5 -dy 5 -c
If slow computer, perform the morphological filter on subimage using pkcrop
pkcrop -i ${OUTPUTDIR}/exercise6/cloudmask.tif -o ${OUTPUTDIR}/exercise6/cloudmask_crop.tif -ulx $ULX -uly $ULY -lrx $LRX -lry $LRY

Create cloud shadow mask, treating the cloud mask as a digital surface model

Cloud heights should be introduced by setting the cloud flag to the potential cloud height

pkreclass -i ${OUTPUTDIR}/exercise6/cloudmask_dil.tif -o ${OUTPUTDIR}/exercise6/clouddsm.tif -c 1 -r 1800 -ot UInt16

Create cloud shadow mask based on cloud height

pkdsm2shadow -i ${OUTPUTDIR}/exercise6/clouddsm.tif -o ${OUTPUTDIR}/exercise6/shadowmask.tif -sza 20 -saa 155 -f 1 -ct ${OUTPUTDIR}/exercise6/cloudmask_ct.txt
Try different cloud heights, Sun zenith angles and Sun azimuth angles
wiki/exercise6.txt · Last modified: 2021/01/20 20:36 (external edit)