Spatial Join Example: Create RGB Image with a Raster Join

Spatial joins between  images and images use spatial relationships between the locations of pixels in the source, joined image and the locations of pixels in the target, original image to join data into the original image.    The Edit - Join dialog provides spatial joins between images that are layers in maps.    This allows transferring values from pixels in an image, such as a terrain elevation raster, to pixels in a target image layer, packaged within an easy to use dialog.  Spatial joins between images and images work between layers in the same map.  Layers can be in different data sources.

 

Add channels using a spatial join:

 

  1. With the focus on an image layer in an open map window, choose Edit - Join.
  2. In the upper right box choose the joined image in the map from which channels will be joined.  This can be the same image as the original image, for a self-join.

  3. Click the Add button to choose a channel in the joined image that will provide data for a new channel in the original image.  The only spatial method is matches, that is, the pixels from which joined data is transferred are at the same location.

  4. Press Join.

 

Transfer into an existing channel using a spatial join:

 

  1. With the focus on an image layer in an open map window, choose Edit - Join.
  2. In the upper right box choose the joined image in the map from which channels will be joined.   This can be the same image as the original image, for a self-join.

  3. In the row for the channel in the original image that will receive data, double-click on the rightmost cell to choose a channel in the joined image that will provide data for that existing channel in the original image.  The only spatial method is matches, that is, the pixels from which joined data is transferred are at the same location.

  4. Press Join.

Example

A raster to raster join:  Given three images, each of which is a single channel image containing only red channel, blue channel or green channel data, we use the Join dialog to join the three images into a new RGB image.

 

The workflow in this example is shown in video form as part of the Join Dialog Part 6 - Raster to Raster Joins  video.   Another video that shows how to combine channels to create an RGB image is the Create RGB from RGBA using Join  video.

 

 

We start with a map that uses a Bing streets layer as background and which contains three layers, called Ch0, Ch1, and Ch2, each of which is a single channel image.  In the illustration above, only one of the three single channel images layers is on for display.

 

 

We can open each of the images in its own window to see all three by default are visualized as grayscale images.  The three images are three different bands imaged by a satellite sensor.   Ch0 has been sensed using frequencies seen by the human eye as red colors, Ch1 has been sensed using frequencies sensed as green, and Ch2 has been sensed using blue frequencies.  When assembled into a single image using Ch0 for red display, Ch1 for green display, and Ch2 for blue display, we will have a typical RGB image using three channels that the human eye will see as a natural color image.

 

We first will create a new image that will become our RGB image.    We create that image by copying and pasting one of the single channel images to create a new image, and then we will add channels to that image.

 

 

In the Project pane we Ctrl-click the Ch0 and Ch0 Tiles components to highlight them, and then we press Ctrl-C to Copy them.   We could also have chosen Edit - Copy or  pressed the Copy button on the Project pane toolbar.

 

 

We press Ctrl-V, the standard Windows keyboard shortcut to Paste, which creates copies of the two components called Ch0 2 and Ch0 Tiles 2.   We right-click onto Ch0 2 and choose Rename Related to rename both components into something more descriptive.

 

 

In the Rename Related dialog, we rename the image component RGB Image and the dialog automatically renames the table RGB Image Tiles.   We press Rename.

 

 

We now have a conveniently named image and table called RGB Image and RGB Image Tiles.    This image and tables are copies of the Ch0 image and table.   We could have started by copying and pasting either the Ch1 or Ch2 image and table, but we have chosen Ch0 since doing the workflow in numeric order of channels seems easier to remember.

 

 

Dragging and dropping RGB Image into the map, we see it is an exact copy (as, of course, it should be) of Ch0.    It is an image with one channel, Channel 0, where the contents of that channel came from Channel 0 in the Ch0  image.   The Ch0 image contains an image sensed in the red band, so our RGB Image has a single, Channel 0, channel that contains values for the Red channel.

 

We now will use the Join dialog to add two more channels, Channel 1 taken from the Ch1 image that will be used for Green values, and Channel 2, taken from the Ch2 image that will be use for Blue values.

 

With the focus on the RGB Image  layer in the map, we choose Edit - Join

 

 

In the Join dialog we choose Ch1 as the image to join.

 

Press the Add button to add a new channel.

 

 

The menu that drops down lists all the channels available in the Ch1 image.  There is only one channel in the image, Channel 0, so that is the channel we pick.

 

 

The dialog adds a new row, which will add a second channel to the RGB Image.  That second channel will be Channel 1 and it will be populated with pixel values in each spatial position that are copied from Channel 0 in the Ch1 image.   That is exactly what we want, since the Ch1 image is full of values to be used for a Green channel, and Channel 1 is used for Green in a typical RGB arrangement.

 

Press Join.

 

 

