I have two raster files of the same resolution: raster A and raster B. Raster A is the bigger raster and raster B covers some parts of raster A. I want to extract those grids from Raster A which are not covered by raster B.

I usually do using extract by mask but this time, it is the other way round. Can anyone tell me how can I do this.

  • if the cell size of both rasters are the same, you can use map algebra. Do they have the same cell size? – yanes Dec 1 '15 at 18:06
  • Yes the cell size is the same. What do I need to type in the map algebra? – 89_Simple Dec 1 '15 at 18:13
  • 1
    Con(isnull (b),a) – FelixIP Dec 1 '15 at 18:24
  • I went ahead and gave a 2-step answer, which I deleted now as @FelixIP's answer is the most straight forward. Only thing I add is that you go to the environmental setting and make the processing extent set to the bigger raster. ( the default is set to the union of all, but sometimes some functions do not work if you don't explicitly set the processing extent- especially while batch processing) – yanes Dec 1 '15 at 18:34
  • 1
    @yanes no time sorry. Do you mind to pull compile the answer. I'd say setting up extent 1st is important. 2nd step use raster calculator expression "b", 3rd is from my comment, but use output of step 2 – FelixIP Dec 1 '15 at 21:42

Step 1 : set the processing extent. Open Raster calculator go to the environment tab and set the processing extent equivalent to the bigger raster. Then use one of the following options.

OPTION 1 [taken from user FelixIP's comments] Con(isnull (RasterB),RasterA) This answer assumes that raster A is bigger than raster b, as stated by OP. I believe this is the most straight forward answer so I've put mine as option 2 below. I'd go with this option.

OPTION 2 This is assuming both your rasters contain only positive integers. if that is not the case and they include 0 change > into >=, if they both include signed integers use the minimum of the rasters in each case.

Con(((rasterA > 0) & (raster B >0)), -9999, rasterA) Let's say you named the output for the above as RasterC

Open a new raster calculator and use SetNull to set all the values where rasterB overlapped with RasterA to Null (in the above operation they were set to -9999)

SetNull(RasterC, RasterC, "Value = -9999) <- Output RasterD

Your RasterD should have all the areas covered by Raster A but not Raster B. If you don't mind the -9999 value you can stop at Raster C.

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.