13

What I want to do is to generate a static image (e.g. a png) using python and using openstreetmap tiles as a background.

Mathplotlib and Basemap is almost what I'm looking for. The problem is being able to use OSM tiles as background. I'm not pleased by the approach suggested in http://stevendkay.wordpress.com/2010/02/24/plotting-points-on-an-openstreetmap-export/

The closest I found is in this answer but using R, and not python Plotting points from a data.frame using OpenStreetMap

Did I miss any obvious and easy solution?

Thanks for your help

EDIT : this questions suggests many tools, but none seems to match my needs How can I display OSM tiles using Python?

Community
  • 1
  • 1
Tristram Gräbener
  • 9,601
  • 3
  • 34
  • 50

1 Answers1

2

You overlooked the "Export" tab at the OSM website, which is capable of generating a static image with the dimensions and map extents you want. Have a look at http://wiki.openstreetmap.org/wiki/Export

Please be advised that generating static images is a resource-intensive process, and the OSM sysadmins will frown upon you if you do a large number of requests or abuse this feature. Unfortunately this means you'll have to find another solution if you're trying to do lots of images.

By the way, the data you're plotting on top is properly projected into EPSG:3857 and not just raw lat/lon coordinates, right? Raw lat/lon data will look distorted at large zoom levels.

  • 1
    This is the solution used by the first link I pasted. I want to generate about a hundred images, so doing it by hand it very cumbersome (but the bandwidth used will be significantly slower than when juste browsing the map, so there shouldn't be any problem here) – Tristram Gräbener Jul 05 '12 at 14:34
  • 2
    @TristramGräbener I have similar interest than yours, but use other tile source. In order not to overload bandwidth, I created a "tile server" which caches the data. So, when I ask the "server" (which is an instance of the TileServer class I created in Python), it looks in itself for the image (self.image_dict), otherwise it reads the correspondent image from disk (Image.open()), otherwise it downloads and saves the file (urllib.urlretrieve()). Hope this idea helps! – heltonbiker Sep 09 '12 at 22:06