[erdas-l] Modeler: Replace value

425 views
Skip to first unread message

Fairuz Mohamad

unread,
Mar 18, 2009, 1:14:09 AM3/18/09
to ERDAS Discussion List
Hello,

I have two files, A and B. I want to replace/subsitute pixel value(selected only) in file A with the pixel value in file B ( at the same location in file A)  and  create a new raster file. but the other pixel value in file A maintain, so new raster file contain , pixel value from file B(after replace) + pixel value file A
How to write it in modeler?



%2=%1
if %2<=0 then
%2=%3
endif

%2=file B
%1=file A
%3=new file
<=0 means the pixel less or equal zero

Here, is the simple model in other software but how to make it in erdas>modeler
 
A journey of thousand miles starts with one step.
Good judgement comes from experience and experience comes from bad judgement.."pacat" 



From: Donn Rodekohr <ROD...@auburn.edu>
To: ERDAS Discussion List <erd...@lyris.dundee.net>
Sent: Monday, March 2, 2009 11:16:15 PM
Subject: RE: [erdas-l] Modeler: Thematic Level Slice of Terrain

James,

Wan stole my suggestion.  Good for Wan.

Secondarily, the CONDITIONAL statement works by accepting the 1st true
condition and outputting the result.  Therefore, you do not have to use
both the ends of your classification scheme within the statement.  For
example, your conditional statement of
CONDITIONAL {
(($n1_srtm30) lt 0) 1,
(($n1_srtm30) == 0) 2,
((($n1_srtm30) gt 0) AND (($n1_srtm30) le 5)) 3, 
((($n1_srtm30) gt 5)
AND (($n1_srtm30) le 10)) 4,....

will get the same results as this statement:
CONDITIONAL {
(($n1_srtm30) lt 0) 1,
(($n1_srtm30) == 0) 2,
(($n1_srtm30) le 5)) 3, 
(($n1_srtm30) le 10)) 4, ...

or if you want to descend rather than ascend
CONDITIONAL {
(($n1_srtm30) lt 0) 1,
(($n1_srtm30) == 0) 2,
(($n1_srtm30) Ge 500)) 24, 
(($n1_srtm30) GE 495)) 23, ...

In essence the CRITERIA function is an automated interface to the
CONDITIONAL statement.  Use which ever is most easily understood by
you.

Also, since the modeler edit box can receive pastes from an outside
source, I have created spreadsheets with variables that will generate
the CONDITIONAL statements of varying lengths and varying increments.
with some judicious uses of IF and CONCATENATE you can make the spatial
modeler command and then copy/paste it directly into you Spatial model.
since I am essentially a lazy typist I'll use a spreadsheet to generate
the code rather than editing each line within the SM edit box.  I'm more
prone to find and fix an error using this method.


Donn Rodekohr, Spatial Analyst
230 Funchess Hall
Agronomy and Soils Department
Auburn University
Auburn, AL  36849
334-844-3989

>>> Wan Bakx <ba...@itc.nl> 3/2/2009 2:14 AM >>>
Dear James,

The Criteria function is designed for that. You can quickly make a
table
with output values and corresponding ranges e.g.
Output    $n1 LnDEM
1        <=1000
2        <=1100
3        <=1200

Of course you would have to change the Data type and File type of the
output file to unsigned Byte and Thematic layer respectively.
Etc

Wan


-----Original Message-----
From: erd...@lyris.dundee.net [mailto:erd...@lyris.dundee.net] On
Behalf Of James
Sent: Saturday, February 28, 2009 2:39 AM
To: ERDAS Discussion List
Subject: [erdas-l] Modeler: Thematic Level Slice of Terrain

I am building a model to create a thematic level slice from terrain
data
and was wondering if there might be an easier way to accomplish this.

As an input, I have a continuous terrain file (signed 16-bit). I'd
like
to create an unsigned 8-bit thematic image, sliced at 5m vertical
intervals (e.g., Class 1 = 0m-5m; Class 2 = 5m-10m; Class 3 = 10m-15m,
etc).

Here is a sample of my function definition (from an older version).
This
model works fine, but writing all of these individual 5m intervals up
to
500m (or greater) takes so much time! I actually built this entire
model
up to 500m, saved it, then the modeler crashed and I cannot re-open
the
model!

Perhaps there is a function that will automatically create the level
slice based on an interval I input???

