This topic provides a very technical example in which we import a BIL format file that produces three images, each using one band from the BIL. We then create an image that uses the three bands for R, G and B. BIL format fails to provide projection information, so for the sake of this topic we pretend the images are in default Pseudo-Mercator projection, as good as any other we might use.
This topic shows uses an SQL expression to combine three bands. An easier way to create an RGB image from three bands is to use the Join dialog, as shown in the Spatial Join Example: Create RGB Image with a Raster Join topic.
We import a BIL file called austin.bil.
Using the procedures described in the BIL, ESRI Band Interleaved by Line topic, navigate to the file and double-click the austin.bil file.
That results in a single table and three images, all three of which take their data from the same table.
Double-clicking one of the images open we see it shows a monochromatic display.
Switching to the Info pane, we see the image has a single channel using int8 pixel values. We also see from the Info pane that the image lists the default Pseudo-Mercator projection shown in red color, indicating it is a placeholder for an coordinate system that is unknown, since none was specified by the BIL file.
The austin.bil file did not have a .prj associated with it and thus was not imported with a coordinate system assigned. When we intend to work with this data in a real GIS project we will need to launch Assign Initial Coordinate System to specify the correct initial projection for the imported imagery. Since this topic only shows how to combine three bands into a single image, we will not bother hunting down the coordinate system that should be used.
If we open the other two images, we see that all three monochrome images are all int8, single channel images. If we open the austin Tiles table, we can see what is going on.
Images take their content from a Tile type field in a table. Opening the austin Tiles table we see it contains three such tile fields, a tile field for each of the three bands of the .bil image that was imported.
In the illustration above we have right-clicked the column header for the Tile field and chosen Style, to change the format for the Tile field to a format that reports the size of the tile as well as the data type of each channel and the number of channels. That shows each of the tile fields contain single-channel tiles using an int8 data type value per pixel. Using three tile fields, each with single channel tiles, is a classic way to store multiband data from a BIL file.
Presenting the contents of a .bil file as three separate bands is useful for some times of technical analysis, but it does not convey visual, photographic information in a user-friendly way. We can fix that with a bit of work, to create an RGB image by combining all three images into a single int8x3 three channel image.
One way to create an RGB image is to combine data from the three int8 tile fields into a new, computed tile field that stores an int8x3 data type for each pixel, that is, a triplet of values. The new computed tile field is computed using an SQL expression. We can then create a new RGB or BGR image from that new image, using each component of the triplet as a channel in the new image image.
With the focus on the table, we choose Edit - Schema to launch the Schema dialog.
The Schema dialog shows us that the three different tile fields each have had a spatial index built upon them. Manifold uses a standard naming scheme by default, where the name of a tile field's index will be the name of the tile with an _x appended, and the names of the X and Y fields for the index prefixed.
We will now add a new, computed field.
Press the Add command button and then choose Field in the drop down menu.
In the Field dialog we enter the name TileAll and choose data type tile. For pixels type, we choose int8x3, and we leave the size of the tile at 128 x 128 since that is the size of the other tiles in the table. We want to make this a computed field, so we press Edit Expression to launch the Expression dialog.
In the Expression dialog we enter the expression:
TileChannelsConcat([Tile1],
TileChannelsConcat([Tile2], [Tile3]))
This expression builds a value for each int8x3 triplet by starting with the value from the Tile3 column and concatenating onto that the value from the Tile2 column, which results in a ([Tile3], [Tile2]) doublet, and then in turn concatenating onto that the value from the Tile1 column, resulting in a ([Tile3], [Tile2], [Tile1]) triplet. We press OK.
Back in the Field dialog we check our work and press OK.
The new, computed field appears in provisional, bluish color in the schema. It has not yet been added to the table, but will be when we press the Save Changes button.
We will not do that quite yet, as we want to add a spatial index on the new field.
Manifold uses spatial indexes on tile fields to enable faster fetch and display of tile data in images. When we import from typical image formats, both the tile field and the spatial index for the tile field normally will be created automatically by Manifold in the table. When we manually create a new tile field in a table, we should create a spatial index on that tile field as well. This is easy to do.
Press the Add command button and then choose Index in the drop down menu.
In the Index dialog we provide a name for the new index, using the usual naming pattern recommended for indexes. We could name the index whatever we want, but it makes sense to use a name that a literate Manifold user will immediately recognize as the name of an index on a tile. X_Y_TileAll_x is more recognizable than naming the index Ringo or Josephine.
We choose spatial index for tiles (rtree) as the type, the X and Y fields, the TileAll tile as the Tile, and we leave the other entries as loaded by the dialog by default. Press OK.
There, that was easy! The new index appears in provisional, bluish color in the schema. To apply the changes we have made to the table, we press Save Changes.
Immediately, the new tile field appears in the table. The table reports it uses int8x3, a triplet of int8 numbers, as the pixel type in the tiles. The new TileAll column appears in read-only gray background because it is the result of a computed field. The column values cannot be edited directly by us, because they are computed automatically by the system.
Now that we have created a new, computed tile field in the table, our final step is to create an image that displays those tiles.
Before we do, we right_click on one of the existing three images and choose Properties so we can see the size of the image given in the Rect property. We need that information to ensure that the new image we create matches the dimensions of the other images. In the dialog above we see that the bounds are [ 0, 0, 1679, 1903 ]. We right-click that cell and choose Copy to copy those bounds, for later use.
In the Project pane we right-click on the austin Tiles table and we choose Create - New Image.
In the New Image dialog we use the default Name of austin Tiles Image.. We choose the TileAll field for the Tile, leaving the other values as set by the dialog by default. In the Bounds box we Paste the bounds value previously copied, so the size of [ 0, 0, 1679, 1903 ] is used. We pause for a moment to curse the inconvenience of having to do so manually, and make a mental note to send in a Suggestion recommending this be done automatically. We leave the coordinate system as is, and then we press Create Image.
A new image called austin Tile Image appears in the Project pane.
When we double-click open the austin Tiles Image we first see a blank window with a red message icon in the tab. Clicking View - Messages we see an invitation to build intermediate levels. That only needs to be done once for a new image, so we click the button to do that and the image opens. We see it is a gray scale photographic image.
We zoom into the image to see it shows an aerial photo of the Austin, Texas, region.
If we click open the Style dialog (not illustrated) we see that it is a BGR image where the three channels, one from each of the tile fields in the original table, are combined to produce a gray scale image. This is an unusual arrangement for photography but something one runs into with BIL files that might have imaged a region using different frequencies, such as infrared, in different bands.
Assign Initial Coordinate System
BIL, ESRI Band Interleaved by Line