Skip to main content
Bounty Ended with 50 reputation awarded by Nathan
Errata. Correction to Figure 4's captions.
Source Link
Ralph Tee
  • 1.8k
  • 13
  • 17

Figure 4Figure 4

Figure 4

Figure 4

More clarification. Improvement of answer.
Source Link
Ralph Tee
  • 1.8k
  • 13
  • 17
// Assuming Zoom_In and/or Zoom_Out is not Nearest_Neighbour.

if toUseRatio < 1.0 or toUseRatio near 1.0 then
    resamplerToUse = interpolation specified in Zoom_In
else if toUseRatio > 1.0 then
    resamplerToUse = interpolation specified in Zoom_Out
else 
    resamplerToUse = Nearest Neighbour

Next, QGIS decides between (the interpolation method specified in) Zoom In and Zoom Out using the above logic. The resulting "idiosyncrasy" is that Zoom In can be chosen over Zoom Out when User "zooms out" past the layer's native pixel resolution.

let resWidth  = map view's width * toUseRatio,
let resHeight = map view's height * toUseRatio,

let InpImg = Block(raster layer, map view's extent, resWidth, resHeight),
let OutImg = scale InpImg to map view's width and height using chosen interpolation methodresamplerToUse.

And last - the image copying/scaling operation. If toUseRatio is "big", so will resWidth and resHeight, and this directly results in InpImg having more pixels across and down. InpImg is then scaled down (or up) to fit the map view's screen width and height.

let resWidth  = map view's width * toUseRatio,
let resHeight = map view's height * toUseRatio,

let InpImg = Block(raster layer, map view's extent, resWidth, resHeight),
let OutImg = scale InpImg to map view's width and height using chosen interpolation method.

If toUseRatio is "big", so will resWidth and resHeight, and this directly results in InpImg having more pixels across and down. InpImg is then scaled down (or up) to fit the map view's screen width and height.

// Assuming Zoom_In and/or Zoom_Out is not Nearest_Neighbour.

if toUseRatio < 1.0 or toUseRatio near 1.0 then
    resamplerToUse = interpolation specified in Zoom_In
else if toUseRatio > 1.0 then
    resamplerToUse = interpolation specified in Zoom_Out
else 
    resamplerToUse = Nearest Neighbour

Next, QGIS decides between (the interpolation method specified in) Zoom In and Zoom Out using the above logic. The resulting "idiosyncrasy" is that Zoom In can be chosen over Zoom Out when User "zooms out" past the layer's native pixel resolution.

let resWidth  = map view's width * toUseRatio,
let resHeight = map view's height * toUseRatio,

let InpImg = Block(raster layer, map view's extent, resWidth, resHeight),
let OutImg = scale InpImg to map view's width and height using resamplerToUse.

And last - the image copying/scaling operation. If toUseRatio is "big", so will resWidth and resHeight, and this directly results in InpImg having more pixels across and down. InpImg is then scaled down (or up) to fit the map view's screen width and height.

Clarify further
Source Link
Ralph Tee
  • 1.8k
  • 13
  • 17

Edited answer (11-SEP-2018)

The following answers and descriptions are based on QGIS 3.2. They will not touch on interpolation methods since the questioner is already familiar with them.

ThisGenerally, this setting kicks in when User "zooms in" (i.e., towards ground) past the raster layer's native pixel resolution. Please see the figure below for the effect. The(Be sure to keep the Oversampling value at 1.0 or higher. The default is not used here2.0.)

A more accurate description: ThisSpecifically - this setting kicks inwas meant to take effect when the map view's pixel resolution is larger than the raster layer's original (i.e., file) pixel resolution.

ThisGenerally, this setting kicks in when User "zooms out" (i.e., away from ground) past the raster layer's native pixel resolution. Please see the figure below for the effect. If the selection is Average,(Be sure to keep the Oversampling value at higher than 1.0. The default is used2.0.)

A more accurate description: ThisSpecifically - this setting kicks in thenwas meant to take effect when the map view's pixel resolution is smaller than the raster layer's original (i.e., file) pixel resolution.

The Average method is actually a bilinear interpolation that accepts a parameter (i.e. Under most situations, via the Oversampling value). Under most situation, the's default value of 2.0 gives "best" visual result vis-a-vis performance. LargerFor large orthophoto raster, larger Oversample values may workgive better for orthophoto rasters withvisual results especially if the raster has many white spots (e.g., due to light reflections off cars, rooftops, water bodies, poor-quality map production, combinations of thosethe aforementioned, and etc.). But larger Oversample values also increase rendering duration, and may not necessarily produce better result. Different raster orthophotos give different visual results - so do experiment with different Oversampling values.

MiscThe Oversampling Value

BothThe actual application and effect of Zoom InOversampling can be explained from the QGIS source codes reduced/simplified to the following steps:

let pixelRatio = map view's pixres / raster layer's pixres,
let toUseRatio = min(pixelRatio, Oversampling),

toUseRatio is the smaller of pixelRatio and Zoom OutOversampling does not apply when. Thus, Oversampling is a misnomer, and it should aptly be labeled "Maximum Pixel Ratio" instead.

let resWidth  = map view's width * toUseRatio,
let resHeight = map view's height * toUseRatio,

let InpImg = Block(raster layer, map view's extent, resWidth, resHeight),
let OutImg = scale InpImg to map view's width and height using chosen interpolation method.

If toUseRatio is "big", so will resWidth and resHeight, and this directly results in InpImg having more pixels across and down. InpImg is then scaled down (or up) to fit the map view's pixel resolution equals the layer's original pixel resolution, i.escreen width and height.

If InpImg has more pixels (across and down) than the map view, when User right-clicks onthen a selected layerscale down will occur, and choosethe result will be "good". Conversely, if Zoom to Native Resolution (100%)InpImg has less pixels (across and down) than the map view, then a scale up will occur, and the result will be poor. (See the figure below.)

Figure 4

The following answers and descriptions are based on QGIS 3.2. They will not touch on interpolation methods since the questioner is already familiar with them.

This setting kicks in when User "zooms in" (i.e., towards ground) past the raster layer's native resolution. Please see the figure below for the effect. The Oversampling value is not used here.

A more accurate description: This setting kicks in when the map view's pixel resolution is larger than the layer's original (i.e., file) pixel resolution.

This setting kicks in when User "zooms out" (i.e., away from ground) past the raster layer's native resolution. Please see the figure below for the effect. If the selection is Average, the Oversampling value is used.

A more accurate description: This setting kicks in then the map view's pixel resolution is smaller than the layer's original (i.e., file) pixel resolution.

The Average method is actually a bilinear interpolation that accepts a parameter (i.e., via the Oversampling value). Under most situation, the default value 2.0 gives "best" result vis-a-vis performance. Larger values may work better for orthophoto rasters with many white spots (e.g., due to light reflections off rooftops, water bodies, poor-quality map production, combinations of those, and etc.). But larger values also increase rendering duration, and may not necessarily produce better result.

Misc

Both Zoom In and Zoom Out does not apply when the map view's pixel resolution equals the layer's original pixel resolution, i.e., when User right-clicks on a selected layer and choose Zoom to Native Resolution (100%)

Edited answer (11-SEP-2018)

The following answers and descriptions are based on QGIS 3.2. They will not touch on interpolation methods since the questioner is already familiar with them.

Generally, this setting kicks in when User "zooms in" (i.e., towards ground) past the raster layer's native pixel resolution. Please see the figure below for the effect. (Be sure to keep the Oversampling value at 1.0 or higher. The default is 2.0.)

Specifically - this setting was meant to take effect when the map view's pixel resolution is larger than the raster layer's original (i.e., file) pixel resolution.

Generally, this setting kicks in when User "zooms out" (i.e., away from ground) past the raster layer's native pixel resolution. Please see the figure below for the effect. (Be sure to keep the Oversampling value at higher than 1.0. The default is 2.0.)

Specifically - this setting was meant to take effect when the map view's pixel resolution is smaller than the raster layer's original (i.e., file) pixel resolution.

The Average method is actually a bilinear interpolation. Under most situations, Oversampling's default value of 2.0 gives "best" visual result vis-a-vis performance. For large orthophoto raster, larger Oversample values may give better visual results especially if the raster has many white spots (e.g., due to light reflections off cars, rooftops, water bodies, poor-quality map production, combinations of the aforementioned, and etc.). But larger Oversample values also increase rendering duration, and may not necessarily produce better result. Different raster orthophotos give different visual results - so do experiment with different Oversampling values.

The Oversampling Value

The actual application and effect of Oversampling can be explained from the QGIS source codes reduced/simplified to the following steps:

let pixelRatio = map view's pixres / raster layer's pixres,
let toUseRatio = min(pixelRatio, Oversampling),

toUseRatio is the smaller of pixelRatio and Oversampling. Thus, Oversampling is a misnomer, and it should aptly be labeled "Maximum Pixel Ratio" instead.

let resWidth  = map view's width * toUseRatio,
let resHeight = map view's height * toUseRatio,

let InpImg = Block(raster layer, map view's extent, resWidth, resHeight),
let OutImg = scale InpImg to map view's width and height using chosen interpolation method.

If toUseRatio is "big", so will resWidth and resHeight, and this directly results in InpImg having more pixels across and down. InpImg is then scaled down (or up) to fit the map view's screen width and height.

If InpImg has more pixels (across and down) than the map view, then a scale down will occur, and the result will be "good". Conversely, if InpImg has less pixels (across and down) than the map view, then a scale up will occur, and the result will be poor. (See the figure below.)

Figure 4

Source Link
Ralph Tee
  • 1.8k
  • 13
  • 17
Loading