CONDITIONAL { (($n1_srtm30) lt 0) 1, (($n1_srtm30) == 0) 2,
((($n1_srtm30) gt 0) AND (($n1_srtm30) le 5)) 3,  ((($n1_srtm30) gt 5)
AND (($n1_srtm30) le 10)) 4,  ((($n1_srtm30) gt 10) AND (($n1_srtm30)
le 15)) 5,  ((($n1_srtm30) gt 15) AND (($n1_srtm30) le 20)) 6,
((($n1_srtm30) gt 20) AND (($n1_srtm30) le 25)) 7, ((($n1_srtm30) gt
25)
AND (($n1_srtm30) le 30)) 8, ((($n1_srtm30) gt 30) AND (($n1_srtm30)
le
35)) 9, ((($n1_srtm30) gt 35) AND (($n1_srtm30) le 40)) 10,
((($n1_srtm30) gt 40) AND (($n1_srtm30) le 45)) 11, ((($n1_srtm30) gt
45) AND (($n1_srtm30) le 50)) 12, ((($n1_srtm30) gt 50) AND
(($n1_srtm30) le 55)) 13, ((($n1_srtm30) gt 55) AND (($n1_srtm30) le
60)) 14, ((($n1_srtm30) gt 60) AND (($n1_srtm30) le 65)) 15,
((($n1_srtm30) gt 65) AND (($n1_srtm30) le 70)) 16, ((($n1_srtm30) gt
70) AND (($n1_srtm30) le 75)) 17, ((($n1_srtm30) gt 75) AND
(($n1_srtm30) le 80)) 18, ((($n1_srtm30) gt 80) AND (($n1_srtm30) le
85)) 19, ((($n1_srtm30) gt 85) AND (($n1_srtm30) le 90)) 20,
((($n1_srtm30) gt 90) AND (($n1_srtm30) le 95)) 21, ((($n1_srtm30) gt
95) AND (($n1_srtm30) le 100)) 22, ((($n1_srtm30) gt 100) AND
(($n1_srtm30) le 105)) 23, (($n1_srtm30) gt 105) 24}
---
You are currently subscribed to erdas-l as: ba...@itc.nl..
To unsubscribe send a blank email to
leave-31407429-125933268.9ee...@lyris.dundee.n

et
International Institute for Geo-Information Science and Earth
Observation (ITC)
Chamber of Commerce: 410 27 560

E-mail disclaimer
The information in this e-mail, including any attachments, is intended
for the addressee only. If you are not the intended recipient, you are
hereby notified that any disclosure, copying, distribution or action in
relation to the content of this information is strictly prohibited. If
you have received this e-mail by mistake, please delete the message and
any attachment and inform the sender by return e-mail. ITC accepts no
liability for any error or omission in the message content or for damage
of any kind that may arise as a result of e-mail transmission.

---
You are currently subscribed to erdas-l as: rod...@auburn.edu..
To unsubscribe send a blank email to
leave-31430668-58163005.68a6...@lyris.dundee.net=




---
You are currently subscribed to erdas-l as: jcf...@rocketmail.com.
To unsubscribe send a blank email to leave-31434480-96469479.e82b...@lyris.dundee.net


--- 
You are currently subscribed to erdas-l as: erdas-l-gar...@googlegroups.com. 
To unsubscribe send a blank email to leave-31650867-120484586.1d5...@lyris.dundee.net

Paul Beaty

unread,
Mar 18, 2009, 6:22:49 AM3/18/09
to ERDAS Discussion List
Did you look at image interpreter / gis / ovelay for an example?


--
Sent from my Blackberry. Please pardon my typing errors, if any.
You are currently subscribed to erdas-l as: paul....@erdas.com.
To unsubscribe send a blank email to leave-31650867-95268427.ff40...@lyris.dundee.net

---
You are currently subscribed to erdas-l as: erdas-l-gar...@googlegroups.com.
To unsubscribe send a blank email to leave-31652373-120484586.1d5...@lyris.dundee.net

Lilik Budi Prasetyo

unread,
Mar 18, 2009, 9:12:16 AM3/18/09
to ERDAS Discussion List

It seem conditional function within erdas modeler can be applied.

Lilik
Bogor Agric. Univ.

> lbp...@indo.net.id.


> To unsubscribe send a blank email to

> leave-31652373-40133625.ba18...@lyris.dundee.net


___________________________________________________________
indomail - Your everyday mail - http://indomail.indo.net.id

---
You are currently subscribed to erdas-l as: erdas-l-gar...@googlegroups.com.

To unsubscribe send a blank email to leave-31653966-120484586.1d5...@lyris.dundee.net

Adrian Benitez

unread,
Mar 18, 2009, 9:48:52 AM3/18/09
to ERDAS Discussion List

Fairuz,

 

 

Make a simple model maker. Two inputs, one function and one output. Connect the inputs to function, and the function to output. Set the inputs with your raster files A and B. Set the output with a new file name (C).

 

In the function write one of these sentences. Choose one of them according to your preference/objectives.

 

 

EITHER  $fileB                   IF   ($fileA <= 0)    OR    $fileaA              This condition copy A to C(new file) but replaces with B when A is less or equal to zero

