Giter Club home page Giter Club logo

Comments (4)

vincentsarago avatar vincentsarago commented on May 24, 2024

@IAGO1215 without reproducible example nor data nor screenshots it's pretty hard for use to tell what's going on. I can simply make a guess that your data is a COG with internal overview and in QGIS it's the overview that you are seeing

from rasterio.

IAGO1215 avatar IAGO1215 commented on May 24, 2024

Dear Sarago,

I have uploaded the raster I am using here. (200MB)

As for the reproducible example:
First, we can open the raster in QGIS, and check the "Information" tab where we can find the max, mean, min... of each band.
Then we can read the first band by rasterio in VSCode. And check the max, mean, min... They should be identical to those shown in QGIS.
a = rio.open('Band') a = a.read(1).reshape(-1) a = a[~np.isnan(a)] a.max()

from rasterio.

vincentsarago avatar vincentsarago commented on May 24, 2024

With GDAL

GDAL_DISABLE_READDIR_ON_OPEN=FALSE gdalinfo OutputPCA_30_PCs -stats -json | jq '.bands[0]'
{
  "band": 1,
  "block": [
    1137,
    1
  ],
  "type": "Float32",
  "colorInterpretation": "Undefined",
  "description": "PC 1",
  "minimum": -71.904,
  "maximum": 42.271,
  "mean": 0.001,
  "stdDev": 12.35,
  "metadata": {
    "": {
      "STATISTICS_MAXIMUM": "42.271053314209",
      "STATISTICS_MEAN": "0.0011011385352394",
      "STATISTICS_MINIMUM": "-71.90389251709",
      "STATISTICS_STDDEV": "12.349624688556",
      "STATISTICS_VALID_PERCENT": "8.865"
    }
  }
}

With Rasterio

with rasterio.Env(GDAL_DISABLE_READDIR_ON_OPEN=False):
    with rasterio.open("OutputPCA_30_PCs") as src:
        arr = src.read(indexes=1)
        non_nan = arr[numpy.isfinite(arr)]
        print(non_nan.min(), non_nan.max())

-71.90389 42.271053

In QGIS

Screenshot 2023-12-13 at 4 11 11 PM

from rasterio.

IAGO1215 avatar IAGO1215 commented on May 24, 2024

Dear Sarago,

thanks for the prompt reply and the issue has been fixed, and it is not even related to rasterio, which shows the correct max/min values of the raster.

Instead the issue is related to the settings in QGIS on my side. To fix it, I have set "Accuracy" from "Estimate" to "Actual" (as shown in your screenshot), and now it is showing correctly in QGIS as well.

Thanks again for the help.

Best

from rasterio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.