3

I am using ArcGIS Desktop 10.1.

I have one raster layer that is a site suitability layer for a county. Then I have two feature classes (one for roads and one for hydrology) that I need to remove or just set to Null from the site suitability raster. This is because the site suitability is for producing crops which obviously can't grow in water or on roads.

I have converted each feature class to a raster, but now I can't figure out how to get rid of the roads and water from the site suitability layer. I've tried a few things with the Raster Calculator and Set Null tools but I haven't had any luck. I'm probably doing something wrong because each time I end up with a result that is just whatever feature I am trying to remove from the site suitability layer.

12

First, you should make sure your roads and hydrology feature classes are being rasterized appropriately. You should make sure that the cell size and snap raster (i.e. pixel registration) matches your suitability layer. If you don't, the rasterized roads and hydrology could have much larger cells than intended or be misaligned, leading to undesirable results. Set the snap raster and cell size environment variables in Feature to Raster, as shown below.

setting environment variables


Second is the part you were asking about: setting cells in suitability layers as null where the rasterized road (red) and hydrology (blue) layers have non-null values, as shown below.

input data

The easiest way to accomplish this is using Raster Calculator. The Map Algebra expression we want to use is SetNull(~IsNull("hydro.tif")|~IsNull("roads.tif"),"suitability"). Let's break this down step by step.

  • The SetNull tool requires two raster layers in the simplest usage. The first is a conditional raster, where cells not equal to zero (equivalent to boolean TRUE) should be set null. The second is the false raster, representing the desired output cell values where the conditional raster is equal to zero (equivalent to boolean FALSE).

  • We want the conditional raster (parameter 1) to be TRUE if either the roads or hydrology have non-null values and FALSE everywhere else. The OR operation is handled by a | (a vertical bar or pipe, the key right below backspace). To find non-null values, we can take the inverse (or boolean NOT) of the null values, which are found using the IsNull tool. To do the boolean NOT in raster calculator we use a tilde ~. Combining it all: ~IsNull("hydro.tif")|~IsNull("roads.tif").

  • We want the false raster to be our suitability layer, which you can pass in as-is.

final parameters

Here's the output, with the hydro and roads rasters correctly set null:

output

  • Great response, thanks for all of the detail! This worked perfectly AND I understand how. – ge0m3try May 3 '14 at 19:42
  • I just noticed now that some of the corners of the new raster resulting from the raster calculator have been cut off. These areas are present in the site suitability layer before the raster calculator operation and do not have roads/hydrology overlapping them. The corners are cut off on a perfect line. Any idea what might be causing this? – ge0m3try May 3 '14 at 19:57
  • @Markus Two ideas. First, try setting the "Extent" environment variable of Raster Calculator to be the suitability layer. Second, try making sure that all of your layers are in the same projected coordinate system. – dmahr May 3 '14 at 20:07
  • 1
    @Markus It looks like the processing is being limited to the extent of the roads_raster layer. Try rasterizing your roads again with the "Extent" environment variable set to the suitability layer (along with the correct snap raster and cell size) so it's the full extent. – dmahr May 3 '14 at 21:19
  • 1
    Good answer, like the description of what the operands ~ | mean. I would have probably approached a solution entirely within model builder as personally I'm not a big fan of the minimalist raster calculator approach. Got me looking at the help file and found this page about the various operators, seemed relevant to the answer. – Hornbydd May 4 '14 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.