Segmentation Fault in grdfill

Hello everyone, I am having trouble replacing Nan’s in a grid with 0:

region=-85/-68/-47.5/7

gmt begin

gmt grdfill slip_cut_23.grd -Ac0 -Gslip23.grd -R${region}

gmt end

I obtained segmentation fault (core dumped), the only case I could avoid the error reducing the region, but I need it for the region in the variable.

here is the grdinfo on the grid:

slip_cut_23.grd: Title: Produced by grdcut
slip_cut_23.grd: Command: grdcut slip.grd -Gslip_cut_23.grd -Fpoligono.txt -R-85/-68/-47.5/7 -Ve
slip_cut_23.grd: Remark:
slip_cut_23.grd: Gridline node registration used [Cartesian grid]
slip_cut_23.grd: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7
slip_cut_23.grd: x_min: -85 x_max: -68 x_inc: 0.05 name: x n_columns: 341
slip_cut_23.grd: y_min: -47.5 y_max: 7 y_inc: 0.05 name: y n_rows: 1091
slip_cut_23.grd: v_min: 0 v_max: 0.991496264935 name: z
slip_cut_23.grd: scale_factor: 1 add_offset: 0
slip_cut_23.grd: format: netCDF-4 chunk_size: 171,137 shuffle: on deflation_level: 3

Regards

No need for a script, just do

  • gmt grdfill slip_cut_23.grd -Ac0 -Gslip23.grd -R-85/-68/-47.5/7
  • Why setting a -R that is equal to grid limits? Does it still crash if you don’t use -R?

Anyway, nothing we can check without a reproducible example. Need that grid, or preferably a smaller one.

Hello, thanks for your answer:

  • Without -R still crashes with a segmentation fault
  • It doesn’t need to be in the borders, I just wanted to maintain a variable throughout the script (this is just a test to try to perform the procedure on a large scale later). Anyway, I tried with -R-84/-70/-46.5/6 and there is still a segmentation fault.

Here are the files
fill.zip (5.6 KB)

Regards and thanks again

I think you hit grdfill fails, probably in situation where holes extend to the edge of the grid domain · Issue #7736 · GenericMappingTools/gmt · GitHub

I think you can get what you want with grdmath AND operator and a second grid B filled with zeros.

Thank you very much! That was the solution and the explanation of my problem. Just in case I used this to fill the NaN with 0’s in a grid with borders containing only NaNs, it works.

gmt grdmath slip_cut_23.grd 0 DENAN = slip23.grd

Best Regards