Opened 18 years ago
Last modified 18 years ago
#1071 closed defect (fixed)
ASCII Grids round minimum and maximum if first cell value is integer
Reported by: | Owned by: | Mateusz Łoskot | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | GDAL_Raster | Version: | unspecified |
Severity: | normal | Keywords: | VERIFIED |
Cc: | Markus Neteler |
Description
Hi there, With ASCII grids, if the first cell value is an integer or a nodata value, then the minimum and maximum will be rounded. I put together a very simple Windows C++ example to demonstrate this bug, which may be downloaded here: Full project: http://dl.happysquirrel.com/temporary/ASCMinMaxExample.zip Binaries only: http://dl.happysquirrel.com/temporary/ASCMinMaxBug-BinariesOnly.zip In the zip file are two ascii grids of interest - "good.asc" and "bad.asc". They are identical except that the first cell value in "good.asc" has been replaced with 4.6 to illustrate that the first cell value is the determining factor. Example output: C:\dev\MinMaxExample\Debug>MinMaxExample.exe bad.asc Min: 4.000000 Max: 4.000000 C:\dev\MinMaxExample\Debug>MinMaxExample.exe good.asc Min: 4.600000 Max: 4.899000 Thank you! PS... I believe this is with GDAL 1.3.1 if memory serves.
Change History (4)
comment:2 by , 18 years ago
Mateusz, This has been a long standing problem with the ascii grid reader. On the one hand, I don't want to have to scan the whole grid file on open just to find if there are some floating point values "way down" in the file. This would be quite destructive to performance for some applications. On the other hand, the current logic is constantly causing problems for people. I get this sort of bug report at least once per month. Most of the time, the problem is that there are large chunks of "nodata" at the beginning, and that hides the real floating point data. So I think one improvement would be to scan through the data till at least the first value that isn't no-data is encountered. Another approach would be to give up on my hesitancy to scan the whole file, but to try and do the pre-scan as efficiently as possible. Load the data in substantial chunks (100K at a time perhaps) and use strchr() to look for a period. Ensure we stop scanning when we encounter a period of course. On reflection, I think we had better use the second method (scan the whole file efficiently) and be done with the issue.
comment:3 by , 18 years ago
This bug has been fixed already. Appropriate changes are available in CVS. Chris, Could you test if your MinMaxExample works with those changes?
Note:
See TracTickets
for help on using tickets.