Trouble with shading a grd file on dem.grd using grdimage


I have applied GMTSAR to compute LOS displacement of 2017, Iran Earthquake. In the next step, I want to shade los_ll.grd on dem.grd. To that end, I have written the following code in GMT 5.4.5 on ubuntu 16.04:

gmt psbasemap -R$file -JM3i -Bx0.5 -By0.5 -P -K -Xc -Yc >
gmt makecpt -Cgray -T-4500/4500/30 -Z -D > dem.cpt
gmt grdsample dem.grd -Gtmp_dem.grd
gmt grdgradient tmp_dem.grd -Nt0.75 -A180 -Gdem_grad.grd
gmt grdimage tmp_dem.grd -Cdem.cpt -Idem_grad.grd -R -J -P -O -K >>
gmt makecpt -Crainbow -T-400/950/1 -Z -I -D > los.cpt
gmt grdimage los_ll.grd -Clos.cpt -Idem_grad.grd -R -J -O -Q -K >>

but, when I run the code, the following error is appeared:

grdimage: Warning: Region exceeds grid domain. Region reduced to grid domain.
grdimage: Dimensions of intensity grid do not match that of the data grid!

grdinfo outputs for loss_ll.grd and dem_grad.grd are as follows:

dem_grad.grd: Title: Produced by grdgradient
dem_grad.grd: Command: grdgradient tmp_dem.grd -Nt0.75 -A180 -Gdem_grad.grd
dem_grad.grd: Remark: Normalized directional derivative(s)
dem_grad.grd: Gridline node registration used [Geographic grid]
dem_grad.grd: Grid file format: nf = GMT netCDF format (32-bit float), COARDS, CF-1.5
dem_grad.grd: x_min: 43 x_max: 47 x_inc: 0.000277777777778 name: longitude [degrees_east] n_columns: 14401
dem_grad.grd: y_min: 33 y_max: 36 y_inc: 0.000277777777778 name: latitude [degrees_north] n_rows: 10801
dem_grad.grd: z_min: -0.734872996807 at x = 46.5433333333 y = 34.9094444444 z_max: 0.732431054115 at x = 46.625 y = 33.5391666667
dem_grad.grd: scale_factor: 1 add_offset: 0
dem_grad.grd: median: -0.00853219069541 scale: 0.148482937239
dem_grad.grd: mean: 0.00147948539584 stdev: 0.24351903751 rms: 0.243523531047
dem_grad.grd: format: netCDF-4 chunk_size: 129,129 shuffle: on deflation_level:  3

los_ll.grd: Title: 2017302_2017326 LOS displacement
los_ll.grd: Command: grdmath unwrap_mask_ll.grd 0.0554658 MUL -79.58 MUL = los_ll.grd
los_ll.grd: Remark: equals negative range
los_ll.grd: Pixel node registration used [Geographic grid]
los_ll.grd: Grid file format: nf = GMT netCDF format (32-bit float), COARDS, CF-1.5
los_ll.grd: x_min: 45.2777777778 x_max: 46.4555555556 x_inc: 0.000555555555556 
 name: longitude [degrees_east] n_columns: 2120
los_ll.grd: y_min: 33.8374999993 y_max: 35.4708333326 y_inc: 0.000416666666658 name: latitude [degrees_north] 
n_rows: 3920
los_ll.grd: z_min: -123.42099762 at x = 45.7675 y = 35.027291666 z_max:  952.179626465 at x = 45.7641666667 y = 34.623541666
los_ll.grd: scale_factor: 1 add_offset: 0
los_ll.grd: 2494202 nodes (30.0%) set to NaN
los_ll.grd: median: 65.484413147 scale: 50.0097091873
los_ll.grd: mean: 117.159161734 stdev: 153.107845189 rms: 192.790760695
los_ll.grd: format: classic

I would greatly appreciate if you could help me to fix the error.

Like the error message says, los_ll.grd and dem_grad.grd have (very) different sizes and resolutions. I cannot work like that. You must resample los_ll.grd to fit dem_grad.grd (or the other way around to avoid aliasing).

Also, your second grdimage call would completely overlap the first call.