LinuxCommandLibrary

pnmmercator

Convert image to or from Mercator projection

TLDR

Convert a rectangular projection worldmap to Mercator projection

$ pnmmercator [path/to/image.pnm] > [path/to/output.pnm]
copy

Convert a Mercator projection worldmap to rectangular projection
$ pnmmercator [[-i|-inverse]] [path/to/image.pnm] > [path/to/output.pnm]
copy

SYNOPSIS

pnmmercator [-width=cols] [-height=rows] [-gray|-color] [pnmfile]

PARAMETERS

-width=cols
    Specifies the width of the output image in columns. If not specified, the width of the input image is used.

-height=rows
    Specifies the height of the output image in rows. If not specified, the height of the input image is used.

-gray
    Forces the output to be a PGM (grayscale) image, even if the input is a PPM (color) image. The color components of the input are averaged to produce the grayscale values.

-color
    Forces the output to be a PPM (color) image, even if the input is a PGM (grayscale) image. If the input is grayscale, the same gray value is used for all color components in the output.

pnmfile
    The input PNM file. If not specified, the standard input is used.

DESCRIPTION

The pnmmercator command converts a portable anymap (PNM) image representing a sphere's surface to a Mercator projection. It takes a PNM image as input and produces another PNM image as output, where the input's longitude maps linearly to the output's x-axis and the input's latitude maps linearly to the output's y-axis.

This transformation is useful for displaying spherical textures or data on a flat, rectangular surface, although it introduces distortion, particularly near the poles. The poles are stretched infinitely in the Mercator projection. The command is typically used for creating world maps or other visualizations where a cylindrical projection is desired.

NOTES

The Mercator projection inevitably distorts the original image, especially near the poles of the sphere. Consider the visual impact of these distortions when using the command.

This tool is part of the Netpbm suite, which provides a variety of image manipulation tools.

EXAMPLE

To convert a PNM image named 'sphere.pnm' to a Mercator projection with a width of 800 columns, producing the output on standard output, use:
pnmmercator -width=800 sphere.pnm

SEE ALSO

pnm(5), ppmtops(1)

Copied to clipboard