MyNixOS website logo
Description

High-Performance Geocoding using 'photon'.

Features unstructured, structured and reverse geocoding using the 'photon' geocoding API <https://photon.komoot.io/>. Facilitates the setup of local 'photon' instances to enable offline geocoding.

photon

R-CMD-check R-hub CRANstatus Project Status: Active – The project has reached a stable, usablestate and is being activelydeveloped. Codecov testcoverage CodeFactor

{photon} is a simple interface and setup manager of the photon 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:

install.packages("photon")

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

# 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.

library(photon)
places <- c("Paris", "Beijing", "Sao Paolo", "Kinshasa")

cities1 <- geocode(places, limit = 1, layer = "city")
cities1
#> Simple feature collection with 4 features and 12 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -46.63338 ymin: -23.55065 xmax: 110.7344 ymax: 48.8535
#> Geodetic CRS:  WGS 84
#> # A tibble: 4 × 13
#>     idx osm_type  osm_id country osm_key countrycode osm_value name  state type 
#>   <int> <chr>      <dbl> <chr>   <chr>   <chr>       <chr>     <chr> <chr> <chr>
#> 1     1 R         7.15e4 France  place   FR          city      Paris Ile-… city 
#> 2     2 N         4.52e9 China   place   CN          town      Beij… Shan… city 
#> 3     3 R         2.98e5 Brazil  place   BR          municipa… São … São … city 
#> 4     4 R         3.88e5 Democr… bounda… CD          administ… Kins… Kins… city 
#> # ℹ 3 more variables: extent <list>, county <chr>, geometry <POINT [°]>

Reverse geocoding means taking point geometries and returning their addresses or place names.

cities2 <- reverse(cities1$geometry, limit = 1, layer = "city")
cities2
#> Simple feature collection with 4 features and 12 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -46.63338 ymin: -23.55065 xmax: 110.7344 ymax: 48.8535
#> Geodetic CRS:  WGS 84
#> # A tibble: 4 × 13
#>     idx osm_type  osm_id country osm_key countrycode osm_value name  state type 
#>   <int> <chr>      <dbl> <chr>   <chr>   <chr>       <chr>     <chr> <chr> <chr>
#> 1     1 R         7.15e4 France  place   FR          city      Paris Ile-… city 
#> 2     2 N         4.52e9 China   place   CN          town      Beij… Shan… city 
#> 3     3 R         2.98e5 Brazil  place   BR          municipa… São … São … city 
#> 4     4 R         3.88e5 Democr… bounda… CD          administ… Kins… Kins… city 
#> # ℹ 3 more variables: extent <list>, county <chr>, geometry <POINT [°]>
all.equal(cities1, cities2)
#> [1] TRUE

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.

photon <- new_photon(path = "./photon", country = "Germany")
photon$start()

Related packages

  • The {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} package by Michael Hudecheck implements reverse geocoding using (among others) photon.
  • The {tidygeocoder} and {nominatimlite} packages implement general (OSM) geocoding using web APIs.
Metadata

Version

0.3.1

License

Unknown

Platforms (77)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows