0

How can I get two different raster layers in ArcMap, that have exact the same edge?

I tried clipping or extract by mask but the output looks exactly like the input.

I only want to have these values that have a cell in the other raster.

In other words: I have a red and a black raster. In the first image I want to get rid of the black cells of the underlying raster. In the second image I want to get rid of the red cells of the underlying raster.

enter image description here

enter image description here

  • this may help?: gis.stackexchange.com/questions/221979/… – pdavis Jan 1 at 14:36
  • thanks for the link, but this doesn't help :) I want to get rid of the raster cells of one raster, that kind of "overlap" the other raster. Like the cells you see at the edge in the screenshots above. both pictures describe two rasters that are on top of each other. in the first picture the red is on top of the black raster in the second picture the black is on top of the red raster. In the first picutre I want to delete the black cells and in the second picture I want to delete the 6 red cells. – Enzo Baldini Jan 1 at 15:50
  • Not sure number of rasters you are dealing with, but could you convert the rasters to vector, make edits manually and then reconvert to raster (which have same properties as original rasters, of course)? – jbrengel Jan 1 at 17:45
  • Also, if the cells of interest have easily distinguishable pixel values versus the other pixels in rasters, maybe try reclassify cells values to NoData? – jbrengel Jan 1 at 17:46
  • I am dealing with 4 rasters. I thought about converting each raster to vextor polygons, dissolve these, intersect all 4 vector-layers and this will give my a clip-feature. I could use that to clip all 4 raster-layers. I will try that. But I guess there must be a simpler solution or I am overlooking something. Your second option will not work, because the pixels of the rasters are not easily distinguishable. – Enzo Baldini Jan 1 at 19:05
1

Have you thought about working with NoData values? If they are not properly labelled already, you could assign the white cells to the raster mask. That can be achieved for example by using the Copy Raster tool to modify the NoData Value.

You could also use the Raster Calculator to create a Mask raster using operations like AND/OR (something like "raster1 == 255" | "raster2 == 255" assuming that white = 255 in your screenshots)

Once you have this sorted you should be able to perform an Extract By Mask using the new raster with NoData values as a mask.

Edited solution after the additional information provided in the comment:

SetNull((IsNull("raster1") | IsNull("raster2")) == 1, "raster1"), then SetNull((IsNull("raster1") | IsNull("raster2")) == 1, "raster2") using the Raster Calculator tool should do the trick

  • Hi Alessio, thanks for your post! All the white space are already NoData values. In both raster layers. – Enzo Baldini Jan 2 at 21:29
  • I suggest then to run Raster Calculator with a function like this SetNull((IsNull("raster1") | IsNull("raster2")) == 1, "raster1"). This will generate a raster where pixels will have a value of 1 if any of the two input raster pixels is NoData. We can then use that intermediate raster with the SetNull function to assign a new comprehensive mask to raster1. You can then rerun this function changing the last "raster1" to "raster2" to perform the same operation on the second raster. This method requires the SpatialAnalyst license – Alessio Arena Jan 2 at 22:37
  • This is the reference for the SetNull operation pro.arcgis.com/en/pro-app/tool-reference/spatial-analyst/… – Alessio Arena Jan 2 at 22:48
  • so I could ask in the raster calculator to turn the values of the black raster to NoData, where the red raster has already a NoData value. And the same thing vice versa. right? – Enzo Baldini Jan 2 at 23:52
  • this part (IsNull("raster1") | IsNull("raster2")) uses a OR logic operator. Basically checks if pixel value in raster1 is NoData OR pixel value in raster2 is NoData, and returns a 1 if that is the case. So it should be able to merge both masks in one go, merging black pixels of your first screenshot, white ones and red pixels of your second screenshot. You then apply that mask using the SetNull operator – Alessio Arena Jan 3 at 0:49

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.