This is a static archive of our old OpenStreetMap Help Site. Please post any new questions and answers at community.osm.org.

Cannot get mapnik image from export/finish with Python

0

I want to get image from "https://www.openstreetmap.org/export/finish" or "http://api06.dev.openstreetmap.org/export/finish" with Python.

I tried this command.

import requests

url = "https://www.openstreetmap.org/export/finish" <br />
r = requests.post(url,{'mapnik_format': 'png', 'minlon': 135.74, 'minlat': 35.011, 'maxlon': 135.75, 'maxlat': 35.014, 'format': 'mapnik', 'mapnik_scale': 30000})

but r is Response [400] and r.content is this

<html>
<head>
<title>Error</title>
</head>
<body>
<h1>Error</h1>
<p>Missing or invalid token</p>
</body>
</html>

Why I can't get image? How should I do?

asked 04 Jan '17, 05:35

taki_'s gravatar image

taki_
11113
accept rate: 0%

edited 04 Jan '17, 07:59

scai's gravatar image

scai ♦
33.3k21309459


One Answer:

1

The export facility on the web site is not meant to be used programmatically. (See https://operations.osmfoundation.org/policies/tiles/ which says "Calls to /cgi-bin/export may only be triggered by direct end-user action." - even though you're not calling /cgi-bin/export this is the same thing.)

So even if the problem you are seeing could be fixed, you'd be using the interface in disregard of the policy.

Generally the best and most reliable way to generate static map images is to run your own rendering server - that way you can make as many requests as you like and you're not killing anyone else's server with it. If you absolutely must use a hosted service, have a look at https://wiki.openstreetmap.org/wiki/Static_map_images but be aware that the services listed there are not suitable for massive use either.

answered 04 Jan '17, 09:53

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

Oh, I see. Thank you.

(10 Jan '17, 13:19) taki_

Well, the same error occurs from the web gui when trying to export a page, to any format.

(29 Mar '17, 22:38) quazgar

Source code available on GitHub .