-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
55 lines (41 loc) · 1.71 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# tidypass
<!-- badges: start -->
[](https://lifecycle.r-lib.org/articles/stages.html#experimental)
<!-- badges: end -->
A tidy R interface to the [Postpass](https://github.com/woodpeck/postpass-ops) service. Allows you to use dplyr syntax to retrieve OpenStreetMap data using [`{dbplyr}`](https://dbplyr.tidyverse.org/). Postpass is a nice alternative to [Overpass Turbo](https://overpass-turbo.eu/) that is faster and more versatile because it uses a Postgres database in the background.
## Installation
You can install the development version of tidypass from [GitHub](https://github.com/) with:
``` r
# install.packages("pak")
pak::pak("jslth/tidypass")
```
## Example
This is a basic example which extracts all fast food restaurants in Karlsruhe along with their stated cuisine. Generally, only the four columns can be accessed directly (`tags`, `osm_id`, `osm_type`, and `geom`) and all other features have to be extracted from the tags list using the `%->>%` operator.
```{r example}
library(tidypass)
library(dplyr, warn.conflicts = FALSE)
library(sf, quietly = TRUE)
# Boundaries of Karlsruhe
bbox <- st_as_sfc(st_bbox(c(
xmin = 8.34,
xmax = 8.46,
ymin = 48.97,
ymax = 49.03
)))
pp_tbl("point") |>
filter(tags %->>% 'amenity' == "fast_food" & geom %&&% !!pg_bbox(bbox)) |>
transmute(cuisine = tags %->>% "cuisine", name = tags %->>% 'name', geom) |>
collect()
```