EITHER  $fileB+$fileA    IF    ($fileA <= 0)    OR    $fileaA              This condition copy A to C(new file) but replaces with A+B when A is less or equal to zero

 

 

Regards,

 

 

Adrian E. Benítez, Ing. Agr.

Responsable Geographic Imaging, Aeroterra S.A.

aben...@aeroterra.com

www.aeroterra.com

You are currently subscribed to erdas-l as: aben...@aeroterra.com. 
To unsubscribe send a blank email to leave-31650867-87054609.6468...@lyris.dundee.net

--- 
You are currently subscribed to erdas-l as: erdas-l-gar...@googlegroups.com.. 
To unsubscribe send a blank email to leave-31654356-120484586.1d5...@lyris.dundee.net

Donn Rodekohr

unread,
Mar 18, 2009, 10:45:36 AM3/18/09
to ERDAS Discussion List
Fairuz,

If I understand the problem correctly I think that this Modeler
statement will do what you are asking

Input files: $n1_A, $n2_B
Output file: $n3_C
Function statement:
Either $n1_A + $n2_B if ($n1_A == $n2_B) or $n1_A otherwise

This statement will add A+B to every location where A=B. If you want
to restrict the summation to a specific values, 16 and 49 for example,
then I would suggest the following CONDITIONAL statement be used:
Conditional {
($n1_A == 16) $n1_A + $n2_B,
($n1_A == 49) $n1_A + $n2_B,
(default) $n1_A}

This statement will scan through file A and will repeat the values for
A unless the value is equal to 16 or 49. In that case it will add A+B.

Hello,

%2=%3
endif

________________________________

James,

Wan

leave-31654356-58163005.68a6...@lyris.dundee.net

---
You are currently subscribed to erdas-l as: erdas-l-gar...@googlegroups.com.
To unsubscribe send a blank email to leave-31655241-120484586.1d5...@lyris.dundee.net

Fairuz Mohamad

unread,
Mar 18, 2009, 11:57:55 AM3/18/09
to ERDAS Discussion List
Tq Donn Rodekohr, Adrian Benitez,  Lilik Budi Prasetyo and Paul Beaty

 but I'm very sorry for a minimum typing error.

%2=%1                ----------------this command will create new file with the value same with file A
if %2<=0 then       ................this command will search any value less or equal to zero then
%2=%3                ...............the zero value will replace with value from file B, so automatically "new file" contain no zero value
                                           or less than that.
                                          
endif

%2=new file ( previously, file B)
%1=file A
%3=file B   (previously, new file)

<=0 means the pixel less or equal zero

sorry for my mistake

 
A journey of thousand miles starts with one step.
Good judgement comes from experience and experience comes from bad judgement.."pacat" 


From: Donn Rodekohr <ROD...@auburn.edu>
To: ERDAS Discussion List <erd...@lyris.dundee.net>
Sent: Wednesday, March 18, 2009 10:45:36 PM
Subject: RE: [erdas-l] Modeler: Replace value
To unsubscribe send a blank email to leave-31655241-96469479.e82b...@lyris.dundee.net


--- 
You are currently subscribed to erdas-l as: erdas-l-gar...@googlegroups.com.. 
To unsubscribe send a blank email to leave-31656210-120484586.1d5...@lyris.dundee.net

Adrian Benitez

unread,
Mar 18, 2009, 1:20:30 PM3/18/09
to ERDAS Discussion List

Fairuz,

 

 

In some cases, I prefer to use a general math expression instead of conditional statement syntaxes. You can prove this way.

 

For example, you can replace the following ERDAS conditional statement

 

EITHER  $fileB        IF   ($fileA <= 0)    OR    $fileaA    OTHERWISE          (This condition copy A to C(new file) but replaces with B when A is less or equal to zero)

 

 

By this algebraic expression :

 

$fileB*($fileA <= 0) +  $fileaA *($fileA > 0)   

 

If (relation) is true, the system returns the value  1 (one) . If it is false, a 0 (zero)  will be returned.

Thus, you can use the neutrality of some  math operators and relational operators, instead of specific  conditional commands

In some systems, value -1  is the result from  true conditions.

 

 

Adrian E. Benítez

Aeroterra S.A.

Buenos Aires. Argentina

You are currently subscribed to erdas-l as: aben...@aeroterra.com.. 
To unsubscribe send a blank email to leave-31656210-87054609.6468...@lyris.dundee.net

--- 
You are currently subscribed to erdas-l as: erdas-l-gar...@googlegroups.com
.. 
To unsubscribe send a blank email to leave-31656749-120484586.1d5...@lyris.dundee.net
Reply all
Reply to author
Forward
0 new messages