Learn R Programming

nominatimlite (version 0.1.6)

reverse_geo_lite_sf: Get spatial objects through reverse geocoding

Description

This function allows you extract the spatial object located on a known pair of coordinates (lat, long). Latitudes must be between -90 and 90 and longitudes must be between -180 and 180.

Usage

reverse_geo_lite_sf(
  lat,
  long,
  address = "address",
  full_results = FALSE,
  return_coords = TRUE,
  verbose = FALSE,
  custom_query = list(),
  points_only = TRUE
)

Arguments

lat

latitude values (input data)

long

longitude values (input data)

address

name of the address column (in the output data)

full_results

returns all available data from the geocoding service if TRUE. If FALSE (default) then only a single address column is returned from the geocoding service.

return_coords

return input coordinates with results if TRUE. Note that most services return the input coordinates with full_results = TRUE and setting return_coords to FALSE does not prevent this.

verbose

if TRUE then detailed logs are output to the console. FALSE is default. Can be set permanently with options(tidygeocoder.verbose = TRUE)

custom_query

API-specific parameters to be used, passed as a named list (ie. list(zoom = 3)). See Details.

points_only

Logical TRUE/FALSE. Whether to return only spatial points (TRUE, which is the default) or potentially other shapes as provided by the Nominatim API (FALSE).

Value

A sf object with the results.

Details

See https://nominatim.org/release-docs/develop/api/Reverse/ for additional parameters to be passed to custom_query.

Use the option custom_query = list(zoom = 3) to adjust the output. Some equivalences on terms of zoom:

zoom address_detail
3 country
5 state
8 county
10 city
14 suburb
16 major streets
17 major and minor streets
18 building

See Also

reverse_geo_lite()

Other spatial: bbox_to_poly(), geo_address_lookup_sf(), geo_amenity_sf(), geo_lite_sf()

Examples

Run this code
# NOT RUN {
library(ggplot2)


Coliseum <- geo_lite("Coliseo, Rome, Italy")

# Coliseum
Col_sf <- reverse_geo_lite_sf(
  lat = Coliseum$lat,
  lon = Coliseum$lon,
  points_only = FALSE
)

ggplot(Col_sf) +
  geom_sf()

# City of Rome - Zoom 10

Rome_sf <- reverse_geo_lite_sf(
  lat = Coliseum$lat,
  lon = Coliseum$lon,
  custom_query = list(zoom = 10),
  points_only = FALSE
)

ggplot(Rome_sf) +
  geom_sf()

# County - Zoom 8

County_sf <- reverse_geo_lite_sf(
  lat = Coliseum$lat,
  lon = Coliseum$lon,
  custom_query = list(zoom = 8),
  points_only = FALSE
)

ggplot(County_sf) +
  geom_sf()
# }

Run the code above in your browser using DataLab