-
Notifications
You must be signed in to change notification settings - Fork 15
Add new vignette for tips and tricks #311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| --- | ||
| title: "Tips and tricks for using the package" | ||
| output: rmarkdown::html_vignette | ||
| vignette: > | ||
| %\VignetteIndexEntry{tips-and-tricks} | ||
| %\VignetteEngine{knitr::rmarkdown} | ||
| %\VignetteEncoding{UTF-8} | ||
| --- | ||
|
|
||
| ```{r, include = FALSE} | ||
| knitr::opts_chunk$set( | ||
| collapse = TRUE, | ||
| comment = "#>", | ||
| fig.align = "center" | ||
| ) | ||
|
|
||
| # save user's options and pars | ||
| user_options = options() | ||
|
agila5 marked this conversation as resolved.
|
||
| user_par = par(no.readonly = TRUE) | ||
|
|
||
| # save files in the tempdir | ||
|
agila5 marked this conversation as resolved.
|
||
| old_dd = Sys.getenv("OSMEXT_DOWNLOAD_DIRECTORY", tempdir()) | ||
| Sys.setenv(OSMEXT_DOWNLOAD_DIRECTORY = tempdir()) | ||
|
|
||
| its_pbf = file.path( | ||
| osmextract::oe_download_directory(), | ||
| "test_its-example.osm.pbf" | ||
| ) | ||
| file.copy( | ||
| from = system.file("its-example.osm.pbf", package = "osmextract"), | ||
| to = its_pbf, | ||
| overwrite = TRUE | ||
| ) | ||
|
|
||
| # set new options | ||
| options(width = 100) | ||
| ``` | ||
|
|
||
| This vignette presents a collection of useful tips and tricks we've gathered over the years for effectively using this package to read, download, and filter OpenStreetMap (OSM) extracts. First of all, let's load the relevant packages: | ||
|
|
||
| ```{r setup} | ||
| library(osmextract) | ||
| ``` | ||
|
|
||
| ## How can I get OSM objects by node/way id number? | ||
|
|
||
| The example below demonstrates how to select a set of ways from an OSM extract, assuming you already know their OSM IDs: | ||
|
|
||
| ```{r} | ||
| osm_id <- c("4419868", "6966733", "7989989", "15333726", "31705837") | ||
|
|
||
| out <- oe_get( | ||
| place = "ITS Leeds", | ||
| query = paste0( | ||
| "SELECT * FROM lines WHERE osm_id IN (", paste0(osm_id, collapse = ","), ")" | ||
| ), | ||
| quiet = TRUE | ||
| ) | ||
| print(out, n = 0L) | ||
| ``` | ||
|
|
||
| ```{r, include=FALSE} | ||
|
agila5 marked this conversation as resolved.
|
||
| # reset par, options, and download directory | ||
| options(user_options) | ||
| par(user_par) | ||
| Sys.setenv(OSMEXT_DOWNLOAD_DIRECTORY = old_dd) | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.