-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
84 lines (60 loc) · 3.25 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
---
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%"
)
```
# photon
<!-- badges: start -->
[](https://github.com/JsLth/photon/actions/workflows/R-CMD-check.yaml)
[](https://github.com/jslth/photon/actions/workflows/rhub.yaml)
[](https://CRAN.R-project.org/package=photon)
[](https://www.repostatus.org/#active)
[](https://app.codecov.io/gh/JsLth/photon?branch=main)
[](https://www.codefactor.io/repository/github/jslth/photon/overview/main)
<!-- badges: end -->
`{photon}` is a simple interface and setup manager of the [photon](https://photon.komoot.io) OpenStreetMap geocoder. It features unstructured, structured, and reverse geocoding. The package allows requests to the public API but shines at setting up local instances to enable high-performance offline geocoding.
## Installation
To install the package from CRAN:
``` r
install.packages("photon")
```
You can install the development version of photon from [GitHub](https://github.com/) with:
``` r
# install.packages("remotes")
remotes::install_github("jslth/photon")
```
## Usage
When loading `{photon}`, the package assumes that you want send geocoding requests to the public photon API. If you want to change this, you can use the workhorse function `new_photon()`. Otherwise, you can directly start geocoding.
```{r geocode}
library(photon)
places <- c("Paris", "Beijing", "Sao Paolo", "Kinshasa")
cities1 <- geocode(places, limit = 1, layer = "city")
cities1
```
Reverse geocoding means taking point geometries and returning their addresses or place names.
```{r reverse}
cities2 <- reverse(cities1$geometry, limit = 1, layer = "city")
cities2
```
```{r compare}
all.equal(cities1, cities2)
```
## Offline geocoding
`{photon}` is designed to facilitate offline geocoding. `new_photon()` can install photon locally. The following code would install and start photon covering the country of Germany in the current working directory.
```{r offline, eval=FALSE}
photon <- new_photon(path = "./photon", country = "Germany")
photon$start()
```
## Related packages
- The [`{photon}`](https://github.com/rCarto/photon) package by Timothée Giraud interfaces photon but does not allow the setup of local instances and was abandoned a while ago.
- The [`{revgeo}`](https://CRAN.R-project.org/package=revgeo) package by Michael Hudecheck implements reverse geocoding using (among others) photon.
- The [`{tidygeocoder}`](https://jessecambon.github.io/tidygeocoder/) and [`{nominatimlite}`](https://dieghernan.github.io/nominatimlite/) packages implement general (OSM) geocoding using web APIs.