How to multiply two layers based on particular fields?

2550
6
Jump to solution
05-26-2012 11:56 AM
JamalNUMAN
Legendary Contributor

How to multiply two layers based on particular fields?
In the screenshot below, I wanted the first raster based on the field named ???I_factor??? with the second raster based on the field named ???value??? but couldn???t know the correct syntax to perform this process!
What might be the correct syntax?

[ATTACH=CONFIG]14673[/ATTACH]

Thank you for the help,
Best
Jamal

----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
1 Solution

Accepted Solutions
TimothyHales
Esri Notable Contributor
You should be able to do this with the Lookup function similar to one of your other forum posts:What is wrong with this syntax when using the ???raster calculator????.

"P_rec" * Lookup("I_rec","I_factor")

View solution in original post

6 Replies
TimothyHales
Esri Notable Contributor
You should be able to do this with the Lookup function similar to one of your other forum posts:What is wrong with this syntax when using the ???raster calculator????.

"P_rec" * Lookup("I_rec","I_factor")
JamalNUMAN
Legendary Contributor
You should be able to do this with the Lookup function similar to one of your other forum posts:What is wrong with this syntax when using the �??raster calculator�?�?.

"P_rec" * Lookup("I_rec","I_factor")


Many thanks for the help Timothy. The syntax you have provided solved my issue.

[ATTACH=CONFIG]14850[/ATTACH]
----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
JamalNUMAN
Legendary Contributor

Is there a way to use the “times” tool in order to multiply two rasters based on particular fields?

----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
NawajishNoman
Esri Contributor

Hi Jamal, 

You can use the Lookup tool to create a new raster by looking up values found in another field in the table of the input raster.

You can create a model or you can write a map algebra expression as follows to solve your problem. 

This map algebra expression does 3 things in one shot 

1. It creates a raster using the value from P_Value field from P_map raster - let's call it P_Value_Raster

2. It creates a raster using the value from I_Factor field from I_map raster - let's call it I_Factor_Raster

3. Finally it multiplies P_Value_Raster with I_Factor_Raster to create the final output times_ P_I raster object

Since the expression is executed in one shot, you don't see the outputs from step 1 and 2. You get the final output times_ P_I .

However, the output from a map algebra expression is temporary, so, don't forget to save your output by calling the Save method.

Thanks

Noman 

JamalNUMAN
Legendary Contributor

Thanks Nawajish.

 

It appears that using the “raster calculator” tool is much efficient in this case

Lookup("%P_Rank%","P_Rank") * Lookup("%I_map%", "I_Factor")

 

----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
NawajishNoman
Esri Contributor

Hi Jamal,

I am glad that you find Raster Calculator more efficient for your workflow. 

The Raster Calculator tool is designed to execute a map algebra expression in a model. It executes the same expression as you would do in Python Window or in a standalone Python script. However, it creates a persisted output like any other Geoprocessing tool.

From analytical and execution point of view, it works the same way like any map algebra expression, just a different user experience.

Please free free to use whatever suits your workflow. Please let me know if you see any real performance different between executing it from a Raster Calculator and from Python Window or in a standalone Python script.

I hope, you are enjoying the Lookup functionality which has been improved recently to make it efficient.

Thanks!

Noman