Parent Topic: MODEL

Examples

MODEL can be used for both imagery and raster GIS applications. The examples presented here have been selected to show a range of possible applications and to stir the user's imagination.

The first example (called Detailed) is described in depth; the other examples only show the model itself.

Please note: if it is possible to perform an operation using an existing PACE program (for example, using ARI for simple image arithmetic, or FAV for 3x3 smoothing filters), then these programs should be used rather than MODEL since they will execute more rapidly.

Detailed

A project requires the generation of a map showing areas of high fire risk. The study region is mountainous and it has been determined that the risk of fire increases with elevation and ground cover type. The base elevation at which the risk starts varies with the time of the year and the amount of rainfall which has occurred. This base elevation is computed on a monthly basis from available weather data.

The file `irvine.pix' contains 16-bit elevation data held in channel 10 (signed 16-bit channel) expressed in metres. Channel 6 contains Land use / Land coverage data obtained from the U.S. Geological Survey. Segment 28 on the database contains the attribute data identifying the coverage codes. A partial listing of this data is shown below:

  ! Land Use / Land Cover Classification System from USGS.
  !
  ! Grey level ; Level 1      Level 2
  !
           11 ; Urban        Residential
           12 ; Urban        Commercial
           13 ; Urban        Industrial
           14 ; Urban        Transportation
           15 ; Urban        Commercial/Industrial 
           16 ; Urban        Mixed
           17 ; Urban        Other
           21 ; Agriculture  Crop/Pasture
           22 ; Agriculture  Orchards
           23 ; Agriculture  Feeding
           24 ; Agriculture  Other
           31 ; Rangeland    Herbaceous
                         . . .
It has been determined that only land classed as 'Agriculture', 'Rangeland' and 'Forest' are at risk. The model will generate a new output channel (layer) showing areas of risk and will also generate a report giving the acreage of each class at risk. To improve the appearance of the report, the following text was entered into a text file, 'labels.att':

  ! Channel 7 Class ;  Class Name
          0         ;  'No Risk'
         20         ;  Agriculture
         30         ;  Rangeland
         40         ;  Forest
The actual model is shown below and was entered into a text file called 'risk.mod'.

                Fire Risk Zone Model

  !In this model, we are assuming that channel 6 is the coverage
  !and channel 10 is elevation data.
 
  !Setup Section
 
  input 'Enter base elevation: ' #base;  !Prompt user for elevation
  seta  %6 = 28;                         !Land use/Land cover attributes
  seta  %7 = 'labels.att';               !Labels for report
 
  print 'Channel 7 will receive the new coverage map.';
 
  !Equations section
 
  #elev = %10;                  !elevation to a single value
  if (#elev<#base) then
      %7 = 0;
  else
      $class = %6.1;                    !Land class
      if     ($class = 'Agriculture') then
         %7 = 20;
      extrif ($class = 'Rangeland') then
         %7 = 30;
      extrif ($class = 'Forest') then
         %7 = 40;
      else
         %7 = 0;
      endif;
  endif;
 
 !Report Section:  Generate an area report with title
 
 title 'Fire Risk Area Report';

 report %7 by hectares identify %7.1;
To actually run the model, the following commands are entered:

 EASI> FILE = "irvine.pix"
 EASI> SOURCE="risk.mod"
 EASI> UNDEFVAL=
 EASI> REPORT = "term"
 EASI> RUN MODEL
A copy of the generated report is shown below:

  Fire Risk Area Report

  Value    Pixels         Hectares    Identifier

      0     91059         8195.310    No Risk
     20     46025         4142.250    Agriculture
     30    119843        10785.870    Rangeland
     40      5217          469.530    Forest

Arithmetic

Perform a `Vegetative Index' calculation using channels 1 and 2, saving the result to channel 7. If channel 7 is 32 bit real, the following model is used:

   %7=(%1-%2)/(%1+%2);
If channel 7 is 8-bit, some scaling and adjustment is necessary:

   %7=((%1-%2)/(%1+%2))*128 + 127.5;

Blending

Create an image which smoothly blends channel 1 into channel 2 as we move across the image. The output is placed in channel 7.

   %7 = (@x-1)/@dbx)*%2 + (@dbx-@x)/@dbx*%1;

Testimages

Create a grey level ramp of 0 to 255 across an image plane.

   %7 = ((@x-1)*255) / @dbx;

Grids

A file is georeferenced in UTM coordinates. As part of the final processing steps, the user wishes a grid to be superimposed on the imagery along 1000-metre intervals in both the x and y directions. The input imagery is an RGB-enhanced image on channels 1, 2, 3. The output will be to channels 7, 8, and 9.

   if (mod(@geox,1000)<=@sizex) or (mod(@geoy,1000)<=@sizey) then
      %7 = 255;   %8 = 255;   %9 = 255;
   else
      %7 = %1;    %8 = %2;    %9 = %3;
   endif;
The following model prompts the user for the spacing (in pixels) for a regular grid as well as an input and output channel.

   input 'Enter the grid spacing:   ' #s;
   input 'Enter the input  channel: ' %in;
   input 'Enter the output channel: ' %out;
   if (mod(@x,#s)=0) or (mod(@y,#s)=0) then
     %out=255;
   else
     %out=%in;
   endif;

Volume

One of the steps in producing a study for a new dam project is to estimate the capacity of the reservoir that will be formed. This can be accomplished by summing the volume that is contributed by each pixel that will be in the reservoir. Given that:

Channel 10 has the elevation for each pixel expressed in metres.

Channel 7 has a mask where a pixel value of 27 means the pixel is in the reservoir area, any other value means it is not. (This mask was created from the elevation channel by altering the elevation data to show the line of the dam at its maximum final built height, thresholding at the surface elevation of the reservoir (program THR), burning the resulting bitmap into a channel (MAP), growing polygons for contiguous areas (IPG), then identifying the polygon number which represents the reservoir (DCP)).

The following model calculates the volume of the reservoir at a user-entered water level.

        !       Reservoir Capacity Model
        !
        input 'Enter water level in metres: ' #level;
        !
        if (%7 = 23) then
           #volume = (#level - %10) * @metrex * @metrey;
           if (#volume < 0) then #volume = 0; endif;
        endif;
        !
        title ' Capacity of Reservoir in Cubic Metres';
        report #volume by sum;

Filtering

Perform a 3x3 smoothing filter on channel 4.

        %7 = (%4[-1,-1] + %4[ 0,-1] + %4[ 1,-1] + 
              %4[-1, 0] + %4[ 0, 0] + %4[ 1, 0] +
              %4[-1, 1] + %4[ 0, 1] + %4[ 1, 1] ) / 9;
PACE program FAV performs this operation more efficiently.

Enhancement

Segments 2, 3, and 4 are lookup tables for channels 1, 2, and 3 respectively. Perform an enhancement operation on the three channels and output the enhanced images to channels 7, 8, and 9.

 seta %1=2; seta %2=3; seta %3=4;      %7=%1.1; %8=%2.1; %9=%3.1;
PACE program LUT performs this operation more efficiently.


Parent Topic: MODEL
About PCI Help Gateway