Code Monkey home page Code Monkey logo

osmapir's Introduction

osmapiR osmapiR website

R-CMD-check Codecov test coverage CRAN checks Project Status: Active CRAN_Status_Badge CRAN Downloads

An R interface to the OpenStreetMap API v0.6 for fetching and saving raw geodata from/to the OpenStreetMap database. This package allows access to OSM maps data as well as map notes, GPS traces, changelogs, and users data. osmapiR enables editing or exploring the history of OSM objects, and is not intended to access OSM map data for other purposes. See Related packages for other packages to access OSM map data.

Important

You are responsible for following the API Usage Policy. You can modify the user agent of the requests by setting the option osmapir.user_agent:

options(osmapir.user_agent = "my new user agent")

Respect and follow the standards and conventions of the OpenStreetMap community. If you plan to do automated edits, check the Automated Edits code of conduct.

Installation

To install latest CRAN version:

install.packages("osmapiR")

You can install the development version of osmapiR from GitHub with:

# install.packages("remotes")
remotes::install_github("ropensci/osmapiR") # Without vignettes

## With vignettes (also accessible at https://docs.ropensci.org/osmapiR/ > Articles)
# install.packages("rmarkdown") # Needed to build vignettes.
remotes::install_github("ropensci/osmapiR", build_vignettes = TRUE)

Get started

For an overview of the functions, check ?osmapiR-package or the web.

For basic examples, check vignette("osmapiR", package="osmapiR").

Related packages

  • osmdata implements the Overpass API to query data from OSM.
  • osmextract matches, downloads, converts, and imports bulk OSM data (.pbf files).
  • OpenStreetMap accesses high resolution raster maps using the OpenStreetMap protocol.

osmapiR is the only package to access other OSM data than the maps data (map notes, GPS traces, changelogs and users). It is also useful to get the history of the OSM objects and is the only package that allows editing and upload any kind of data.

To access OSM map data for purposes other than editing or exploring the history of objects, it may be better to use other packages that implement the Overpass API (osmdata) or that works with .pbf files (osmextract).

Code of Conduct

Please note that this package is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

osmapir's People

Contributors

ccamara avatar jmaspons avatar maelle avatar nealrichardson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

osmapir's Issues

pkgcheck results - main

Checks for osmapiR (v0.0.0.40)

git hash: ddd95e2a

  • ✔️ Package name is available
  • ✔️ has a 'codemeta.json' file.
  • ✔️ has a 'contributing' file.
  • ✔️ uses 'roxygen2'.
  • ✔️ 'DESCRIPTION' has a URL field.
  • ✔️ 'DESCRIPTION' has a BugReports field.
  • ✔️ Package has at least one HTML vignette
  • ✔️ All functions have examples.
  • ✔️ Package has continuous integration checks.
  • ✔️ Package coverage is 93.1%.
  • ✔️ R CMD check found no errors.
  • ✔️ R CMD check found no warnings.

Package License: GPL (>= 3)

Check input for scalar values or vectorize functions

Vectorize (no better API alternative):

  • osm_get_gpx_metadata(gpx_id, format = c("R", "xml")) call osm_get_metadata_gpx() 47e5cb7
  • osm_get_data_gpx(gpx_id, format)
  • osm_get_changesets(changeset_id, include_discussion = FALSE, format = c("R", "xml", "json"), tags_in_columns = FALSE) call osm_read_changeset() 21e185f
  • osm_get_notes(note_id, format = c("R", "xml", "rss", "json", "gpx")) call osm_read_note() 3df9362
  • osm_get_objects(osm_type, osm_id, version, full_objects = FALSE, format = c("R", "xml", "json"), tags_in_columns = FALSE) call osm_full_object() / osm_version_object() / osm_read_object() / osm_fetch_objects() #8
  • osm_get_user_details(user_id, format = c("R", "xml", "json")) call osm_details_user() / osm_details_users() #8
  • osm_delete_gpx(gpx_id) dbb3a3f
  • osm_close_note(note_id) ed056f2
  • osm_reopen_note(note_id) ed056f2
  • osm_get_notes(note_id, format = c("R", "xml", "rss", "json", "gpx")) 3df9362
  • osm_delete_note(note_id, text) 8401ef1
  • ... review other functions

Warning for length(input) > 1 pointing to osmchange_* + osm_diff_upload_changeset() as a recommended API use:

Remove explicit doc links to osmdata pkg

Hi @jmaspons, congratulations on submitting this package to rOpenSci! It'll be a great addition to the OSM ecosystem there. I was trying to debug why checks for this package didn't appear, and discovered that the following lines refer to functions from osmdata, yet that package is neither imported nor suggested here:

https://github.com/jmaspons/osmapiR/blob/6589fc37d48e187ee6b4106d4d6bcccb2a5c68c2/R/osm_get_objects.R#L28-L31

https://github.com/jmaspons/osmapiR/blob/6589fc37d48e187ee6b4106d4d6bcccb2a5c68c2/R/osmapi_elements.R#L679-L682

https://github.com/jmaspons/osmapiR/blob/6589fc37d48e187ee6b4106d4d6bcccb2a5c68c2/R/osmapi_elements.R#L906-L909

https://github.com/jmaspons/osmapiR/blob/6589fc37d48e187ee6b4106d4d6bcccb2a5c68c2/R/osmapi_miscellaneous.R#L222-L224

These become errors because the rOpenSci systems runs roxygen2::roxygenise() or the equivalent devtools::document(), while those are not called in standard rcmdcheck, which is why those checks all pass. roxygen2 has to then parse the function name from the package, which requires the package to be installed. My preferred way around this is to replace, for example,

The function [osmdata::opq()]

with

The \pkg{osmdata} function opq()

The \pkg{...} tag is resolved by roxygen simply by examining available.packages(), regardless of whether or not they are installed, and so does not error. The function name is then just plain code that requires no interpretation. When you've fixed those, feel free to ping the bot to run checks again.

Release osmapiR 0.2.0

Prepare for release:

  • git pull
  • Check current CRAN check results
  • Polish NEWS
  • usethis::use_github_links()
  • urlchecker::url_check()
  • devtools::build_readme()
  • devtools::check(remote = TRUE, manual = TRUE)
  • devtools::check_win_devel()
  • revdepcheck::revdep_check(num_workers = 4)
  • Update cran-comments.md
  • git push
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • Finish & publish blog post
  • Add link to blog post in pkgdown news menu
  • usethis::use_github_release()
  • usethis::use_dev_version(push = TRUE)
  • Tweet

Transfer repo to ROpenSci

To-dos:

  • Transfer the repo to rOpenSci's "ropensci" GitHub organization under "Settings" in your repo. I have invited you to a team that should allow you to do so. You will need to enable two-factor authentication for your GitHub account.
    This invitation will expire after one week. If it happens write a comment @ropensci-review-bot invite me to ropensci/<package-name> which will re-send an invitation.
  • After transfer write a comment @ropensci-review-bot finalize transfer of <package-name> where <package-name> is the repo/package name. This will give you admin access back.
  • Fix all links to the GitHub repo to point to the repo under the ropensci organization.
  • Delete your current code of conduct file if you had one since rOpenSci's default one will apply, see https://devguide.ropensci.org/collaboration.html#coc-file
  • If you already had a pkgdown website and are ok relying only on rOpenSci central docs building and branding,
    • deactivate the automatic deployment you might have set up
    • remove styling tweaks from your pkgdown config but keep that config file
    • replace the whole current pkgdown website with a redirecting page
    • replace your package docs URL with https://docs.ropensci.org/package_name
    • In addition, in your DESCRIPTION file, include the docs link in the URL field alongside the link to the GitHub repository, e.g.: URL: https://docs.ropensci.org/foobar, https://github.com/ropensci/foobar
  • Skim the docs of the pkgdown automatic deployment, in particular if your website needs MathJax.
  • Fix any links in badges for CI and coverage to point to the new repository URL.
  • Increment the package version to reflect the changes you made during review. In NEWS.md, add a heading for the new version and one bullet for each user-facing change, and each developer-facing change that you think is relevant.
  • We're starting to roll out software metadata files to all rOpenSci packages via the Codemeta initiative, see https://docs.ropensci.org/codemetar/ for how to include it in your package, after installing the package - should be easy as running codemetar::write_codemeta() in the root of your package.
  • You can add this installation method to your package README install.packages("<package-name>", repos = "https://ropensci.r-universe.dev") thanks to R-universe.

Should you want to acknowledge your reviewers in your package DESCRIPTION, you can do so by making them "rev"-type contributors in the Authors@R field (with their consent).

Welcome aboard! We'd love to host a post about your package - either a short introduction to it with an example for a technical audience or a longer post with some narrative about its development or something you learned, and an example of its use for a broader readership. If you are interested, consult the blog guide, and tag @ropensci/blog-editors in your reply. They will get in touch about timing and can answer any questions.

We maintain an online book with our best practice and tips, this chapter starts the 3d section that's about guidance for after onboarding (with advice on releases, package marketing, GitHub grooming); the guide also feature CRAN gotchas. Please tell us what could be improved.

