Skip to main content
3 of 4
added 99 characters in body

Max and Min value from an ascii grid

I'm working in Qgis with python console. I have a file .asc whose structure is:

Ncols 49

Nrows 52

Xllcorner 2611187.75

Yllcorner 4336914.199

Cellsize 1000

NODATA_value -9999

0.5081 0.679 -9999 ...

I have to find the Max and the Min value in the file and I tried:

GridFile = open('filepath \ file.asc', 'r')
MaxValue = max (GridFile)
MinValue = min (GridFile)

But the procedure returns the following error

ValueError: max () is an empty sequence
ValueError: min () is an empty sequence

What I understand is that I have to skip the first 6 lines and find the maximum and the minimum of successive values, but I do not know how to do it.