<div dir="ltr">Hi all,<br><br>I think the problem described in these tickets can be more serious than just a visualization question:<br><br><a href="https://issues.qgis.org/issues/11974">https://issues.qgis.org/issues/11974</a><br><a href="https://issues.qgis.org/issues/14853">https://issues.qgis.org/issues/14853</a><br><a href="https://issues.qgis.org/issues/14835">https://issues.qgis.org/issues/14835</a><br><br><br>Please try the following workflow.<br><br>1) Download this sample raster:<br><a href="https://cld.pt/dl/download/de81b6ce-38a8-4539-be16-24a3e3ef72d1/perigosidade_int.tif">https://cld.pt/dl/download/de81b6ce-38a8-4539-be16-24a3e3ef72d1/perigosidade_int.tif</a><br><br>2) Running gdalinfo, the output is:<br><br>gdalinfo perigosidade_int.tif<br><br>Driver: GTiff/GeoTIFF<br>Files: perigosidade_int.tif<br>Size is 1039, 1701<br>Coordinate System is:<br>PROJCS["ETRS89 / Portugal TM06",<br>(...)<br>Origin = (73626.458811498901923,145193.972505581419682)<br>Pixel Size = (25.002694985400002,-25.002694985400002)<br>Metadata:<br>  AREA_OR_POINT=Area<br>Image Structure Metadata:<br>  INTERLEAVE=BAND<br>Corner Coordinates:<br>Upper Left  (   73626.459,  145193.973) (  7d15'30.17"W, 40d58'21.05"N)<br>Lower Left  (   73626.459,  102664.388) (  7d15'48.20"W, 40d35'22.48"N)<br>Upper Right (   99604.259,  145193.973) (  6d56'59.28"W, 40d58'11.13"N)<br>Lower Right (   99604.259,  102664.388) (  6d57'23.68"W, 40d35'12.70"N)<br>Center      (   86615.359,  123929.180) (  7d 6'25.36"W, 40d46'47.22"N)<br>Band 1 Block=1039x3 Type=Int16, ColorInterp=Gray<br>  NoData Value=32767<br><br><br>3) Running gdalinfo with stats option, the output is:<br><br>gdalinfo -stats perigosidade_int.tif<br><br>Driver: GTiff/GeoTIFF<br>Files: perigosidade_int.tif<br>Size is 1039, 1701<br>Coordinate System is:<br>PROJCS["ETRS89 / Portugal TM06",<br>(...)<br>Origin = (73626.458811498901923,145193.972505581419682)<br>Pixel Size = (25.002694985400002,-25.002694985400002)<br>Metadata:<br>  AREA_OR_POINT=Area<br>Image Structure Metadata:<br>  INTERLEAVE=BAND<br>Corner Coordinates:<br>Upper Left  (   73626.459,  145193.973) (  7d15'30.17"W, 40d58'21.05"N)<br>Lower Left  (   73626.459,  102664.388) (  7d15'48.20"W, 40d35'22.48"N)<br>Upper Right (   99604.259,  145193.973) (  6d56'59.28"W, 40d58'11.13"N)<br>Lower Right (   99604.259,  102664.388) (  6d57'23.68"W, 40d35'12.70"N)<br>Center      (   86615.359,  123929.180) (  7d 6'25.36"W, 40d46'47.22"N)<br>Band 1 Block=1039x3 Type=Int16, ColorInterp=Gray<br>  Minimum=2.000, Maximum=835.000, Mean=37.025, StdDev=71.526<br>  NoData Value=32767<br>  Metadata:<br>    STATISTICS_MAXIMUM=835<br>    STATISTICS_MEAN=37.024768992184<br>    STATISTICS_MINIMUM=2<br>    STATISTICS_STDDEV=71.52569727799<br>   <br><br>4) gdalinfo creates a XML file with statistics info in the file folder:<br><br><PAMDataset><br>  <PAMRasterBand band="1"><br>    <Metadata><br>      <MDI key="STATISTICS_MAXIMUM">835</MDI><br>      <MDI key="STATISTICS_MEAN">37.024768992184</MDI><br>      <MDI key="STATISTICS_MINIMUM">2</MDI><br>      <MDI key="STATISTICS_STDDEV">71.52569727799</MDI><br>    </Metadata><br>  </PAMRasterBand><br></PAMDataset><br><br><br>5) Then, delete that XML file. <br><br>6) Load the perigosidade_int.tif file in QGIS.<br><br>7) Don't do anything, just remove the raster from QGIS TOC.<br><br>8) If you go to the folder where the raster is stored, QGIS created a new XML file with:<br><br><PAMDataset><br>  <PAMRasterBand band="1"><br>    <Histograms><br>      <HistItem><br>        <HistMin>1.500685871056241</HistMin><br>        <HistMax>730.4993141289438</HistMax><br>        <BucketCount>729</BucketCount><br>        <IncludeOutOfRange>0</IncludeOutOfRange><br>        <Approximate>1</Approximate><br>        <HistCounts>(...)</HistCounts><br>      </HistItem><br>    </Histograms><br>    <Metadata><br>      <MDI key="STATISTICS_MAXIMUM">730</MDI><br>      <MDI key="STATISTICS_MEAN">34.375557670573</MDI><br>      <MDI key="STATISTICS_MINIMUM">2</MDI><br>      <MDI key="STATISTICS_STDDEV">67.853826109685</MDI><br>    </Metadata><br>  </PAMRasterBand><br></PAMDataset><br><br><br>9) So, QGIS marks the STATISTICS_MAXIMUM as 730.<br><br>10) Even defining in Settings -> Options -> Rendering -> Rasters -> Limits (minimum/maximum): Minimum/Maximum<br><br>QGIS always uses 730, because the Accuracy is, by default, "Estimate (faster)", and this option is not configurable at Options, as said in these tickets.<br><br><br>But what is really serious here, is that as soon as the XML file is created, Processing tools uses these statistics for the calculations.<br><br>11) For instance, if run r.quantile with "generate recode rules" flag, the output is:<br><br>2.000000:6.000000:1<br>6.000000:8.000000:2<br>8.000000:12.000000:3<br>12.000000:20.000000:4<br>20.000000:730.000000:5<br><br>12) Classifying the raster based on these rules with r.recode leaves pixels with value 835 as NULL.<br><br>And every subsequent process gives errors.<br><br><br>The question is.. how I never had realized this problem? The fact is that QGIS only generates the XML file when the raster layer is removed from QGIS project. And so, if Processing modules are run using the layers loaded in TOC, there are no problems.<br><br>If these modules are runned from the python console (processing.runalg) or using raster layers that are not loaded in QGIS, the problem show up.<br><br>I'm with QGIS 2.18.22 (OSGeo4W64 bits). <br><br>Thank you very much!<br><br>Best regards,<br>Pedro Venâncio<br></div>