Fill Missing Grid Data

I’ve obtained terrain data from the remote dataset earth relief. However the area of interest contains an artifact anomaly. I have removed the anomalous heights with NaN values. My code and graphics are below. What module do I use to replace the NaN values with interpolated values? I don’t want to modify the remaining valid heights at all.

gmt begin Artifact png
gmt makecpt -Cjet -T4000/5000
  gmt subplot begin 2x1 -Ff20c/20c -B+n
    :: Image 1 - SRTM data with Artifact
    gmt subplot set 0,0
    gmt grdview @earth_relief_03s.grd -R137:11:00/137:11:48/-4:05:24/-4:04:36 -JM -p330/30 -Qs -JZ10c
    gmt grd2xyz @earth_relief_03s.grd > artifact-03s.csv
    :: @pause
    :: Manually replace Artifact heights with NaN and save as 'artifact-removed-03s.csv'

    :: Image 2 - SRTM data with Artifact Removed
    gmt subplot set 1,0
    gmt xyz2grd artifact-removed-03s.csv -Gartifact-removed-03s.grd -I03s
    gmt grdview artifact-removed-03s.grd -JM -p330/30 -Qs -JZ10c
  gmt subplot end
gmt end show

Hi Wally

I never done it but I think you should try grdfill.

Thanks Esteban, that’s exactly what I was after. I’m a little embarrassed as I had been looking in all the wrong places. Thanks for pointing me in the right direction.

For the benefit of anyone else that might be going down the same path, here’s what the two options (nearest neighbor and bicubic spline) look like:

Code:

gmt begin artifact png
gmt makecpt -Cjet -T3700/5000
  gmt subplot begin 2x2 -A+jLB+o4c/4c -M1c -Ff20c/20c -B+n
    :: Image 1 - SRTM data with Artifact
	gmt subplot set 0,0 -AArtifact
    gmt grdview @earth_relief_03s.grd -R137:11:00/137:11:48/-4:05:24/-4:04:36 -JM -p330/45 -Qs -JZ10c

	:: Image 2 - SRTM data with Artifact Removed
	gmt subplot set 1,0 -ARemoved
	gmt grdview artifact-removed-03s.grd -JM -p330/45 -Qs -JZ10c

    :: Image 3 - SRTM data with Artifact Replaced (Nearest Neighbor)
	gmt subplot set 0,1 -A"Nearest Neighbor"
	gmt grdfill artifact-removed-03s.grd -An -Gartifact-replaced-nn-03s.grd
	gmt grdview artifact-replaced-nn-03s.grd -JM -p330/45 -Qs -JZ10c

    :: Image 4 - SRTM data with Artifact Replaced (Bicubic Spline)
	gmt subplot set 1,1 -A"Bicubic Spline"
    gmt grdfill artifact-removed-03s.grd -As -Gartifact-replaced-bs-03s.grd
	gmt grdview artifact-replaced-bs-03s.grd -JM -p330/45 -Qs -JZ10c
  gmt subplot end
gmt end show