I have had a look at this issue and fixed the bug. This is a command which was implemented quite some while ago and it hasn’t been used very much so please let me know if you see any results which aren’t what you expect. Note that it’s performing a ray-tracing so it does take a little while to execute.
I’d suggest running a median filter to tidy up the result, see the python code below.
import rsgislib.elevation
import rsgislib.rastergis
import rsgislib.imagefilter
import rsgislib
inputImage = "/Users/pete/Desktop/TestShadowMask/Wales_fltg_grtr0_subset2.kea"
outputMaskImage = "/Users/pete/Desktop/TestShadowMask/Wales_fltg_grtr0_subset2_mask.kea"
outputHSImage = "/Users/pete/Desktop/TestShadowMask/Wales_fltg_grtr0_subset2_hs.kea"
solarAzimuth = 315
solarZenith = 45
maxHeight = 1200
gdalFormat = "KEA"
#rsgislib.elevation.shadowmask(inputImage, outputMaskImage, solarAzimuth, solarZenith, maxHeight, gdalFormat)
outputMaskImageMed = '/Users/pete/Desktop/TestShadowMask/Wales_fltg_grtr0_subset2_mask'
gdalFormat = 'KEA'
outExt = 'kea'
filters = []
filters.append(rsgislib.imagefilter.FilterParameters(filterType = 'Median', fileEnding = 'med', size=3) )
# Apply filters
rsgislib.imagefilter.applyfilters(outputMaskImage, outputMaskImageMed, filters, gdalFormat, outExt, rsgislib.TYPE_8UINT)
outputMaskImageMed = outputMaskImageMed +"_med.kea"
rsgislib.rastergis.populateStats(clumps=outputMaskImageMed, addclrtab=True, calcpyramids=True, ignorezero=True, ratband=1)