-
Notifications
You must be signed in to change notification settings - Fork 365
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
Tif won't convert to grd without complaining about xres/yres #8655
Comments
👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. We appreciate that you took the time to contribute! Please make sure you read our Contributing Guide and abide by our Code of Conduct. |
Hi, The real issue here is that The
not |
Hi, thanks for your comment. I think it is an issue with x_inc/y_inc being treated as both single-precision and double-precision floating points and not being reset correctly by grdconvert or grdedit, but the code logic is too dense for me to follow. From using -Vd, it seems that grdconvert tries to reset x_inc/y_inc, but it doesn't seem to stick. And then grdedit -A tries again, but it just goes back to the original single-precision settings for some reason. I may be barking up the wrong tree, but that's what seems to be going on. |
Nope, all computations are carried in double precision. It's just the format printing that shows less decimals. I increased them and now -Vd says
which equal to original (but it was recomputed from the -R limits). The issue is that the -A doesn't even try to fix the |
No, wrong conclusion above. -A computes the right inc but somehow when we run |
So here is what is happening (in grdinfo).
Changes the increments ...
but not the limits so when latter
is triggered. Not sure what to do here other than move that annoying warning up to at least the -V level. @seisman ? EDIT: But basically GMT is right the limits are slightly off such that the increments that were clearly intended to 3 arc sec, are in fact not. That grid also does not announce its nodata-value so ocean and non-California are filled with zeros instead of NaNs. |
Here is my understanding of the issue. The origianl GeoTIFF file is stored in float32. That's why the grid increment of 3 arc second is
Personally, I feel nothing is wrong here. Instead, you may want to use the following command to edit the grid. The new
|
…if it breaks. See issue #8655. The issue is that gmtgrdio_doctor_geo_increments() may change the increments in such a way that a grid with a previous good range as a multiple of inc becomes bad (because only the incs were changed). This PR checks that the _doctor_ works does not break the condition. If it does, do not apply it.
Yes, but that would require to do |
Thanks for the workaround. It seems a bit fragile, like if the file's author changes anything about the file by just a smidge it won't work anymore and I'll have to revise my script, but this will work for now. So thanks. I do think this qualifies as a bug because the behavior is unexpected: 1) grdconvert takes a .tif file that grdinfo thinks is fine and turns it into a .grd file that is no longer compliant, then 2) the recommended solution, grdedit -A, does not fix it. So maybe it is two bugs. Or maybe joa-quim is right and the ERROR message should be downgraded to a WARNING since it doesn't prevent anything from actually working. |
…if it breaks. (#8660) See issue #8655. The issue is that gmtgrdio_doctor_geo_increments() may change the increments in such a way that a grid with a previous good range as a multiple of inc becomes bad (because only the incs were changed). This PR checks that the _doctor_ works does not break the condition. If it does, do not apply it.
Closing as fixed in #8660 |
I download a file from ScienceBase in .tif format, and grdinfo is happy with it, but as soon as I do anything with the file that turns it into a .grd (or .nc), grdinfo (and other GMT processes) throw an error: "grdinfo [ERROR]: (x_max-x_min) must equal (NX + eps) * x_inc), where NX is an integer and |eps| <= 0.0001. [etc.]". The file comes from this page on SB: https://www.sciencebase.gov/catalog/item/5a5fa029e4b06e28e9bfc43a
To get the .tif file do:
You may need to remove the "\" before the "?" depending on your shell.
Now:
is happy, and the numbers look good. But if we do:
Now:
Gives:
Despite the numbers still looking good. Following the instructions in the error message:
Results in the same errors when running
Full error message
Actual outcome
Expected outcome
The grid spacing seems fine for the bounds. I don't think an error is warranted here, but in any event, I don't know how to fix it.
System information
gmt --version
): 6.5.0The text was updated successfully, but these errors were encountered: