How can I display OSM tiles using Python?

2019-03-08 09:10发布

问题:

I'm in the process of generating tiles with generate_tiles.py and I'd like to write a Python app to display them instead of having a web interface. Does anything like that already exist or is there information somewhere on how to write such an app myself?

回答1:

You can look/edit your map using a desktop application like Tilemill or QGIS (I can't really guess why are you generating tiles if it is not for a web application).

Tilestache has an internal webserver you can use for testing, it's easy to get it running just using config files.

A few pointers to get you started (or keep you busy for a few weeks):

Server side libraries and applications

  • TileStache: very easy to use tile server and tile cache
  • Mapnik: underlying library behind tilestache and tilemill
  • TileLite: lightweight Python tile-server
  • MapOSMatic: written in Python/Django + mapnik ?

Client side libraries

  • Leaflet: client side library a lot like Google Maps API
  • OpenLayers: makes it easy to put a dynamic map in any web page
  • Wax: adds common utilities to minimal mapping libraries
  • Modest maps: a simple platform to build upon
  • Mapstraction: common interface for numerous javascript mapping libraries

Tools for custom map creation

  • Tilemill: like css for maps (awesome)
  • OSGeo4W: must have geospatial toolbox for windows

Markers

  • MakiIcons: A clean point of interest icon set made for web cartography
  • Map Icons Collection: 700 free icons to use as placemarks

Some related videos from PyCon2012

  • A gentle introduction to GIS
  • Making maps with Python
  • Spatial data and web mapping with Python
  • Making interactive maps for the web

Some interesting applications to get you inspired:

  • 8bitcity: if Google Maps was running into an Atari 2600 River Raid cartridge
  • OpenWhateverMap: a patchwork of different rendering styles


回答2:

Quoting the OP:

I'd like to write a Python app to display them instead of having a web interface

I have the same request (more specifically, I need to show an interactive map within an already existing GTK+ desktop application), I didn't see the question answered here, so I went to look for direct reference information. There I see three options:

  • if you're on KDE: https://wiki.openstreetmap.org/wiki/KDE_Marble
  • if you're on GTK+: http://nzjrs.github.io/osm-gps-map/
  • again in GTK+: https://wiki.openstreetmap.org/wiki/Libchamplain

Paulo Scardine very complete overview focuses on web interface, and does not mention them.