Import 'OpenStreetMap' Data as Simple Features or Spatial Objects

Download and import of 'OpenStreetMap' ('OSM') data as 'sf' or 'sp' objects. 'OSM' data are extracted from the 'Overpass' web server and processed with very fast 'C++' routines for return to 'R'.



Major changes:

  • New function, osm_elevation to insert elevation data into SC-format data returned by osmdata_sc function.
  • New vignette on osmdata_sc function and elevation data.
  • opq() function now accepts polygonal bounding boxes generated with getbb(..., format_out = "polygon").


Minor changes:

  • Bux fix for vectorized lists of values in add_osm_feature, so only listed items are returns (see #139; thanks @loreabad6)
  • But fix to ensure all sf data.frame objects have stringsAsFactors = FALSE


Major changes:

  • New function osmdata_sc to return data in silicate::SC format (see; this also requires additional dependency on tibble)
  • Structure of osmdata object modified to replace former $timestamp field with $meta field containing a list of $timestamp, $OSM_version (currently 0.6), and $overpass_version.
  • add_osm_feature() now accepts vectors of multiple values (see #139).
  • osmdata_sf() objects default to character vectors, not factors (see #44).

Minor changes:


  • Fix bug in trim_osmdata so that all sf attributes are reinstated, and also issue message that sf-preload is necessary for this function
  • Fix bug with opq (key_exact = FALSE) so value_exact is always also set to FALSE


  • Fix bug in c method so it works when sf not loaded
  • Fix bug in overpass query syntax to match new QL requirements


  • Add new function 'osm_poly2line()' to coerce the 'osmdata$odm_polygons' object for 'osmdata_sf' objects to lines, and append to 'osmdata$osm_lnes'. This is important for street networks ('add_osm_objects (key = "highway")'), which are otherwise separated between these two components.
  • Add new function opq_osm_id to query by OSM identifier alone
  • Add timeout and memsize options to opq() to improve handling large queries.
  • Return useful information from overpass server when it returns neither error nor useful data
  • Make C++ code interruptible so long processing can be cancelled
  • Fix minor yet important C++ code lines that prevented package being used as dependency by other packages on some systems


  • Add extraction of bounding polygons with getbb (..., format_out = "polygon")
  • Add trim_osmdata function to trim an osmdata object to within a bounding polygon (thanks @sytpp)
  • Add unique_osmdata function which reduces each component of an osmdata object only to unique elements (so $osm_points, for example, only contains points that are not represented in other - line, polygon, whatever - objects).
  • Rename add_feature to add_osm_feature (and deprecate old version)


  • Enable alternative overpass API services through get_overpass_url() and set_overpass_url() functions
  • Extend and improve vignette


  • Change tests only, no functional difference


  • Rename function opq_to_string() to opq_string()

0.0.1 (19 May 2017)

  • Remove configure and Makevars files
  • Fix tests

0.0.0 (18 May 2017)

  • Initial CRAN release

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.1.3 by Mark Padgham, 9 months ago (website) (devel)

Report a bug at

Browse source code at

Authors: Mark Padgham [aut, cre] , Bob Rudis [aut] , Robin Lovelace [aut] , Maƫlle Salmon [aut] , Andrew Smith [ctb] , James Smith [ctb] , Andrea Gilardi [ctb] , Marcin Kalicinski [ctb, cph] (Author of included RapidXML code) , Finkelstein Noam [ctb, cph] (Author of included stub.R code) , Bartnik Lukasz [ctb, cph] (Author of included stub.R code)

Documentation:   PDF Manual  

GPL-3 license

Imports curl, httr, lubridate, magrittr, methods, Rcpp, rvest, jsonlite, sp, tibble, utils, xml2

Suggests devtools, knitr, pkgdown, raster, rmarkdown, roxygen2, sf, testthat

Linking to Rcpp

System requirements: C++11

Imported by dodgr, osmplotr.

Suggested by stats19, tmap, tmaptools.

See at CRAN