Last but not least, you can volunteer as a reviewer via filling a short form.

Originally posted by @ropensci-review-bot in ropensci/software-review#633 (comment)

format = "sf"

  • notes (#36)
  • gpx data (#44, #45)
    • LINESTRING (non-self intersecting XYZM), MULTIPOINTS (XYZM) or a sf of POINT (can include time and elevation for each point as regular columns) ?
    • All dimensions of XYZM sf have to be numeric (no POSIXct for time).
    • Few functions implement XYZM sf (eg. plot fails with Error: GEOS does not support XYM or XYZM geometries; use st_zm() to drop M)
  • gpx metadata (#38, #42)
  • changesets (bbox) (#37)

pkgcheck results - pkcheck

Checks for osmapiR (v0.0.0.22)

git hash: b3aa78ee

  • ✔️ Package name is available
  • ✔️ has a 'codemeta.json' file.
  • ✔️ has a 'contributing' file.
  • ✖️ The following functions have no documented return values: [osm_delete_note, osm_hide_comment_changeset_discussion, osm_redaction_object]
  • ✔️ uses 'roxygen2'.
  • ✔️ 'DESCRIPTION' has a URL field.
  • ✔️ 'DESCRIPTION' has a BugReports field.
  • ✔️ Package has at least one HTML vignette
  • ✖️ These functions do not have examples: [osm_create_gpx, osm_delete_gpx, osm_delete_note, osm_hide_comment_changeset_discussion, osm_redaction_object, osm_update_gpx].
  • ✔️ Package has continuous integration checks.
  • ✔️ Package coverage is 84.7%.
  • ✔️ R CMD check found no errors.
  • ✔️ R CMD check found no warnings.

Important: All failing checks above must be addressed prior to proceeding

Package License: GPL (>= 3)

pkgcheck results - main

Checks for osmapiR (v0.1.0.9004)

git hash: 805e3e54

  • ✔️ Package is already on CRAN.
  • ✔️ has a 'codemeta.json' file.
  • ✔️ has a 'contributing' file.
  • ✔️ uses 'roxygen2'.
  • ✔️ 'DESCRIPTION' has a URL field.
  • ✔️ 'DESCRIPTION' has a BugReports field.
  • ✔️ Package has at least one HTML vignette
  • ✖️ These functions do not have examples: [st_as_sf].
  • ✔️ Package has continuous integration checks.
  • ✔️ Package coverage is 94.1%.
  • ✔️ R CMD check found no errors.
  • ✔️ R CMD check found no warnings.

Important: All failing checks above must be addressed prior to proceeding

Package License: GPL (>= 3)

Pagination and calls in batches to suppress limits

Deal with pagination:

  • osm_get_points_gps(bbox, page_number = 0, format = c("R", "gpx")) #29
  • osm_query_changesets((bbox, user, time, time_2, open, closed, changeset_ids, order = c("newest", "oldest"), limit = 100, format = c("R", "xml", "json"), tags_in_columns = FALSE)) #23
  • osm_search_notes <- function(q, user, bbox, from, to, closed = 7, sort = c("updated_at", "created_at"), order = c("newest", "oldest"), limit = 100, format = c("R", "xml", "rss", "json", "gpx"))

Release osmapiR 0.1.0

First release:

Prepare for release:

Submit to CRAN:

  • usethis::use_version('minor')
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

Error in osm_get_objects()->osm_fetch_objects() with many osm_ids

library(osmapiR)
#> Data (c) OpenStreetMap contributors, ODbL 1.0. https://www.openstreetmap.org/copyright

# osm_ids <- unique(sort(toponimsCat::municipis$id))
# seq_ids <- list(osm_ids[1])
# k <- 1
# for (i in seq_len(length(osm_ids))[-1]) {
#   if (osm_ids[i] - osm_ids[i - 1] > 1) {
#     k <- k + 1
#     seq_ids[[k]] <- osm_ids[i]
#   } else if (osm_ids[i + 1] - osm_ids[i] > 1) {
#     seq_ids[[k]] <- c(seq_ids[[k]], osm_ids[i])
#   }
# }
# cmd <- paste0("osm_ids <- c(", paste(sapply(seq_ids, function(x) paste(x, collapse = ":")), collapse = ", "), ")")
# all.equal(osm_ids, eval(parse(text = cmd)))
# cat(cmd)

osm_ids <- c( ## Municipis PPCC
  18000, 18311, 18316, 18318, 18326, 18328, 18349:18352, 18354, 18362:18363, 18375, 18391, 18409, 18416:18417, 18419,
  18428, 18475:18479, 18482, 18484, 18496, 20224, 20339, 22531, 22588, 23234, 23237, 23266, 23303, 23308, 23315,
  23324, 23340, 23759, 23763, 23790, 23795, 23804, 23814, 23823, 23895, 24457:24459, 24858, 24940, 25873, 27529,
  34167, 40581, 51547, 53365, 54461, 54467, 54469, 54471, 74277, 74281, 74284, 74308:74310, 74988, 74993, 80067,
  81599, 123160, 269776, 270405, 271192, 271356, 271429, 271495, 271536, 271664, 271713, 272157, 273497:273498,
  274180, 339488:339490, 339492:339493, 339495, 339498:339503, 339506:339511, 339513:339515, 339534, 339536:339537,
  339568, 339572:339574, 339577, 339584, 339613:339622, 339664, 339809:339811, 339815:339821, 339823:339824, 339847,
  339849:339852, 339854:339855, 339858, 339862, 339873:339880, 339887, 339928, 339930, 339963:339972, 340014, 340016,
  340030, 340174:340179, 340193:340204, 340206:340211, 340216:340217, 340257, 340259, 340261, 340307, 340319,
  340328:340331, 340341:340351, 340373:340375, 340377, 340379:340382, 340390, 340413, 340438:340439, 340441:340442,
  340445:340448, 340454, 340476, 340485, 340487:340488, 340492, 340498, 340500:340502, 340506:340507, 340518,
  340526:340528, 340530:340553, 340555, 340561:340562, 340661, 340689, 340694, 340696:340697, 340700, 340791, 340826,
  340828, 340843, 340848:340856, 340858:340859, 340865:340872, 340908, 340920, 340928, 340930:340933, 340935, 340975,
  341046:341047, 341049:341051, 341053, 341056, 341135, 341140:341142, 341144:341148, 341193, 341195, 341224,
  341230:341236, 341240:341241, 341308:341311, 341314:341315, 341318:341321, 341323, 341330, 341355, 341395:341397,
  341410, 341413, 341416:341418, 341444:341450, 341473, 341476, 341484:341486, 341497, 341530, 341537, 341540, 341559,
  341695:341702, 341709, 341711, 341730, 341733, 341745, 341762, 341774:341775, 341787, 341789, 341791, 341802:341809,
  341814:341815, 341826:341829, 341831:341834, 341837, 341841, 341843, 341845:341846, 341848, 341850:341852,
  341894:341901, 341903:341904, 341981, 341996:341999, 342001:342007, 342064:342073, 342133:342134, 342136:342143,
  342152:342153, 342164, 342166:342171, 342210, 342212, 342214:342217, 342250:342258, 342333:342345, 342347:342349,
  342355:342364, 342416, 342418:342419, 342422:342423, 342427, 342447, 342454, 342456, 342470, 342477:342478,
  342491:342499, 342502, 342505:342507, 342517:342526, 342544, 342552, 342590, 342597:342603, 342605, 342670:342671,
  342673:342675, 342677:342678, 342680:342681, 342688:342696, 342698, 342712, 342726:342734, 342737, 342742, 342784,
  342788:342789, 342792, 342826, 342829:342830, 342833:342839, 342890:342891, 342903, 342910, 342912, 342914:342922,
  342934, 342939, 342959:342961, 342985:342993, 343010:343014, 343017:343018, 343020:343023, 343059, 343063, 343117,
  343119, 343121, 343123:343126, 343185:343190, 343215:343222, 343235:343236, 343242, 343305:343320, 343322:343324,
  343328:343329, 343332, 343334:343335, 343347:343352, 343396:343398, 343400:343401, 343406:343410, 343436, 343441,
  343444:343445, 343447:343449, 343470:343471, 343500, 343505:343506, 343511, 343534:343542, 343586, 343589,
  343629:343640, 343642, 343644:343645, 343647:343648, 343659, 343668:343672, 343710:343719, 343729, 343818,
  343834:343842, 343893:343894, 343936:343937, 343939:343945, 343953:343962, 343964:343967, 343970:343971,
  344060:344069, 344117:344118, 344126:344135, 344174, 344198:344206, 344255, 344257:344262, 344264, 344266:344273,
  344294:344301, 344372:344381, 344392, 344394, 344403:344406, 344419, 344437, 344515:344523, 344537, 344563, 344581,
  344583, 344585, 344591, 344610:344617, 344624:344634, 344648, 344674, 344730:344731, 344742, 344744:344745, 344825,
  344856, 344858, 344861:344862, 344864, 344867, 344873, 344885, 344887, 344919:344925, 344927:344929, 344932:344935,
  344940:344948, 344950, 344953, 344956, 344964, 344966, 345011, 345022, 345031, 345033:345041, 345064, 345154,
  345165, 345172:345173, 345185, 345204:345208, 345210:345214, 345216:345217, 345219:345225, 345244:345246, 345248,
  345267:345269, 345272, 345282, 345284:345292, 345327, 345329, 345361, 345368, 345396:345398, 345400:345402,
  345405:345406, 345415, 345423, 345430, 345448, 345466:345467, 345484:345486, 345489:345498, 345513:345515,
  345517:345519, 345521:345522, 345526, 345549, 345553:345554, 345583, 345587, 345594:345595, 345598:345599,
  345601:345603, 345694:345696, 345698:345699, 345701:345702, 345704, 345708:345709, 345761, 345764, 345773,
  345806:345807, 345816, 345823, 345855, 345920:345923, 345937, 345941:345946, 345952, 345972, 345996:345997,
  345999:346000, 346003:346005, 346025:346028, 346030:346032, 346037, 346042, 346046, 346050, 346070:346076, 346099,
  346101, 346110:346113, 346131, 346228:346237, 346241, 346254, 346265, 346321, 346327:346328, 346333:346334,
  346336:346337, 346345:346349, 346361, 346363:346365, 346367, 346371:346374, 346383, 346387, 346389, 346437:346446,
  346485, 346487:346488, 346540:346541, 346543:346552, 346555:346558, 346560:346561, 346608:346617, 346643,
  346680:346688, 346690, 346698, 346710:346711, 346717, 346719, 346721:346731, 346734, 346746, 346758:346759, 346793,
  346802:346803, 346844:346845, 346847:346852, 346854:346871, 346883, 346900:346901, 346941:346944, 346981:346983,
  346985:346989, 346992:346993, 346995:347001, 347018, 347020, 347180, 347188, 347244, 347246:347251, 347253,
  347348:347357, 347361:347362, 347364, 347416, 347418:347424, 347468:347470, 347477:347480, 347510:347518, 347535,
  347537:347538, 347540:347541, 347543:347553, 347608:347611, 347614, 347616:347625, 347634:347645, 347656:347657,
  347678:347679, 347682, 347684:347686, 347764:347773, 347785, 347791, 347826, 347836, 347860:347862, 347864:347867,
  347869:347880, 347882, 347884:347885, 347889:347896, 347898, 347911, 347946, 347949:347958, 348026, 348044:348046,
  348048:348051, 348053:348059, 348103, 348113, 348131:348150, 348154, 348158, 348160, 348399, 348402, 348405, 348409,
  348412, 348822:348833, 348882, 348886:348895, 348910, 348943:348952, 348970:348971, 348973, 356747, 392022, 392027,
  392033, 392223, 392304, 392308, 401880, 409332, 409377, 409749, 1069580, 1209766, 1235861, 1382208, 1430537,
  1664392:1664395, 1664419:1664420, 1798944:1798945, 1809101:1809102, 1809104, 1809108, 1809111, 1809113, 1809115,
  1809117, 1809121, 1820709, 1821272, 1918699, 1918726, 1918771, 1918812, 1918955, 1919150, 1919385, 1919494, 1920120,
  1920644, 1920758, 1952519, 1966208, 2084436, 2181768, 2548784, 2593113, 2621923, 2768132:2768134, 2804753:2804759,
  2814309, 2814313, 2814562, 2814982, 2815058, 2815362, 2815369, 2816871, 2817026, 2820388, 2820610, 2820751, 2820851,
  2827098, 2827311, 2828302, 2828560, 2829664, 2853657, 2853759, 2853831, 2853900, 2854010, 2854137, 2858704, 2858743,
  2858774, 2862615, 2862650, 2862710, 2862762, 2863980, 2864868, 2865282, 2868083, 2875269, 2875472, 2897486, 2897517,
  2897645, 2912280, 2912304, 2912344, 2912375, 2912388, 2913416, 2913446, 2913461, 2913485, 2913659, 2913745, 2913805,
  2913808, 2913877, 2918640, 2918769, 2918951, 2918996, 2919019, 2919091, 2919179, 2924113, 2924251, 2924277, 2924304,
  2924446, 2926262:2926263, 5245866, 11755232
)
osm_ids <- as.character(osm_ids)
municipis <- osm_get_objects(osm_type = "relation", osm_id = osm_ids)
#> Error in `httr2::req_perform()`:
#> ! HTTP 414 URI Too Long.
#> • Please, open an issue at `https://github.com/jmaspons/osmapiR/issues` and report the output of `httr2::last_response()`.

Created on 2024-05-17 with reprex v2.1.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.