OSMViz 1.0

Retrieve and use OpenStreetMap images

  Add it to your Download Basket!

 Add it to your Watch List!


Rate it!
send us
an update
MIT/X Consortium License 
Colin Bick
ROOT \ Science and Engineering \ Geographical
2 OSMViz Screenshots:
OSMViz - Some buses in San FranciscoOSMViz - All aboard!
OSMViz is a small set of Python tools for retrieving and using OpenStreetMap (OSM) images (actually, Mapnik images served by Slippy Map). OSMViz's original purpose was to draw a bunch of things moving around on the map, which has been somewhat generalized and expanded.

With OSMViz you can:

 * Grab appropriate rendered OSM tiles from an OSM server of your choosing
 * Patch tiles together into a bigger map
 * Easily animate stuff on that map (requires pygame)

A note about OpenStreetMap maps

If you choose to pull tiles from the openstreetmap.org server, then there are some things you should know:

 * These tiles have a usage policy, available here.
 * These tiles are (c) OpenStreetMap and contributors, CC-BY-SA

Using OSM Viz

The code below will show a train running across the USA. Choo choo!

from osmviz.animation import TrackingViz, Simulation

start_lat,start_lon = (45.77,-68.65) # Northeast
end_lat,end_lon = (30.05,-118.25) # Southwest
begin_time, end_time = 0, 60 # In 60 seconds!

def locAtTime(t): # Basic interpolator
 if t < 0: return start_lat,start_lon
 if t > 60: return end_lat,end_lon
 frac = t/60.0
 interp_lat = start_lat + frac * (end_lat-start_lat)
 interp_lon = start_lon + frac * (end_lon-start_lon)
 return interp_lat,interp_lon

image_f = "images/train.png"
zoom = 6 # OSM zoom level
viz = TrackingViz("Continental Espresso", image_f, locAtTime,
 (30,46,-119,-68.5), # lat/lon bounding box
sim = Simulation([viz,],[],0)

While the animation is running, you can control it as follows:

* Mousing over the icon displays its label ("Continental Espresso")
* Up/down arrows increase/decrease the speed of simulation (can go backwards in time)
* Left/right arrows set simulation to begin/end of the time window
* Space bar sets the speed to zero
* Escape key exits.

To run it yourself you need to have an existing "images/train.png" as well as an empty "maptiles/" directory. These already exist in the "test" directory in the source download; in fact one of the included tests is to show the same train.

Last updated on January 11th, 2010


#map animation #OSM images #Mapnik images #OpenStreetMap #map #animation #OSM

Add your review!