Matthew's Map Projection SoftwareHere 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, an excellent source is the Flat Planet project or NASA.
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.
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 or pull from https://github.com/matthewarcus/mmps.git 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 test2 tests other features and the starmap projection feature.
General options for Stars and ProjectCurrently MMPS supports the following projections, specified as a command line parameter:
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][-rotate][-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 Not all options are covered here.
Latitude and longitude of the central point of the map are specified
with the
See Sundials with MMPS for details about drawing sundials with MMPS. 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 168 -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. 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. |