osmda 包找不到任何对象

The osmda package doesn't find any objects

我直接用osmdata package to find the banks in a sector of Bogota, Colombia. When using the overpass网页,找到了下面的对象,但是RAPI什么也没有找到。有什么问题?

使用立交桥

node[amenity=bank]
  (4.6304414673187,-74.075607061386,4.6332058140013,-74.072549343109);
out;

使用 R

library(osmdata)
library(mapview)

my_box <- c(4.6304414673187,-74.075607061386,4.6332058140013,-74.072549343109);
bank_pol <- opq(bbox = my_box, timeout = 25*100) %>% 
            add_osm_feature(key = "amenity", "bank") %>% 
            osmdata_sf()

bank_pol$osm_polygons
Simple feature collection with 0 features and 1 field
bbox:           xmin: 1.797693e+308 ymin: 1.797693e+308 xmax: -1.797693e+308 ymax: -1.797693e+308
geographic CRS: WGS 84
[1] osm_id   geometry
<0 rows> (or 0-length row.names)

mapview(bank_pol$osm_polygons)

my_box 可以是 matrixvector,如 opq 的文档所述

bbox - Either (i) four numeric values specifying the maximal and minimal longitudes and latitudes, in the form c(xmin, ymin, xmax, ymax) or (ii) a character string in the form xmin,ymin,xmax,ymax. These will be passed to getbb to be converted to a numerical bounding box. Can also be (iii) a matrix representing a bounding polygon as returned from getbb(..., format_out = "polygon").

使用 getbb,生成的输出是 matrix,其中 x 值在第一行,y 值在下面

getbb("Bogota", display_name_contains = "Colombia")
#        min       max
#x -74.223514 -74.01025
#y   4.471175   4.83317


getbb("Bogota", display_name_contains = "Colombia") %>%
    opq() %>% 
    add_osm_feature(key = "amenity", "bank") %>%
    osmdata_sf() -> bank_pol

因此,如果我们检查 OP 的 vector,某些 'x' 和 'y' 值会反转。它可以创建为

my_box <- c(-74.075607061386, 4.6304414673187, -74.072549343109, 4.6332058140013)

现在,调用 opq

bank_pol <- opq(bbox = my_box, timeout = 25*100) %>% 
         add_osm_feature(key = "amenity", "bank") %>% 
         osmdata_sf()

-检查数据

bank_pol$osm_polygons
#Simple feature collection with 3 features and 18 fields
#geometry type:  POLYGON
#dimension:      XY
#bbox:           xmin: -74.07552 ymin: 4.630524 xmax: -74.07264 ymax: 4.633099
#geographic CRS: WGS 84
#             osm_id            name addr.city addr.country addr.district #addr.housenumber       addr.state addr.street
#392010374 392010374     Bancolombia    Bogotá           CO   Teusaquillo            40-95 Distrito Capital  Carrera 24
#392010458 392010458 Banco AV Villas    Bogotá           CO   Teusaquillo         40-71/73             <NA>  Carrera 24
#394955633 394955633            <NA>    Bogotá           CO   Teusaquillo            42-19             <NA>  Carrera 24
#          addr.suburb amenity  atm       brand brand.wikidata brand.wikipedia building building.levels    operator
#392010374  La Soledad    bank  yes Bancolombia        Q806206  en:Bancolombia      yes               2 Bancolombia
#392010458  La Soledad    bank <NA>        <NA>           <NA>            <NA>      yes               4        <NA>
#394955633  La Soledad    bank  yes        <NA>           <NA>            <NA>      yes               2  Davivienda
#                            source                       geometry
#392010374 Kaart Ground Survey 2017 POLYGON ((-74.07546 4.63140...
#3392010458 Kaart Ground Survey 2017 POLYGON ((-74.07546 4.63112...
#394955633                     <NA> POLYGON ((-74.0754 4.632585...

-情节

mapview(bank_pol$osm_polygons)

也可以使用ggmap

library(ggplot2)
library(ggmap)
library(sf)
library(osmdata)

bogota_map <- get_map(getbb("Bogota", 
   display_name_contains = "Colombia"), maptype = "toner-background")

ggmap(bogota_map) + 
   geom_sf(data = bank_pol$osm_points, inherit.aes = FALSE,
           colour = "#238443",
           fill = "#004529",
           alpha = .5,
           size = 4,
           shape = 21)+
   labs(x = "", y = "")