1° gridded data on projected map

Hi,
I have a netcdf file with 1° gridded data which I want to plot with grdimage. Now I would like to use a projected map (polar stereographic for Greenland), but the grid cells do not align along the projected parallels. I know I could increase the interpolation via the -E option, but I want the grid cells to be still visible. How can I do this?
So far I have:
gmt grdimage -JS-45.0/90/10c -R-57.0/59.0/8/79r -Ccolors.cpt input.nc
which produces the attached map:


Thank you in advance for any help!
Eva

Hi,

I’m confused with what is asked. What do you mean with grid cells do not align along the projected parallels. ? Any supporting fig to helps us figure that?

If you want the lines to be aligned with the data, you can use some -B option to plot the gridlines at 70.xxx°N instead of 70 for example.

If you want to align the data with the 70°N parallel for example, that’s altering your data.

Ok, I will try to explain my problem again and the unnice solution I found so far:
I have gridded data in my netcdf file, 1° resolution. But this means, that the value corresponding, let’s say, to the grid point 50°W,70°N is representing the grid cell from 49.5-50.5°W 69.5-70.5°N. If using the Plate Carre projection (-Jq/Q), this is plotted correctly, but for the polar stereographic projection, the “lines” between the grid cells are parallel to the map frame but not to longitudes and latitudes.
My solution so far: using cdo to remap the grid to a higher resolution via nearest neighbour and then plot. It does more or less what I want with only small artefacts.
Code for the attached figure:

cdo -s remapnn,global_0.05 temp_gis.nc temp_gis2.nc
gmt begin comp_greenland 
gmt subplot begin 1x3 -Fs7c -M0.7c/0.5c 
gmt subplot set 0,0
gmt grdimage -JS-45.0/90/7c -R-57.0/59.0/8/79r -Ccolors_gis.cpt  temp_gis.nc -Ba10f5g5
gmt coast -JS-45.0/90/7c -R-57.0/59.0/8/79r -A1000+ag -Di -W0.5,0 		

gmt subplot set 0,1
gmt grdimage -JQ7c -R-57.0/-20/59.0/85 -Ccolors_gis.cpt temp_gis.nc -Ba10f5g5
gmt coast -JQ7c -R-57.0/-20/59.0/85 -A1000+ag -Di -W0.5,0

gmt subplot set 0,2
gmt grdimage -JS-45.0/90/7c -R-57.0/59.0/8/79r -Ccolors_gis.cpt temp_gis2.nc -Ba10f5g5
gmt coast -JS-45.0/90/7c -R-57.0/59.0/8/79r -A1000+ag -Di -W0.5,0 
gmt subplot end	
gmt end show

Any better idea how to solve this?
Best, Eva

Sorry, but I am not sure if I understand well your issue. But are you sure that you want to interpolate with nearest neighbour?

I think grdproject is what you’re looking for.
Also, is your data gridline or pixel node registered (grdinfo)?

I am really sorry to ask again. But what would I need to do with grdproject?
I tried

scale="1:20000000"
gmt grdproject temp_gis.nc -Gtemp_gis2.nc -Js-45.0/90/$scale -R-60.0/0/50.0/85 -I -D0.05 -nn -rp

Is this correct? But then how can I plot this? With both
gmt grdimage -JS-45.0/90/7c -R-57.0/59.0/8/79r -Clajolla temp_gis2.nc
and
gmt grdimage temp_gis2.nc -Jx$scale -Clajolla (what I usually use for polar stereographic grids)
I just get rubbish plots…

Confess that I still don’t get what you want to do, but that is not how (in most cases) one use grdproject. Scale should be “1:1” and from top of my head I think you must also use -F -C or use a -J<proj4 string> instead that greatly simplify things.

Yesterday, I found out that at least part of the problem is my GMT configuration. A colleague tested my code on his computer, and it did exactly what I wanted (outline of the grid cell along projected lines of lat and long). According to him, this is standard GMT behaviour with grdimage. So, I have no idea why my GMT is not doing this. I give up :frowning: Thank you very much for trying to help me

Do you both have the same GMT version?

Yes, 6.3 on Ubuntu

Maybe a config file in the home directory ? But it’s weird, it should not affect the data itself… I guess I’m somehow confused and not sure to get the root of your problem…

I think @Eva has the same problem I had back in December 2022. Have a look at the thread Basic understanding grdimage & -JL projection. If this describes your problem then maybe you want to use grdview -T.

1 Like