How to add field for raster that doesn???t have an attribute table?

2163
5
Jump to solution
06-03-2012 12:05 PM
JamalNUMAN
Legendary Contributor
How to add field for raster that doesn???t have an attribute table?

I???ve the raster that represent the rainfall and wanted to calculate the recharge. In order to do so, I need first to add field then to apply the ???if statement??? below:
-------------------------------------
if [Value] < 456 then
OP = .3 * [Value]
else
if [Value] >456 and [Value]  < 700 then
OP = .46*( [Value]  - 159)

else
if  [Value] > 700 then
OP = .36*([Value] -285)

end if
end if
end if
------------------------------------------
Then how to derive the recharge from the rainfall knowing that there is no attribute table for the rainfall?

[ATTACH=CONFIG]14892[/ATTACH], [ATTACH=CONFIG]14893[/ATTACH]

The raster is attached

Thank you for the help,

Best

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

Accepted Solutions
MarkBoucher
Occasional Contributor III

Jamal,


After some trial and error, I found that you need to enclose the expressions on either side of the "&" with "()"s.  The equestion below worked for me:

Con("Rainfall"<456, 0.3*"Rainfall", Con(("Rainfall">456) & ("Rainfall"<700), 0.46*("Rainfall"-159), 0.36*("Rainfall"-285)))


Also, you had wrapped the second Con() with "()" and I took that out.

You may want to explore the greater or equals to ">=" and less than or equal to "<=" test so your don't miss something that hits values right on.

Hope this helps.

View solution in original post

5 Replies
by Anonymous User
Not applicable
Original User: MBoucher21

Jamal,

Rasters are not the same as a point, polyline or polygon feature class. I don't think you can get an attribute table on a non-integer raster and you can't add another field to a raster attribute table.
 
You should be able to use the raster calculator to do what you want. You would use the CON() function in raster calculator instead of the IF statement. This will result in a new raster with the values you are calculating.

by Anonymous User
Not applicable
Original User: Jamal432@gmail.com

Jamal,

Rasters are not the same as a point, polyline or polygon feature class. I don't think you can get an attribute table on a non-integer raster and you can't add another field to a raster attribute table.
 
You should be able to use the raster calculator to do what you want. You would use the CON() function in raster calculator instead of the IF statement. This will result in a new raster with the values you are calculating.



Many thanks for the answer Mark.

I tried to write the If statement on the �??raster calculator�?� but doesn�??t sound to work!

What might be the mistake in my syntax?

[ATTACH=CONFIG]14917[/ATTACH], [ATTACH=CONFIG]14920[/ATTACH]


Con("%Rainfall%"<456, 0.3*"%Rainfall%", (Con(("%Rainfall%">456  & "%Rainfall%"<700), 0.46*("%Rainfall%"-159), 0.36*("%Rainfall%"-285))))
0 Kudos
MarkBoucher
Occasional Contributor III

Jamal,


After some trial and error, I found that you need to enclose the expressions on either side of the "&" with "()"s.  The equestion below worked for me:

Con("Rainfall"<456, 0.3*"Rainfall", Con(("Rainfall">456) & ("Rainfall"<700), 0.46*("Rainfall"-159), 0.36*("Rainfall"-285)))


Also, you had wrapped the second Con() with "()" and I took that out.

You may want to explore the greater or equals to ">=" and less than or equal to "<=" test so your don't miss something that hits values right on.

Hope this helps.
by Anonymous User
Not applicable
Original User: Jamal432@gmail.com

Jamal,


After some trial and error, I found that you need to enclose the expressions on either side of the "&" with "()"s.  The equestion below worked for me:

Con("Rainfall"<456, 0.3*"Rainfall", Con(("Rainfall">456) & ("Rainfall"<700), 0.46*("Rainfall"-159), 0.36*("Rainfall"-285)))


Also, you had wrapped the second Con() with "()" and I took that out.

You may want to explore the greater or equals to ">=" and less than or equal to "<=" test so your don't miss something that hits values right on.

Hope this helps.



Thank you very much for the help Mark. It worked like a charm.

Appreciated

Jamal


[ATTACH=CONFIG]14925[/ATTACH]
0 Kudos