Global Mapper v25.0

Exported PNG map tiles always contain resampling artifacts

Boyd
Boyd Global Mapper UserTrusted User

I have several applications where data is encoded as RGB values in PNG map tiles, so when I export OSM tiles from source TIFF files, it's essential that they are color accurate. However, I'm finding it next to impossible to accomplish this in GlobalMapper 23.

When I export TIFF files, I use No Resampling (Nearest Neighbor) which ensures this kind of problem can't happen. But there is no resampling option in the Export Web Format dialog. I had hoped it would respect the resampling option I set the Export Raster Imagery dialog, but that doesn't seem to be the case.

Here's an example, shown in Photoshop and zoomed 3200% so you can see the individual pixels. The problem only appears in areas of high contrast. For example, in the TIFF file there are pixels with RGB values of (1,139,255) next to pixels with values of (1,140,0). The exported PNG map tiles contain a pixel with RGB values of (1,139,117) between the original pixels. This creates a big problem in my app when decoding RGB values in these tiles.

Is there some workflow that allows creation of PNG map tiles with no resampling (nearest neighbor)? The source TIFF file was created at a resolution of 1.2 meters with Web Mercator projection and the tiles were exported at Level 17. I am NOT using the option to create 8-bit pallete files.


Comments

  • Boyd
    Boyd Global Mapper User Trusted User

    I just tried a new idea and so far it seems to be working but I need to test farther. Anyway, I re-exported my source TIFF file at 1.194328566955879 meters/pixel (this is the the exact resolution of zoom level 17 as defined in the Web Mercator projection I'm using). I think this prevents resampling because the source file is already at the correct resolution for level 17 tiles.

    Would still be nice if there was a way to specify no resampling in the PNG tile export dialog however.

  • Boyd
    Boyd Global Mapper User Trusted User

    Just a follow-up, in case it helps somebody else later. Have spent the past week and a half re-processing my entire US Mid-Atlantic DEM dataset. After crunching 1.7 terabytes of source files into 9 million 256x256 PNG tiles (169 gigabytes) at zoom levels 6 through 17, I can confirm that the technique above works. Re-sampling does not occur (and no artifacts are created) if the resolution of the source file exactly matches the calculated resolution of the zoom level. The resolutions I used for each zoom level are shown at the end of this post. I don't know how many decimal places are actually needed to prevent re-sampling, so I just copied/pasted these full values. Also note that for this to work, you need to create a separate file at the correct resolution and process each zoom level separately instead of letting Globalmapper create a whole series of zoom levels from a single file.

    Here's an example of how I use RGB-encoded elevation in map tiles on my site (it's free with no registration or ads)

    boydsmaps.com/#16.32/41.388337/-73.176463/mbx3dmidatl/-43.80/71.60


    Click the button with the blue cube to export the DEM data to my new 3d terrain viewer for more control over the rendering of the 3d imagery. Both of these apps depend on being able to accurately encode elevation as RGB values in PNG map tiles without any re-sampling artifacts.

    boydsmaps.com/terra/#41.388337/-73.176463/1395/1303/1408/0/74/0/1000/600/-1000/45/3/3d/shader20/0/0/z17

    _________________________________

    zoom meters/pixel

     0   156543.03392804097

     1  78271.51696402048

     2   39135.75848201024

     3   19567.87924100512

     4   9783.93962050256

     5   4891.96981025128

     6   2445.98490512564

     7   1222.99245256282

     8   611.49622628141

     9   305.748113140705

    10   152.8740565703525

    11   76.43702828517625

    12   38.21851414258813

    13   19.109257071294063

    14   9.554628535647032

    15   4.777314267823516

    16   2.388657133911758

    17   1.194328566955879

    18   0.5971642834779395

    19   0.29858214173896974

    20   0.14929107086948487