Select to view content in your preferred language

Make raster-clipping work, or keep "Extract by Mask" from altering raster-cell values. (Pro 3.1.2)

1587
7
Jump to solution
07-25-2023 01:53 PM
JohnBranum
New Contributor III

Hi All.  Super sorry this is so long, but it's complex stuff.

I'm trying to clip a 48-MB, 1-band raster.  I started with Toolboxes' "Clip Raster" tool but gave-up after waiting half a day.  Checking this forum, it was suggested to instead "Extract by Mask", which actually worked, and quickly, but upon close examination, it appears to have reevaluated and modified the resulting raster's cell values.  Below, you'll see where all values have been elevated/lightened.

Original raster - group of cells:

JohnBranum_0-1690312860933.png

JohnBranum_5-1690315932731.png

Extracted raster - same group of cells:

JohnBranum_1-1690312883662.png

JohnBranum_4-1690315894140.png

Both rasters above still claim a single-band value range of 0-81, but the Extracted raster appears to have "overexposed" the data, lightening all its values and eliminating its highest.  My guess is that the process clips out the unwanted cells, then reevaluates what remains, redistributing the value spectrum across the new-raster cells.  The Raster Information tables throw all sorts of red flags too, namely, Columns, Rows, Size, Pixel Type and Depth, NoData Value, and Pyramids, so it seems evident that Extract by Mask might not work here, since most of these parameters are not editable in the tool's Environments.

Alternatively, via Pro's tabs, the Analysis > Clip tool (Analysis > Raster > Raster Functions > System > Data Management > Clip) offers even fewer parameter adjustments.

This leads me to believe that the Geoprocessing > Clip Raster tool (Geoprocessing > Toolboxes > Data Management Tools > Raster > Raster Processing > Clip Raster), which does allow adjustment of many of the Raster Information parameters, is the only way to clip without losing data (assuming that IS what's actually happening).

So my questions are:

  1. Is there a way Extract by Mask can work without altering the original cell values?  If not,
  2. Will Geoprocessing > Clip Raster tool eventually work if i let it spin long enough?  If so,
  3. Is there an adjustable parameter that will retain the original raster-cell values?

 

1 Solution

Accepted Solutions
Luke_Pinner
MVP Regular Contributor

Really the only way you might get the pixel values actually changing is if the output coordinate system  is different and the raster gets resampled when it is reprojected. 

View solution in original post

0 Kudos
7 Replies
Luke_Pinner
MVP Regular Contributor

Can't reproduce. Extract by Mask maintains cell values,

For example - using Identify to show cell values at the same point in both original large raster and the extracted raster:

Luke_Pinner_1-1690344145279.png

Of course your extent, n. rows/columns and min/max cell statistics will change, because you clipped/extracted out a smaller area.   But the actual cell values remain the same. 

The rasters/cells may even look different in the map but the values themselves have not changed. This is simply because the symbology will have changed (as the statistics are different).  You can make them look the same by changing the symbology.

Luke_Pinner_2-1690344389872.png

 

0 Kudos
Luke_Pinner
MVP Regular Contributor

Also, as your raster cells appear rotated in the screenshots, it looks like you are trying to run the clip in a different projection than the raster is in which is probably why it's taking so long.  Change your map /tool environments spatial reference system to match that of the original raster.

JohnBranum
New Contributor III

Thanks Luke.  For me, the most important bit of your reply is where you say the cell values have not changed.  Can you explain/confirm this?  I almost never work with rasters (hence my struggle here) and am not sure how to compare one raster's cell value to that of another.  In all my tests, what appears to happen is that the clipping process reevaluates the clipped raster, reassigning values from min to max, which will change those values if, for example, the removed portions were higher and/or lower values than what remains.

0 Kudos
Luke_Pinner
MVP Regular Contributor


You can manually check by subtracting one from the other.  You'll get all zero values where they overlap.

Luke_Pinner
MVP Regular Contributor

@JohnBranum wrote:

In all my tests, what appears to happen is that the clipping process reevaluates the clipped raster, reassigning values from min to max, which will change those values if, for example, the removed portions were higher and/or lower values than what remains.


I think what you are referring to there is what happens to the symbology which is just a visual representation. It doesn't change the underlying values though.

Luke_Pinner
MVP Regular Contributor

Really the only way you might get the pixel values actually changing is if the output coordinate system  is different and the raster gets resampled when it is reprojected. 

0 Kudos
JohnBranum
New Contributor III

That's great, Luke.  That's what i needed to know.  Much appreciated!

0 Kudos