This example implements a Spatial Modeler RasterOperator that demonstrates the use of the Planes property of the RasterRequest.
Spatial Modeler SDK version
For Spatial Modeler RasterOperators, the RasterRequest defines what the downstream is expecting from the operator. It’s important to realize that the request parameters may specify less (or more) that the operator is capable of generating. Often these parameters are just handled by the upstream operators, and you don't need to be aware of them when you implement your operator. However, depending on what your operator does, you may need to query what's being requested and obey the request. You may even need to request from your operator's input something different than what's being requested of your operator. This sample demonstrates observing the Planes (bands) that the RasterRequest passed to the ProcessBlock() method is requesting and requesting different bands from the input than what's requested of our operator.
Our example operator, Band Combo, allows the user to select which bands of the input raster should be output in a 3-band stack. That's what it is capable of doing. But a downstream operator,such as Preview, may request these three bands in any order or combination. So we cannot just blindly request from the input the bands in the order and combination that is specified on the Band input ports and output a 3-band stack. Instead we have to query what bands are requested and figure out from that what bands we want to request from the input. Say, for instance, that the input raster has seven bands and the user has specified (4, 3, 2) for the input ports Band1, Band2, and Band3. You might think that you'd want to just request bands 4, 3, and 2 from RasterIn. And there are many workflows in which you'd be right, e.g. if Band Combo hooked up directly to a Raster Output operator. However, some operators don't necessarily process all input bands in order. For an example, let's use the Preview operator. If Band Combo eventually hooks up to a Preview operator, and the user has selected band 3 for Red, band 1 for Green, and band 2 for Blue for the Preview, you'd actually need to request bands 2, 3, and 4 from RasterIn. The user could also select band 3 for both Red and Green and band 2 for Blue. In that case the Planes in the RasterRequest would be 3, 3, 2, and you would request bands 2, 2, and 3 from RasterIn. Furthermore, if the user previewed the layer as Panchromatic, you would get a request for only a single band.
You also have to be careful that what you request from your inputs is valid. For example, you should only request bands 1 - 7 from a 7-band image. Therefore, in the Band Combo operator we have to verify that the user has not specified a band that is out of range.
This same concept applies to other properties on the RasterRequest, particularly the Boundary property, but we'll leave the discussion of that to a later time.