-
Notifications
You must be signed in to change notification settings - Fork 360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
image shading problem for tiled earth relief data? #3694
Comments
Wow, strange. Well ,good that it is not in the data files I guess. Running grdgradient manually and passing the file works. So something with passing @file to grdgradient via GMT_Call_Module. |
Just an update. This only applies to tiled data sets. The 06m and larger do not have this problem. |
And of course has nothing to do with modern mode. A plain
yields the same problem. |
Some more experimentation.:
Conclusions:
Yet, will need to see if there is any difference in the two calls to gmt_grd_project. |
Slowly making progress on understanding this but not out of the woods. Can @seisman and @joa-quim try the same command but turning off anti-aliasing? That gives a good result for me but need to verify before I dig into the why (since it works find with a single file or without shading...)
|
Yes, this command gives me the correct plot. |
OK, so I will try to see what is different with the default anti-aliasing when input was tiles versus not, since this has always worked just fine for all cases. Those curved lines has a spacing that is proportional to the grid spacing, are projection dependent, and only appear when auto-shading is on and main file is a tile.... |
Same error for pixel or gridline tiles, BTW. |
Basically, these are the two steps that grid projection takes:
The -n+a controls this. Default is to do 1 + 2. +a turns off step 1 and only relies on step 2. The reason we do all this is that step 2 is great if we in effect are interpolating, but would alias if the projected input points are denser than the output points. Step 1 deals with that by averaging (filtering), and then at the end we blend. The result may vary continuously across the map depending on projection, and has worked will for GMT always. |
Something related to central meridian and range: This shows the error (even -JN179/20c shows a little bit):
This one has no issues:
Have a look at this one:
You can see the lines with land-colored pixels around lon = 60 must be coming from the lat around long = -60. WHy this only happens in bands is the mystery since clearly most pixel end up looking OK. |
Looks similar to issue GenericMappingTools/pygmt#515. |
Was that with tiled data or full-grid data? |
It's 01d full-grid data, but is passed to GMT as an xarray. |
I hacked grdimage to write out the number of projected points that fall into each rectangular bin (step 1 above - the blockmean) and then made a plot of it. I did this for tiles and the single 5m pixel grid. The plots are identical so only plosting one here: Read the cpt as green: 0 hits (outside area), 1, 2, up to 6 max. The pattern reflects the curved paths seen in the final image. However, the final image, which combines the block-meaned points with interpolated points, looks fine for the single grid. So will try to visualize step 2. |
Most of the image is blue (1 hit) with the dominant lines from before being red (2 hits). Step 2 code says this:
So, for the blue and red areas this means:
As n goes up the z_in is given less and less weight. E.g., if 5 points inside the sum then the z_int weight is 1/5 vs 5. The idea behind this was to avoid aliasing by favoring the sum if there were many points ( here meaning lots of 5m gridlines going through the same projected node, so splining the lon/lat grid at this point would badly alias the solution), whereas at the other end (no hits) all we do is spline and that is fine. But none of this has changed in years and it has worked fine, except for the tiles. Clearly, the red and blue nodes above give very different results to the point it stands out with the DEM cpt. |
Another observation is that towards the far north, where the red pixels dominate over the blue, you can see shadows of the features offset. E.g., Greenland is plotted twice, as is every other feature. Greenland is plotted were it is (fuzzy) but also over/north of Norway. So the bins computed from Step 1 are the wrong bins since the equatorial regions, mostly blue in the hits, are mostly from Step 2, and that maps looks mostly good. This is why with -n+a it looks good since that bypasses step 1. I will debug step 1 with tiles and with single grid and presumably I will learn something. I think I am getting closer. |
Above I am referring to features in the main plot, not the hitmap. |
Pretty sure it is because the assembly of the tiles passes in region as 0/360 but the plot is -60/300, and that is the ghost shift etc we are seeing. Jeez... |
Think I have a solution now. Just running tests but works for the example herein. Also think it points to a solution for the pyGMT case. |
This addresses issue #3694. The problem turned out to be this: grdimage usually reads in a grid in two steps:
Remind me (again), passes as GMT_VIA_MATRIX and REFERENCE or DUPLICATE? |
|
FYI, #3799 doesn't fix GenericMappingTools/pygmt#515. |
This addresses issue #3694. The problem turned out to be this: grdimage usually reads in a grid in two steps:
No, it can't, but I know why. More tomorrow. |
…ge (#3799) (#3803) This addresses issue #3694. Co-authored-by: Paul Wessel <[email protected]>
The issue was fixed in #3799. Closing. |
Plotting a global earth relief map using the following command:
It looks good at first glance, but after zooming in, I saw a lot of weird curves:
I don't see these curves for
@earth_relief_06m
orearth_relief_05m
without shading.The text was updated successfully, but these errors were encountered: