1

I've finally been able to get two rasters with the same pixel size and perfect overlap (resample + snap raster). Now I need them to have the same extent, giving the value of "-9999" in pixels not present and eliminating those that are out of the raster used as a template.

As you see in the image what I need is to fit the "light green layer" to the "dark green layer".

enter image description here

1

You question is somewhat unclear, because in this context extent usually refers to the minimum bounding box of the raster. It sounds like you might want the same coverage.

If you want the same extent, you need to use a tool from the toolbox: Data Management Tools > Raster > Raster Processing > Clip. Your input raster will be the light green layer and your output extent will be the dark green layer. The result will be a version of the light green layer cropped to the smallest rectangle that contains all the dark green pixels. There will still be light green values in places there are no dark green values.

If you want the same coverage, or only those light green pixels that fall under dark green pixels, you need a Spatial Analyst extension license and the tool called Spatial Analyst tools > Extraction > Extract by Mask. Again, light green as the input, dark green as the feature mask. The result will be a raster that has both the same extent as the dark green layer, as well as only light green pixels where there are dark green pixels. Whether this works or not may depend on your specific rasters and what the actual values of the white/clear cells are.

There are also other ways to do this second operation, including the Con tool and Raster Calculator using a Con function. You also may need to use the Raster Calcualtor to set your specifically desired "-9999" null value to what are likely to be null/nodata cells in your results.

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.