Monday, June 9, 2008

Camel's 'R' Us

I am working on creating scripts to create weighted linear combination. Basically duplicating different features in Idrisi so that I can have two models, one in ArcGIS and Idrisi. This is for the "Camel Project." I have a script now that calculates the weights for a pairwise matrix. Once I found a little information on this topic it was fairly easy to create. It is mostly just multiplying the matrix until the differences between the weights calculated from each iteration equals zero. Unfortunately, the python script is dependent on NumPy (Numerical Python), so it isn't as self-contained as I would like. I didn't feel like writing a function to multiply matrices, although I did this in VB.NET. I also am able to calculate the consistency ratio. I would share the script, but I because I am getting paid to do it, it is up to the client.

I also have managed to use Raster Calculator to duplicate the Fuzzy tool in IDRISI. It is a duplicate of the Linear function, and there are two ways to calculate it. One for monotonically increasing, and the other for monotonically decreasing. The formula is for 0 to 255.
Con is a map algebra function that means conditional. Con(test, true, false).

Here is how it works for monotonically decreasing:

INT((Con([RasterToBeScaled] <> 900, 0,( ((900 - [RasterToBeScaled]) * 255) / 900) + 0))) + .5)

Con([RasterToBeScaled] <> 900, 0 if the cell value is greater than 900 give this cell a value of 0. If it is false then calculate the value
( ((900 - [RasterToBeScaled]) * 255) / 900) + 0)))

INT and +.5 rounds the values properly and removes the decimal places.
The range of this example is from 0 to 900, so you need to change those values depending on what your "maximum and minimum" values are going to be. You really divide 900 - [RasterToBeScaled] by the range (max - min raster values). Since my range was 0 to 900 I skipped this and put 900.

If you need this to increase then you have to change some of it around.
INT((Con([RasterToBeScaled] <> 900, 255,( (([RasterToBeScaled] - 0) * 255) / 900) + 0))) + .5)

Now, whatever is less than zero is zero and greater than 900 is 255. Everything in between is calculated using the formula:
( (([RasterToBeScaled] - 0) * 255) / 900) + 0))
So now we subtract the cell value by the lowest value in your range and everything else is the same.

This is similar, but not quite what I was looking for.

Hope that helps...

1 comment:

TIME FOR ME TO OPEN UP AND SHOW THE PERSON I AM said...

Hello,
It was nice to read your article. I would like to know whether you have any idea regarding how we can perform fuzzy addition, multiplication and division in arcgis. I have a set of input raster grids representing different parameter. The task is to fuzzfied all the parameters in arcgis, then use some fuzzy operator to get an output, thereby can be defuzzified in later step to get a corresponding crisp output.
Thanking you,
Regards,
Bakim