NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum


I am trying to get a map using R and the get_map function.

Location.S <- c(3.5, 57.7, 11, 66)
Map.South <- get_map(location=Location.S, source="osm", color="bw", crop=TRUE, language="en-EN")

This code worked fine three weeks ago but I now get the following error message:

Error: map grabbing failed - see details in ?get_openstreetmap. In addition: Warning message: In download.file(url, destfile = destfile, quiet = !messaging, mode = "wb") : cannot open URL ',57.7,11,66&scale=5000000&format=png': HTTP status was '400 Bad Request'

Any help will be greatly appreciated.

asked 11 Jan '17, 11:57

Pierrick0204's gravatar image

accept rate: 0%

This R function seems to run an CGI export call. I'm surprised that it worked at all. An issue has been filed against the github repo requesting that this call not be used:

The website export call is heavily rate limited. There are numerous examples of queries on this site relating to this issue.

permanent link

answered 11 Jan '17, 13:38

SK53's gravatar image

SK53 ♦
accept rate: 22%

/cgi-bin/export at is not designed for automated requests from scripts! See for more details. Quoting this page:

Calls to /cgi-bin/export may only be triggered by direct end-user action. (For example: “click here to export”.) The export call is an expensive (CPU+RAM) function to run and will frequently reject when server is under high load.

This means that the get_map() call implementation in R for OSM is broken.

IMHO R should access individual tiles for the specified zoom level instead (without violating the tile usage policy, of course). Afterwards it just has to concatenate these tiles locally. This should be roughly equivalent to a call to /cgi-bin/export.

permanent link

answered 11 Jan '17, 13:38

scai's gravatar image

scai ♦
accept rate: 23%

The call get_openstreetmap() does not semm to work as well. Is there any way I can import the OSM from R since I am plotting data linked to geo coordinates?

(11 Jan '17, 14:00) Pierrick0204

I can't answer this question since I've never worked with OSM in R.

(11 Jan '17, 14:43) scai ♦

See the github issue for more on this.

(11 Jan '17, 17:53) SK53 ♦

Hi again. If I understand the recent conversation from this post on Github, there is no way I can plot the same OSM map from R? That's really a pity since I used I for a scientific paper from which I have to update the map figure using the same map background as I previously did. Is there any alternative to get through this?

(12 Jan '17, 01:33) Pierrick0204

You can try BigMap 2 to generate an image which you can then embed yourself. Keep in mind that this program will also violate the tile usage policy if used excessively. But for your paper it is probably okay.

(12 Jan '17, 08:19) scai ♦

Thanks. Will the generated image contain the geographic coordinates? I need this information to plot my data (aquaculture sites) along the Norwegian coast, based on coordinates.

(12 Jan '17, 08:55) Pierrick0204

No, the image will just be a regular image. The image generated by /cgi-bin/export also doesn't "contain" coordinates. Instead R knows the bounds of the image and can calculate the coordinates.

(12 Jan '17, 09:58) scai ♦

An alternative would be to use QGIS, the Composer option & Quick Map Services Plugin to create a map from OSM tiles covering the same area. This gives good control over scale and boundaries. I'm not sure exactly how pulling a map into ggplot works though.

(12 Jan '17, 13:26) SK53 ♦

In the meantime, I just figured out the openstreetmap package on R which seem to do more or less the same.

(12 Jan '17, 14:42) Pierrick0204
showing 5 of 9 show 4 more comments

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 11 Jan '17, 11:57

question was seen: 9,043 times

last updated: 12 Jan '17, 14:42

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum