Retrieve and use OpenStreetMap images
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)
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.