Raster Calculation within Field Calculator

2403
4
Jump to solution
05-10-2017 08:48 PM
CarlosGarcia4
New Contributor

Hello, I've run into a problem involving multiple rasters and using Raster Calculator for a Master's Thesis involving soil erodibility.

I have an NDVI raster, which I've turned into an Int Raster, allowing me to build an attribute table of all the NDVI values within my study area. Now I am able to select by attribute pixel values above and below my threshold values.

I was able to add a field for "Erodibility" of type double, but ran into the problem of actually calculating the field not being able to call upon other rasters.

I literally need nothing from the NDVI raster except the location of the values above/below my threshold, which would be two separate calculations.

I also have 2 other rasters of average precipitation (P) and soil erodibility values (K). I'd like to calculate within the NDVI raster, Erodibility = (P * K) using the selection of my threshold within the Field Calculator or using another method if known, or if I can Raster Calculate using a spatial component.

I have tried changing using Raster to Polygon and doing it, but every time something gets lost or just leads to a dead end.

Any help at all is much appreciated. Defense is coming soon!

0 Kudos
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Also the threshold can be used in a simple Con statement, see: Con—Help | ArcGIS Desktop 

Con(Condition, calculation when true, optional calculation when false)

Example: Con(NDVI <= threshold, P * K)

This will generate a raster that will contain the "Erodibility" when the NDVI have values lower and equal to the threshold, the rest of the cells will have NoData values. 

View solution in original post

4 Replies
DanPatterson_Retired
MVP Emeritus

the ndvi raster can be reclassed to 0 and 1 using your threshold, then your P * K calculation is simply the Times tool in the spatial analyst.  Now multiply that by your binary reclassed ndvi  and you will have P * K and 0 elsewhere.

XanderBakker
Esri Esteemed Contributor

Also the threshold can be used in a simple Con statement, see: Con—Help | ArcGIS Desktop 

Con(Condition, calculation when true, optional calculation when false)

Example: Con(NDVI <= threshold, P * K)

This will generate a raster that will contain the "Erodibility" when the NDVI have values lower and equal to the threshold, the rest of the cells will have NoData values. 

CarlosGarcia4
New Contributor

I had a problem with my reclassify getting errors no matter what I did. The Con (Spatial  Analyst) tool saved the day.

Thank you both for your help! Made everything so much easier!

0 Kudos
DanPatterson_Retired
MVP Emeritus

Carlos... sorry I wasn't clearer about the 'reclassification' step.  Basically if you query a raster for a 'condition' you get True (aka 1) or False (aka 0).  This produces the reclassification for you.  

For future reference, refer to these images.

Now on to querying the grid and producing an 'indicator grid'

Now this can be accomplished in a workflow as xander_bakker has aptly shown by doing it in one step.  You can use the Con tool to query for the condition and return a 1 where the condition is true and 0 otherwise, or return a calculation where a condition is true and something else (ie 0) where it was false.