3

Recently, in R, every time I try to query the OpenStreetMap database through the osmdata package, I get the following error:

Error in `httr2::req_perform()`:
! HTTP 405 Method Not Allowed.

I've always used this package to download data from OpenStreetMap directly in R, but now it's not working anymore. That's an example of the code I am trying to use, which should return the bounding box of a city:

library(osmdata)

city_bbox <- getbb(place_name = "Milan, Italy")
5
  • What packageVersion('osmdata'), mine osmdata-0.1.10, working as expected on above query. Commented Aug 4, 2023 at 11:11
  • The version is the 0.2.3. I tried to re-install the version you are using and the error is still appearing. Commented Aug 4, 2023 at 11:16
  • 2
    With osmdata-0,2,3, still working, have you tried debugonce(osmdata::getbb) and stepped thru to where httr2::req_perform() appears? Commented Aug 4, 2023 at 11:39
  • Apparently after 1 day things started working again normally. It was probably a problem on the server side. Commented Aug 5, 2023 at 7:32
  • 3
    This HTTP 405 error was fixed in {osmdata} v0.2.4 (see github.com/ropensci/osmdata/releases/tag/v0.2.5, github.com/ropensci/osmdata/issues/328) Commented Aug 18, 2023 at 13:33

2 Answers 2

2

Its curious, if I get this code specifying the boundaries of bbox as vector it works.

library(osmdata)
library(mapview)
library(sf)
Castalla <- opq (bbox = c (-0.88,38.49,-0.47,38.74)) %>% # 
  add_osm_feature (key = "name", value = "Castalla", value_exact = FALSE) %>%
  osmdata_sf ()

However trying this sample from the documentation still fails with the 405 error

q <- opq ("portsmouth usa") %>%
    add_osm_feature (key = "amenity", value = "!restaurant") %>%
    add_osm_feature (key = "amenity", value = "!pub") # There are a lot of these

Its very bizarre

Sign up to request clarification or add additional context in comments.

1 Comment

Going into the exact same problem ; I have also run the code from documentation that failed; while your code didnot
-1

Here's a workaround using packages nominatimlite and sf:

nominatim_polygon <- nominatimlite::geo_lite_sf(address = "Milan, Italy", points_only = FALSE)
bbox <- sf::st_bbox(nominatim_polygon)

It seems to be an issue within osmdata's get_nominatim_query function (getbb.R), which can be avoided by passing a vector to getbb() instead of a string. This vector can be obtained by passing through st_bbox() an sf polygon, which we can still get with nominalite::geo_lite_sf() while osmdata is giving this 405 error.

1 Comment

Correct answer is to upgradeosmdata

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.