Bug report #9400

"Clip raster by mask layer" produces different results than "Clipper" from Raster Menu

Added by Filipe Dias about 10 years ago. Updated almost 8 years ago.

Status:Closed
Priority:Normal
Assignee:Alexander Bruy
Category:Processing/GDAL
Affected QGIS version:2.4.0 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:17998

Description

I tried clipping a raster with "Clipper" from the Raster Menu and "Clip with mask layer" from the Processing Toolbox and obtained different results

The outputs of both functions had:

- different raster statistics (Layer properties ->Metadata->Band 1)

- handled no "NoDataValues" differently. While Clipper kept "NoDataValue" undefined, Clip with mask layer assigned "0" as NoDataValue, even though I set "none" in Nodata value

Am I missing something? I attached test data to reproduce the issue

clip.zip (182 KB) Filipe Dias, 2014-01-22 02:57 AM

History

#1 Updated by Filipe Dias about 10 years ago

SAGA 2.10/"Clip grid with polygon" produced a raster with the same statistics as the output from "clip raster with mask layer" and assigned -32767 as NoDataValue

#2 Updated by Giovanni Manghi about 10 years ago

  • Status changed from Open to Closed

The different stats are explained because all the pixels that have 0 value are evidently counted in the stats (that does not happens for NO DATA).

If you need to have NO DATA in the output from the tool in the raster menu then you must check the "no data value" option (and set it to 0).

#3 Updated by Filipe Dias about 10 years ago

  • Status changed from Closed to Reopened

Giovanni Manghi wrote:

The different stats are explained because all the pixels that have 0 value are evidently counted in the stats (that does not happens for NO DATA).

You're right

But one issue remains: if the original raster doesn't have a NoDataValue, then the tool in the processing toolbox automatically assigns it to 0. The function "clipper" does not do this.

#4 Updated by Giovanni Manghi about 10 years ago

Filipe Dias wrote:

Giovanni Manghi wrote:

The different stats are explained because all the pixels that have 0 value are evidently counted in the stats (that does not happens for NO DATA).

You're right

But one issue remains: if the original raster doesn't have a NoDataValue, then the tool in the processing toolbox automatically assigns it to 0. The function "clipper" does not do this.

to me makes much more sense that the areas outside the clipped area are NO DATA rather than 0. So in this sense the processing tool acts better by default than the tool in th vector menu, that has the option unchecked.

#5 Updated by Filipe Dias about 10 years ago

There is that. But maybe the tool in the Raster Menu was designed that way because of some use case?

Anyway, it's important that both tools behave the same way.

#6 Updated by Giovanni Manghi over 9 years ago

  • Project changed from 78 to QGIS Application
  • Crashes QGIS or corrupts data set to No
  • Affected QGIS version set to 2.4.0
  • Category deleted (58)

#7 Updated by Giovanni Manghi over 9 years ago

  • Category set to Processing/GDAL

#8 Updated by Alexander Bruy almost 8 years ago

  • Status changed from Reopened to Closed

Works fine in master. There is a minor difference in statistics cause by the fact that Processing tool aligns the coordinates of the extent of the output file to the values of the resolution ("-tap" option).

Please reopen if necessary.

Also available in: Atom PDF