Matthew's Map Projection Software![]() Here are some C++ programs I wrote a little while ago for generating basic map projections. It all currently runs on Unix only, though could probably be ported to Windows without too much trouble (it will compile and run with the cygwin tools though). Use of the ImageMagick tools (available for Windows and Unix) is highly recommended. Interface is command line only; of course a little TCL front end would be nice. You will also need some suitable image files to work with. Space Graphics have some excellent examples, which can be freely downloaded for non-commercial use (clearly they are very nice people at Space Graphics).
Images need to be converted to .ppm format, this is easily done using
the ImageMagick mogrify -format ppm earth.jpg converts earth.jpg to earth.ppm.
PPM is a simple uncompressed format (which is why we use it), but the
images can take up a lot of disk space. Space Graphics' excellent e43 shaded map
for example, is a little over 100M as a PPM file (compared to about 5M as a JPEG).
Smaller images (and images of Mars) are available from there.
The software uses
P6 First line of header is format identifier, followed by size in pixels and color depth, followed by packed data bytes, 3 bytes per pixel for as long as it takes. To unpack and build the relevant executables:
$ tar xvzf mmps.tgz Additionally: make ppms
converts any .jpg images in the If compilation has gone smoothly, make test will try an example projection, displaying the result with the ImageMagickdisplay utility. The test
target assumes there is file called earth.ppm in your
images subdirectory.
make startest tests the starmap projection feature.
General options for Stars and ProjectCurrently MMPS supports the following projections, specified as a command line parameter:
Most of the maths for the projection is home grown, so I may well have got some things wrong. The Bonne equations, as well as some other things, are taken from the splendid MathWorld site, so are more likely to be correct. Mathworld is an excellent source of general information about map projections and all kinds of other wonderful stuff. Other general parameters:
ProjectUsage: project [-bg r:g:b][-w n][-h n][-adjust] [-f filename][-out filename][-back filename] [-tilt x][-turn x][-lat x][-long x] [-scale x][-x x][-y x][-z x][-ox x][-oy x][-oz x] [-a x][-date x][-time x][-p x][-aw x] [-conic x][-conicr x][-xoff x][-yoff x][-sun] [-grid][-gridx x][-gridy y][-gridcolor r:g:b] latlong|equalarea|sinusoidal|sinusoidal2| mollweide|mercator|azimuthal|rectilinear| orthographic|stereographic|gnomonic| perspective|bonne <infile> Using the data in the image specified by the -f option (or images/earth.ppm if no file specified), generate a projected image in PPM format and write to standard output. Not all options are covered here.
Latitude and longitude of the central point of the map are specified
with the
Examplesproject equalarea -p 45 -adjust -grid | display Equal area cylindrical projection. Reference parallel at 45 degrees. Adjust image size so as to fit. This is the so-called Peters projection. project gnomonic -scale 2 -lat 50 -long -50 -grid | display Gnomonic projection, centred on North Atlantic. Note how projection turns great circles in to straight lines. Perspective
The
Oblateness may be changed with the project perspective -lat 40 -long 30 -x 8 -sun -date 88 -time 3.83 -oz 0.8 | display Inverse mapping
In order to generate a lat-long map from a projected image or photograph,
the project -i <options> -f <file1> > <file2>
which should project the image in project <options> -f <file2> > <file1> (apart from rounding errors and the incompleteness of some projections). See Generating maps from images with MMPS and Generating maps from images with MMPS, Part II for further details. StarsUsage: stars [-bg r:g:b][-w n][-h n][-adjust] [-f filename][-out filename][-back filename] [-year x][-magfact x][-topmag x][-bv][-bvfact x] [-tilt x][-turn x][-dec x][-ra x] [-scale x][-x x][-y x][-z x] [-a x][-date x][-time x][-p x][-aw x] [-conic x][-conicr x][-xoff x][-yoff x] [-grid][-gridx x][-gridy y][-gridcolor r:g:b] latlong|equalarea|sinusoidal|sinusoidal2| mollweide|mercator|azimuthal|rectilinear| orthographic|stereographic|gnomonic| perspective|bonne Using the data in the starlist on standard input, generate a projection image in PPM format and write to standard output. Not all options are covered here.
The
The program reads the starlist from standard input, so we can do, for example:
to just display the stars in Orion.
A slightly naff attempt to show star colour based on
the BV value can be switched on with the The codeThe code implements both forward and backwards projection - the former for drawing grid lines and stars, the latter for projecting maps. The marvellous comments in the code might provide some help as to how it all works. Key files are:
Legal stuffUsual disclaimers; you'll be lucky if this software doesn't make your hard disk explode etc. GPL applies. I wrote this stuff for fun and will be happy if anyone finds it useful. Needless to say, commercial use without permission will be frowned upon, but to be honest I'm unlikely to actually do anything about it (and maybe secretly flattered). |