Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdal_contour: min value unexpected #9705

Closed
pmeems opened this issue Apr 19, 2024 · 3 comments · Fixed by #9710
Closed

gdal_contour: min value unexpected #9705

pmeems opened this issue Apr 19, 2024 · 3 comments · Fixed by #9710
Assignees

Comments

@pmeems
Copy link

pmeems commented Apr 19, 2024

What is the bug?

I have a Surfer grid which I want to convert into polygons using gdal_contour.
The min value of the lowest polygon is 0 which I didn't expect. Since the max value is 107000 I expected the min value to be 101000.
In my next step, I calculate the average of the min and max values, and in this case that average is wrong.

I've attached the Surfer grid.
These are the values of the grid:

Grid Size (X*Y):       113 x 121
NoData Value:          1.70141E+38
Minimum:               107000
Maximum:               133000

Surfer.zip

Steps to reproduce the issue

gdal_contour -p -f "ESRI Shapefile" -fl -97000 -37000 23000 83000 89000 95000 101000 107000 113650 121000 129000 137000 143000 149000 155000 215000 275000 335000 -amin Min -amax Max "Surfer.grd" "tmp3p4f4i.shp"

Versions and provenance

I tried it with GDAL 3.6.3, released 2023/03/07 on Windows and with GDAL 3.8.4, released 2024/02/08 also on Windows

Additional context

I don't have this problem with just this grid file, I experience the issue with all grid-files I convert using gdal_contour.

We now have to manually update the shapefile to fix this. This is a lot of work for us. I think I can free up some budget if needed to fix this issue.

@pmeems
Copy link
Author

pmeems commented May 24, 2024

I haven't tested it with v3.9.0 because it is not yet available at gisinternals.com.
But I did try with the development version of gisinternals.com: GDAL 3.10.0dev-cccb40e39c, released 2024/05/24

@rouault: Should this fix work for that version as well? I assume it does because it has a higher version number.

But in this version it doesn't seems to work. The lowest value is no longer 0 but it is still not the correct value.
The value is now -4294967295 which looks like the lowest possible int.

This time I use these gdal_contour.exe arguments:
-p -f "ESRI Shapefile" -i 20 -amin Min -amax Max "TC.asc" "tmpefbulv.shp"
The result:
image

If needed I can provide some sample data.

@rouault
Copy link
Member

rouault commented May 24, 2024

Should this fix work for that version as well? I

from what I can see, you're not using -fl but -i, so this is a slightly different code path that might require extra adjustment as well. Please re-open a new issue with the gdal_contour command line arguments and the input dataset

@pmeems
Copy link
Author

pmeems commented May 24, 2024

I was working on the new issue: gathering data, describing my steps when I noticed that the lowest value is set to the lowest value when calling first gdalinfo -stats TC.asc. In this case 72.818
Without gathering the stats in v3.8.5 the lowest value is 0 and in v3.10.0 it is -4294967295.

So I will update my workflow and create the statistics before I call gdal_contour, that seems to solve my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants