Repository navigation
Better auto-resolution selection for grids and images - #5887
Conversation
maxrjones
left a comment
There was a problem hiding this comment.
Nice. Probably can remove the commented print statement before merging.
|
Forgot to remote the printf of course, will do in next PR. |
|
Question. Now GMT can calculate a proper dpi for the output raster? |
|
I think so, it is better than it was earlier. Using the height and latitude range is more stable. But it is a relatively new feature so we may learn more as we use it more. Let me know if you run into anything. |
|
I just wonder if it could be used for grdview -Qi. The default value is 100 dpi. |
|
Oh, I see. Given there is now GMT_GRAPHICS_DPU [300i] perhaps that should be the default . Is that what you meant? |
|
Mmm, I think yes. |
|
Thinking about this some more. There is a difference:
In fact, if you were to make a 3-D grdview plot of @earth_relief then the grid resolution we compute is probably only approximately correct, and then -Qi comes along. So I am not sure, but -Qi100 default was set a decade or more ago when we felt it took "too long" to rasterize. Maybe @joa-quim have any thoughts on this? |
Description of proposed changes
I have been tinkering with how to determine a suitable remote grid image resolution that would work well with all projections. My initial attempts (in master) examined both longitude and diagonal degree range for a map. However, longitudes are difficult as the longitude range can suddenly jump from a small range to 360 if a pole enters the region. So this PR only considers the latitude range (Y) relative to the map height (H). Then, the required number of grid nodes per degree is computed via
N_f = L * dpi / D,where dpi is the desired dots-per-inch needed. We then use the next higher actual N_r of the nearest grid resolution. I am testing this with a zoom from 100,000 km altitude to 10 km altitude over a fixed point (Vienna). The movie script isThe movie can be seen on YouTube. Via debug dump I have captured both N_f and N_r and for this wide range of altitudes it looks like this:
As you can see, the selected grid resolution (blue) is always equal or higher than the required, until we run out of even higher resolutions after 1 arc second around 25 km altitude. Please view the movie and see how it transitions between resolutions. Since the data sets are not always exactly the same you will notice the jumps to the better data but it is pretty good I think. Remember that making a movie with variable resolution like this is the most extreme case of this. Static plots will not experience this of course.
Given the stability that using Y brings to computing the required nodes per degree, I recommend you approve this PR.