Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dieghernan/nominatimlite
Lite interface for getting data from OSM geocoder service.
https://github.com/dieghernan/nominatimlite
address api geocoding gis nominatim openstreetmap r r-package reverse-geocoding rstats shapefile spatial
Last synced: 4 months ago
JSON representation
Lite interface for getting data from OSM geocoder service.
- Host: GitHub
- URL: https://github.com/dieghernan/nominatimlite
- Owner: dieghernan
- License: other
- Created: 2021-07-13T12:45:30.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-11T13:57:37.000Z (5 months ago)
- Last Synced: 2024-10-12T19:44:44.475Z (4 months ago)
- Topics: address, api, geocoding, gis, nominatim, openstreetmap, r, r-package, reverse-geocoding, rstats, shapefile, spatial
- Language: R
- Homepage: https://dieghernan.github.io/nominatimlite/
- Size: 54.2 MB
- Stars: 18
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Citation: CITATION.cff
- Codemeta: codemeta.json
Awesome Lists containing this project
- jimsghstars - dieghernan/nominatimlite - Lite interface for getting data from OSM geocoder service. (R)
README
---
output: github_document
bibliography: inst/REFERENCES.bib
link-citations: true
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
warning = FALSE,
message = FALSE,
dev = "ragg_png",
tidy = "styler",
fig.path = "man/figures/README-",
dpi = 90,
out.width = "100%"
)
```[](https://CRAN.R-project.org/package=nominatimlite)
[](https://cran.r-project.org/web/checks/check_results_nominatimlite.html)
[](https://CRAN.R-project.org/package=nominatimlite)
[](https://nominatim.org/release-docs/develop/api/Overview/)
[](https://github.com/dieghernan/nominatimlite/actions/workflows/check-full.yaml)
[](https://github.com/dieghernan/nominatimlite/actions/workflows/rhub.yaml)
[](https://app.codecov.io/gh/dieghernan/nominatimlite)
[](https://www.codefactor.io/repository/github/dieghernan/nominatimlite)
[](https://dieghernan.r-universe.dev/nominatimlite)
[](https://www.repostatus.org/#active)
[](https://doi.org/10.32614/CRAN.package.nominatimlite)
[](https://CRAN.R-project.org/package=nominatimlite)The goal of **nominatimlite** is to provide a light interface for geocoding
addresses, based on the [Nominatim
API](https://nominatim.org/release-docs/latest/). It also allows to load spatial
objects using the **sf** package.Full site with examples and vignettes on
## What is Nominatim?
**Nominatim** is a tool to search
[OpenStreetMap](https://www.openstreetmap.org/) data by name and address
([geocoding](https://wiki.openstreetmap.org/wiki/Geocoding "Geocoding")) and to
generate synthetic addresses of OSM points (reverse geocoding).## Why **nominatimlite**?
The main goal of **nominatimlite** is to access the Nominatim API avoiding the
dependency on **curl**. In some situations, **curl** may not be available or
accessible, so **nominatimlite** uses base functions to overcome this
limitation.## Recommended packages
There are other packages much more complete and mature than **nominatimlite**,
that presents similar features:- [**tidygeocoder**](https://jessecambon.github.io/tidygeocoder/)
[@R-tidygeocoder]: Allows to interface with Nominatim, Google, TomTom,
Mapbox, etc. for geocoding and reverse geocoding.
- [**osmdata**](https://docs.ropensci.org/osmdata/) [@R-osmdata]: Great for
downloading spatial data from OpenStreetMap, via the [Overpass
API](https://wiki.openstreetmap.org/wiki/Overpass_API).
- [**arcgeocoder**](https://dieghernan.github.io/arcgeocoder/)
[@R-arcgeocoder]: Lite interface for geocoding with the ArcGIS REST API
Service.## Installation
Install **nominatimlite** from
[**CRAN**](https://CRAN.R-project.org/package=nominatimlite):```{r, eval=FALSE}
install.packages("nominatimlite")
```You can install the developing version of **nominatimlite** with:
```{r, eval=FALSE}
remotes::install_github("dieghernan/nominatimlite")
```Alternatively, you can install **nominatimlite** using the
[r-universe](https://dieghernan.r-universe.dev/nominatimlite):```{r, eval=FALSE}
# Install nominatimlite in R:
install.packages("nominatimlite",
repos = c(
"https://dieghernan.r-universe.dev",
"https://cloud.r-project.org"
)
)
```## Usage
### `sf` objects
With **nominatimlite** you can extract spatial objects easily:
```{r pizzahut, fig.alt="Locations of Pizza Hut restaurants in California extracted with nominatimlite"}
library(nominatimlite)# Extract some points - Pizza Hut in California
CA <- geo_lite_sf("California", points_only = FALSE)
pizzahut <- geo_lite_sf("Pizza Hut, California",
limit = 50,
custom_query = list(countrycodes = "us")
)library(ggplot2)
ggplot(CA) +
geom_sf() +
geom_sf(data = pizzahut, col = "red")
```You can also extract polygon and line objects (as provided by the Nominatim API)
using the option `points_only = FALSE`:```{r statue_liberty, fig.alt="Location of Statue of Liberty extracted with nominatimlite"}
sol_poly <- geo_lite_sf("Statue of Liberty, NY, USA", points_only = FALSE) # a building - a polygonggplot(sol_poly) +
geom_sf()
``````{r line-object, fig.alt="Different features named Ohio extracted with nominatimlite"}
dayton <- geo_lite_sf("Dayton, OH") # default - a point
ohio_state <- geo_lite_sf("Ohio, USA", points_only = FALSE) # a US state - a polygon
ohio_river <- geo_lite_sf("Ohio river", points_only = FALSE) # a river - a lineggplot() +
geom_sf(data = ohio_state) +
geom_sf(data = dayton, color = "red", pch = 4) +
geom_sf(data = ohio_river, color = "blue")
```### Geocoding and reverse geocoding
*Note: examples adapted from **tidygeocoder** package*
In this first example we will geocode a few addresses using the `geo_lite()`
function:```{r example}
library(tibble)# create a dataframe with addresses
some_addresses <- tribble(
~name, ~addr,
"White House", "1600 Pennsylvania Ave NW, Washington, DC",
"Transamerica Pyramid", "600 Montgomery St, San Francisco, CA 94111",
"Willis Tower", "233 S Wacker Dr, Chicago, IL 60606"
)# geocode the addresses
lat_longs <- geo_lite(some_addresses$addr, lat = "latitude", long = "longitude")
```Only latitude and longitude are returned from the geocoder service in this
example, but `full_results = TRUE` can be used to return all of the data from
the geocoder service.```{r echo=FALSE}
knitr::kable(lat_longs)
```To perform reverse geocoding (obtaining addresses from geographic coordinates),
we can use the `reverse_geo_lite()` function. The arguments are similar to the
`geo_lite()` function, but now we specify the input data columns with the `lat`
and `long` arguments. The dataset used here is from the geocoder query above.
The single line address is returned in a column named by the `address`.```{r}
reverse <- reverse_geo_lite(
lat = lat_longs$latitude, long = lat_longs$longitude,
address = "address_found"
)
``````{r, echo = FALSE}
knitr::kable(reverse)
```For more advance users, see [Nominatim
docs](https://nominatim.org/release-docs/latest/api/Search/) to check the
parameters available.## Citation
```{r echo=FALSE, results='asis'}
print(citation("nominatimlite"), style = "html")
```A BibTeX entry for LaTeX users is
```{r echo=FALSE, comment=""}
toBibtex(citation("nominatimlite"))
```## References