Parent Topic: MODEL
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.
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 MODELA 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
%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;
%7 = (@x-1)/@dbx)*%2 + (@dbx-@x)/@dbx*%1;
%7 = ((@x-1)*255) / @dbx;
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;
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;
%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.
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.