I have a categorical land classes grid I’d like to color and then apply some hill shading based on @earth_relief_15s DEM. So far my experimentation always ended up distorted with the colored image offset to the hill shading.
Until I used grdimage -JQ. Now it seems to register properly. However this is also a projection and as far as I understand it this recalculates the grid and I therefore loose some resolution.
What would be the proper way to prepare a categorical grid for draping?
My current command: gmt grdimage -JQ60c -R0/40/20/60+r de_discclass.grd -Cland_class_colors.cpt -nn+a -png de9
-JQ is just lon-lat and no projection actually takes place. All other projection requires resampling from the lon/lat equidistant grid onto the projected equidistant x-y grid.
Yes, I was just thinking in terms of the data. Your nx by ny geo grid, if plotted with JQ is still nx by ny. The size is affected by the JQsize, but in a PDF this is just a zoom (in effect). But yes, once png and actual pixel resolutions enter then you get mx by my pixels and they may be larger or smaller than nx,ny, giving interpolation or averaging.
where the plot width of -G and the output image is identical. So only minor problems there. But I plan on recycle my “colored grid” and that’s why I’m keen on keeping it full resolution.
Please bear with me @pwessel I have the feeling I don’t get it. You said there is no loss in -JQ. I agree as long as I don’t convert it into some bitmap image. But as I understand it I can only feed grids/images to grdview -G. So no vector formats and therefore loss in resolution if not perfectly matched.
There might be a chance we talk past each other so I try again:
I have a categorical GeoTIFF with a given size 20160 x 20160 px. I want to replace every pixels grey value with a color from a categorical CPT. No interpolation or similar. Basically make a colorized image from the grey-scale GeoTIFF.
As the resulting image appears somewhat flat I want to add some hill shading. Here I use the colorized image to drape it over some illuminated DEM.
My problem is the first step: How do I switch the pixels from their grey value to some kind of colored pixel without changing the resolution or interpolating the pixels when I need a grid/image for further processing?
Again, thank you for your patience with me @pwessel
Perhaps grdimage -A is what you need: Read the geotiff as a grid and use the z-values with your CPT to create a color image you can write directly via -A. No plotting. You may be able to write it as a new geotiff if you specify the correct driver, I think (@Joaquim knows best) on that).
OK, to start with I don’t understand this point.What is changing the resolution? Selecting an image size is already setting a resolution.
Now, you have a Geotiff image with classes that you want to paint. Fine, that is known as an indexed image to which you attribute colors via a color table. Next, that image is a bit boring and you want to give it some salt. Also fine. Compute a shade with grdgradient of a DTM that you also seem to have and use it as argument of -I in grdimage (if they don’t have de same size, ask help to grdsample)
Maybe it does (I’m not sure, even though the docs say that) but I think it will be ignored because it’s the internal image array that will be saved as a geotiff and not a rasterization of a PS fig.
Thank you @pwessel, thank you @Joaquim for your perseverance in explaining this to me. It works explained.
I feel the documentation is a bit ambiguous there. Do you think that warrants a bit more explanation in the man page or maybe even some expanded explanation in the cookbook?