There is no visible difference in the map display, since the RGB Image layer is still styled only a single channel.  

 

Next, we will add another channel to RGB Image, creating an image with three channels.

 

With the focus on the RGB Image layer in the map, we choose Edit - Join.

 

 

In the Join dialog we choose Ch2 as the image to join.

 

Press the Add button to add a new channel.

 

 

The menu that drops down lists all the channels available in the Ch2 image.  There is only one channel in the image, Channel 0, so that is the channel we pick.

 

 

The dialog adds a new row, which will add a third channel to the RGB Image.  That third channel will be Channel 2 and it will be populated with pixel values in each spatial position that are copied from Channel 0 in the Ch2 image.   That is exactly what we want, since the Ch2 image is full of values to be used for a Blue channel, and Channel 2 is used for Blue in a typical RGB arrangement.

 

Press Join.

 

 

The image updates to show a display using all three channels, but in default BGR ordering, the same order in which they are stored.   We will use the Style pane to switch to RGB order.

 

 Before launching the Style pane, we quickly click on the Bing tab and then we click back onto the RGB Image tab.   That forces a refresh and updating of all styling info, to correctly account for changes to RGB Image such as the addition of channels.   Future Manifold builds will do that automatically.

 

Choose the Style pane.

 

 

Click on the Assign Channels quick selector button.

 

 

Choose RGB.

 

 

Press Update Style.

 

 

The image immediately updates to show RGB channel interpretation, providing a natural color rendering of the scene.

 

In this example we began with three, single-channel images that were acquired using red, green, and blue frequencies, respectfully.   Putting together three different single-channel images to form a three-channel RGB image is a routine task.    We can use exactly the same workflow to assemble an RGB image from single-channel images that were sensed using non-visual frequencies, such as infrared bands.    

 

Many satellite sensors will acquire data in bands that the human eye cannot see.  A typical way of providing visualizations of such data is to create a false color RGB image where non-visual frequencies are used for red, green, and blue channels.  

 

Notes

Sample Image - The sample image shows the nuclear warhead storage area, in the center of the view, within the Francis E. Warren Air Force Base near Cheyenne, Wyoming.  The storage area contains approximately 170 nuclear warheads for Minuteman III intercontinental ballistic missiles.

 

Terminology - The original table also may be called the target table, and the table providing data also may be called the source table.

 

Quick reference - With the Join dialog open, press F1 to open a quick reference guide in a browser window.

 

Why not have a copy transfer method for drawing to image joins? - In the examples above we chose as the transfer method either max when we expected no area overlaps, or sum when we expected overlaps.   Why not have a copy transfer method that in the case of multiple areas containing the same pixel, the system just pulls the first value from one of the areas it encounters?   That is not done because when areas overlap they usually overlap in a way that covers more than one pixel.  Suppose a few hundred pixels are in the region of overlap.  If copy existed, it would simply pull values from whatever one of the overlapping areas it first encountered.  But because there is no ordering in such things, different pixels within the region of overlap might have values pulled from different areas, resulting in different values for different pixels within the region of overlap.  

 

If count, min, max, or sum are not sufficient transfer methods to handle the aggregate effect of multiple areas covering the same pixels, the solution is to first clean up the overlaps in the drawing.  One way to do that is to perform a Merge Areas transform, then to convert the resulting areas to lines, and then finally to create Bounded Areas on those lines.  The result will be independent area objects in all regions of intersection of overlapping areas.  Transferring attribute values to those regions of intersection will still require some sort of logic to choose which area value to assign, but at least such logic can be done using arbitrarily complex expressions instead of the simple list of options within the Join dialog.

 

Guessing the key field - When we launch the dialog with an original field and when we choose a joined field, the dialog will try to guess what fields we might want to use as key fields and will load those first by default.  If it guesses wrong, we can choose the field we want.   For the original table, the dialog tries to use a field (other than mfd_id) that has a BTREE / BTREENULL index, with a data type preference for numbers, then text, then everything else, and a name preference for field names with id in them, such as ... id or ..._id, then ...id and then everything else. For the joined table, the dialog uses similar logic, but first tries to use a field with the same name as in the original table.

 

Added fields are static - Added fields are static, that is, if data in the joined table changes the fields in the original table that received data in the Join operation from the joined table will not automatically be updated.  We can easily update the table any time we want using a saved update query.  

 

Spatial joins are automatically parallel - Joining data between drawings uses parallel GeomOverlay function variants.  Joins from images to drawings are parallelized through a nested SELECT using THREADS.

 

Videos

See the Join Videos list of videos showing how to use the Join dialog.

See Also

Maps

 

Tables

 

Queries

 

Drawings

 

Images

 

Editing and Combining Data

 

Join

 

Join Videos

 

Join Examples

 

Command Window

 

JOIN Statements

 

Editable Results Tables