This article isn't about a specific Spatial Model. It's a general discussion on NoData and how NoData can be handled within Spatial Modeler. It arose out of a conversation which started in the ERDAS IMAGINE Support community on the best practices for stretching data to 8bit. One of the topics that thread didn't get into was the effect NoData might have on such tasks and so I wanted to explore that topic more in the form of an Article.
First off, what is NoData? Fundamentally, it means geospatial locations where information represented by the particular layer is unknown, or does not exist - i.e. there is "no data". There's a basic definition here. But that page really only discusses value-based NoData. Value-based NoData is when a value within the information layer itself is reserved to denote the locations where information does not exist (also sometimes known as a Null Value). For Unsigned 8-bit Integer raster layers the DN value 0 is often used for this purpose. A disadvantage of value-based NoData is that it consumes one of what may be a very limited number of values available in the data set - for example, using the value 0 as NoData in u8 data reduces the number of valid values to 255. It's also very difficult to use if the raster format has been lossily compressed (so that there is no longer a single value that can represent locations with no data).
The NoData Help page also makes the incomplete statement that "Areas of NoData are not automatically identified as such by the operations that create them". Spatial Modeler has an advantage in internally using mask-based NoData (more on that later) and can automatically create and add to that mask if warranted by the operations of the Spatial Model. For example, if you reproject a raster layer as part of a Spatial Model, NoData will be automatically injected into the resulting raster at the locations where there was no available input data to create valid information for the output.
As a Spatial Model executes, NoData information is retained, combined and used in the form of a mask. Think of this as a 1bit raster layer which denotes locations that have information and locations that don't. The mask is essentially a separate layer associated with each data layer in the raster stream and therefore does not reduce the data range of those rasters. Processing will only occur at locations of Data (no NoData). At locations where the mask specifies NoData an Operator will, in general, not execute.
But that rule can vary depending on the needs of the specific Operator being used. For example, if using a Convolution (filtering) operation with a 3x3 input kernel window, the convolution will not be applied at pixel locations which fall under the NoData mask. However when evaluating a location at a valid pixel location, the 3x3 moving window may include neighboring pixel cells that do fall under NoData locations. In this instance the operation of the Focal function is modified to take into account the more limited number of valid pixel values present in the moving window and a valid value is created at the output center location.
But how does this NoData mask get created, updated and (quite importantly) output, when running a Spatial Model?
I think there’s a lot of confusion over how NoData works in Spatial Modeler, so let me see if I can explain how it works using a simple Spatial Model created to take 3 individual TIFF band files of Landsat 8 data and create a stretched 8-bit, 3-band output file suitable for display as a backdrop (in a WMS service, for example):
|Model to Stack and Stretch to 8-bit for a True-Color Display|
|Band 4 of a Landsat 8 image, displayed with the background canvas color set to red|
|True Color 8-bit RGB IMG which did not remap 0s (step 6 & 7) - note the holes showing red background through|
|True Color 8-bit RGB IMG which did remap 0s to 1s (step 6 & 7) - no holes|
|True Color 8-bit RGB ECW which did not remap 0s (step 6 & 7) - no holes because the ECW retained a NoData Mask independant of valid pixels with value 0|