[PyTopo for Linux]

pytopo: Topographic Maps for Linux

PyTopo is a Python-gtk script which interprets local tiled map data (for instance, from a Topo! data CD), and displays it in an interactive viewer, where you can scroll to adjacent maps, switch between resolutions, or produce a map image for printing or editing.

Why does PyTopo exist? There were several existing Linux mapping applications which take data from online web sites or roads databases, and others which take GPS data and correlate it with online maps. But I typically need maps when I'm travelling and don't have net access! I couldn't find any apps that would display data for any location, without requiring a GPS, using local map sources with no net connection needed. (There are a few possibilities but nothing that really solves the problem: GPSdrive claims it can do local mapping now, but I've tried three versions with no luck getting it to run at all. And there's a neat little program called TangoGPS that can download and show OSM maps, but it has a difficult interface that's optimized for cellphones.)

Download: The current version is PyTopo 0.8.

0.8 had lots of changes -- including changes, I'm sorry to say, to the configuration file where you define your collections. I wrote up some Release notes for 0.8 and have updated the Pytopo file formats page to reflect the new syntax.

Using PyTopo

Begin by creating a file named .pytopo in your home directory, in which you define a list of named coordinates, and specify some other parameters such as location of the map data and preferred window size. Read the comments at the beginning of the pytopo script for samples of the .pytopo file.

Key bindings

Left, Right,
Up, Down
Scroll the map in the indicated direction.
+/=, - Zoom in to the 7.5 minute series, or out to the 15 minute series. (Zooming isn't supported in other map formats yet.)
s Save the current map to a file under $HOME/Topo
Space Print (to standard output) the current coordinates of map center.

Clicking in the map displays the coordinates of where you clicked, as well as the distance and bearing from the last clicked point.

Usage (commandline arguments)

Usage: pytopo [-t trackfile] site_name
       pytopo [-t trackfile] start_lat start_long collection
       pytopo -p
Use degrees.decimal_minutes format for coordinates.
Set up site names in ~/.pytopo
Print list of known sites with pytopo -p

Track files may contain track points and/or waypoints;
multiple track files are allowed.

Bugs/Wishlist

I'm working on a new OSMMapCollection format that uses tiles downloaded from OpenStreetMap.org (for instance, by TangoGPS); this code is included in PyTopo 0.8 but is not yet stable nor documented, so if you use it you'll certainly see some bugs. I didn't want to hold 0.8 just for that, so expect better OSM support in PyTopo 0.9.

Track logs (a new feature in 0.8) are also not fully working: they may be off by a bit, if the coordinate system ("datum") your GPS is using differs from the datum of your maps (which is likely, especially with Topo!) data. I'm working on fixing that properly -- darnit, that may require yet another format change since MapCollections may need to specify that -- but the fix probably won't come until 0.9.

Getting Map Data

PyTopo assumes that you already have maps locally, on disk or CD, in a supported image format, named according to the Topo! naming conventions. (PyTopo 0.5 adds support for other naming conventions as well.)

The Topo! local area and specific park map packages sold in camping/hiking stores (sometimes under the aegis of National Geographic) are reasonably priced as a source of map data. They come with Windows software, but Linux users can ignore the software and use the data files, which are standard GIF, named in a fairly straightforward way. They're a good source of US map data.

Caution: the Topo! Back Roads Explorer and the statewide explorer collections are not in this friendly format. They use large data files in a proprietary ".tpq" format. Tom Trebisky has analyzed the format and has written an extractor, and he also has a C GTK viewer for this format. (Eventually I hope to integrate direct support for them into pytopo as well.)

Just to be clear: I am not distributing map data.

Making Your Own Map Collections

You can buy map bits directly from the USGS, but they have a hefty setup fee so it's not cost effective unless you're buying quite a lot.

For some areas, you can download topo maps; for instance, for California you can get maps in TIFF format from the California Spatial Information Library. You still have to split up the maps into maplets, though; if you have ImageMagick, you can use a command like

convert in-map.jpg -rotate 90 -crop 300x300 -repage +0+0 out-map%02d.jpg

Note: previously I included -trim as part of that line, and a lot of pages you'll find googling for image splitting will tell you to use -trim. Don't: it will give you maps of inconsistent sizes, and pytopo has no way to tell where the origin of the map should be.

A map split this way can be read with PyTopo 0.5 or later. Maps downloaded as PDF (such as USGS geologic maps) might work in imagemagick, but if not, try converting them to a raster format before splitting, using a program like GIMP or a command like

gs -sDEVICE=jpeg -r300 -sOutputFile=output-map.jpg input-map.pdf

Non-interactive mapping scripts

I wrote some older commandline helper scripts, but honestly, I don't use them myself and don't vouch for them. I list them here merely on the chance that someone might find one of them a useful building block:

Is it Only For Linux?

PyTopo should run fine on any system which has Python, gtk, gdk-pixbuf, and PyGTK. If it doesn't work, please let me know.

Coming Soon

(Stuff I want that should be easy to implement or is already in progress.)

Wishlist

(Stuff that would be nifty, but is either difficult, or requires additional map data that I'd have to pay for. If you want something on this list, bribing me with interesting map data would be an excellent approach.)

Change Log

0.8, June 20, 2009
Support track/waypoint files;
support worldwide coordinates by using negative longitudes when west of the prime meridian;
complete codebase refactor -- cleaner, more generalizable, more OO code;
base class for implementing new tiled map collections;
some associated MapCollection file format changes;
accept config file in .config/pytopo as well as ~/.pytopo
; introduce new (still buggy and undocumented) OSMMapCollection.
0.7, September 10, 2008
Add -c to find the center of a collection;
fix a bug when latitude or longitude is less than 10°.
0.6, October 12, 2007
Fix bad memory leak (will run much better on small-memory machines now).
Integrate Tom Trebisky's Topo2 format.
0.5, August 21, 2006
Formal 0.5 release: Fix a bug when specifying long/lat on the command line.
0.5b2, June 2, 2006
Fix "save as". Fix latitude reported when clicking.
0.5b1, April 16, 2006
Read more general map formats. Display to arbitrarily sized windows. Bug fixes. Code refactoring.
0.4, April 17, 2005
Calculate distance and bearing between clicks; assorted bug fixes.
0.3, April 13, 2005
Add 's' binding to save current map to a file (using montage from ImageMagick).
Better fix for expose handling.
0.2, April 8, 2005 Temporary fix for spurious expose problem (excessive CPU usage).
0.1, April 5, 2005
Coordinate handling routines mostly working. Store coordinates of center, not edge, so zoom works.

Ellie: Plot GPS elevation profiles
More Software
Shallowsky Home
mail me