A bit long report By Claude but confirmed by me that it is true
GMT grdblend: inputs that need reformatting or resampling come back garbled (Windows)
Found 2026-10-08 blending two DGT MDS-2m GeoTIFF tiles (2 m, pixel registered, ETRS89 / PT-TM06):
MDS-2m-196014-04-2024.tiff + MDS-2m-196015-04-2024.tiff, -R-4000/-3000/-287000/-285000 -I2.
Symptoms
| inputs |
output |
nodes with data (should be 445196 / ~446392) |
the two .tiff, -r |
pixel |
140000, all crammed into x -3999..-3721 |
the two .tiff, no -r |
gridline |
135923 |
same grids saved as .nc, -r |
pixel |
445196 (correct) |
same grids saved as .nc, no -r |
gridline |
135923 (wrong: goes through the resample branch) |
| in memory, already on the output lattice |
either |
correct |
Also printed: Failed to remove c:\TMP/grdblend_reformatted_XXXX.nc! [remove error: Permission denied].
Cause (grdblend.c, grdblend_init_blend_job)
- Reformat branch (non-netCDF input -> grdconvert):
gmt_get_tempname(GMT->parent, "grdblend_reformatted", ".nc", buffer) uses ONE fixed template.
With MSVC _mktemp_s returning the same name every time (the comment in the resample branch
says so), every reformatted input is written into the same file: the second overwrites the
first while it is still open (hence the failed delete). The resample branch already works
around this with sprintf(template, "grdblend_resampled_%d", n); the reformat branch does not.
Probable fix: the same per-input template, e.g. "grdblend_reformatted_%d".
- After either branch the re-read grid goes through
grdblend_overlap_check (GMT, &B[n], h, 0) UNCONDITIONALLY. That is the longitude +-360 check
(its earlier calls are guarded by gmt_M_x_is_lon); on a Cartesian/projected grid it "adjusts"
x by 360 (-Vi: "grid region needed longitude adjustment", -Vd: out: -360/140), so only
140 of the tile's 500 columns land on the output. This is the main cause of the wrong output.
MWE (Julia, GMT.jl)
using GMT
a = raw"C:\Users\j\.gmt\DGT\MDS-2m\MDS-2m-196014-04-2024.tiff"
b = raw"C:\Users\j\.gmt\DGT\MDS-2m\MDS-2m-196015-04-2024.tiff"
R = grdblend("\"$a\" \"$b\""; R="-4000/-3000/-287000/-285000", I=2, r=true)
count(!isnan, R.z) # 140000, expected 445196
A bit long report By Claude but confirmed by me that it is true
GMT grdblend: inputs that need reformatting or resampling come back garbled (Windows)
Found 2026-10-08 blending two DGT MDS-2m GeoTIFF tiles (2 m, pixel registered, ETRS89 / PT-TM06):
MDS-2m-196014-04-2024.tiff+MDS-2m-196015-04-2024.tiff,-R-4000/-3000/-287000/-285000 -I2.Symptoms
-r-r-r-rAlso printed:
Failed to remove c:\TMP/grdblend_reformatted_XXXX.nc! [remove error: Permission denied].Cause (grdblend.c, grdblend_init_blend_job)
gmt_get_tempname(GMT->parent, "grdblend_reformatted", ".nc", buffer)uses ONE fixed template.With MSVC
_mktemp_sreturning the same name every time (the comment in the resample branchsays so), every reformatted input is written into the same file: the second overwrites the
first while it is still open (hence the failed delete). The resample branch already works
around this with
sprintf(template, "grdblend_resampled_%d", n); the reformat branch does not.Probable fix: the same per-input template, e.g.
"grdblend_reformatted_%d".grdblend_overlap_check (GMT, &B[n], h, 0)UNCONDITIONALLY. That is the longitude +-360 check(its earlier calls are guarded by
gmt_M_x_is_lon); on a Cartesian/projected grid it "adjusts"x by 360 (
-Vi: "grid region needed longitude adjustment",-Vd:out: -360/140), so only140 of the tile's 500 columns land on the output. This is the main cause of the wrong output.
MWE (Julia, GMT.jl)