Skip to contents

Generates an address from a latitude and longitude. Latitudes must be in the range \(\left[-90, 90 \right]\) and longitudes in the range \(\left[-180, 180 \right]\). This function returns the tibble associated with the query.

Usage

arc_reverse_geo(
  x,
  y,
  address = "address",
  full_results = FALSE,
  return_coords = TRUE,
  verbose = FALSE,
  progressbar = TRUE,
  outsr = NULL,
  langcode = NULL,
  featuretypes = NULL,
  locationtype = NULL,
  custom_query = list()
)

Arguments

x

longitude values in numeric format. Must be in the range \(\left[-180, 180 \right]\).

y

latitude values in numeric format. Must be in the range \(\left[-90, 90 \right]\).

address

address column name in the output data (default "address").

full_results

returns all available data from the API service. If FALSE (default) only latitude, longitude and address columns are returned.

return_coords

return input coordinates with results if TRUE.

verbose

if TRUE then detailed logs are output to the console.

progressbar

Logical. If TRUE displays a progress bar to indicate the progress of the function.

outsr

The spatial reference of the x,y coordinates returned by a geocode request. By default is NULL (i.e. the parameter won't be used in the query). See Details and arc_spatial_references.

langcode

Sets the language in which reverse-geocoded addresses are returned.

featuretypes

This parameter limits the possible match types returned. By default is NULL (i.e. the parameter won't be used in the query). See Details.

locationtype

Specifies whether the output geometry of featuretypes = "PointAddress" or featuretypes = "Subaddress" matches should be the rooftop point or street entrance location. Valid values are NULL (i.e. not using the parameter in the query), rooftop and street.

custom_query

API-specific parameters to be used, passed as a named list.

Value

A tibble with the corresponding results. The x,y values returned by the API would be named lon,lat. Note that these coordinates correspond to the geocoded feature, and may be different of the x,y values provided as inputs.

See the details of the output in ArcGIS REST API Service output.

Details

More info and valid values in the ArcGIS REST docs.

outsr

The spatial reference can be specified as either a well-known ID (WKID). If not specified, the spatial reference of the output locations is the same as that of the service ( WGS84, i.e. WKID = 4326)).

See arc_spatial_references for values and examples.

featuretypes

See vignette("featuretypes", package = "arcgeocoder") for a detailed explanation of this parameter.

This parameter may be used for filtering the type of feature to be returned when geocoding. Possible values are:

  • "StreetInt"

  • "DistanceMarker"

  • "StreetAddress"

  • "StreetName"

  • "POI"

  • "Subaddress"

  • "PointAddress"

  • "Postal"

  • "Locality"

It is also possible to use several values as a vector (featuretypes = c("PointAddress", "StreetAddress")).

See also

Examples

# \donttest{

arc_reverse_geo(x = -73.98586, y = 40.75728)
#> # A tibble: 1 × 3
#>       x     y address                                    
#>   <dbl> <dbl> <chr>                                      
#> 1 -74.0  40.8 178-198 W 44th St, New York, NY, 10036, USA

# Several coordinates
arc_reverse_geo(x = c(-73.98586, -3.188375), y = c(40.75728, 55.95335))
#> 
  |                                                        
  |                                                  |   0%
  |                                                        
  |=========================                         |  50%
  |                                                        
  |==================================================| 100%
#> # A tibble: 2 × 3
#>        x     y address                                                          
#>    <dbl> <dbl> <chr>                                                            
#> 1 -74.0   40.8 178-198 W 44th St, New York, NY, 10036, USA                      
#> 2  -3.19  56.0 Rabbie's, 6 Waterloo Place, Canongate, Edinburgh, Midlothian, Sc…

# With options: using some additional parameters
sev <- arc_reverse_geo(
  x = c(-73.98586, -3.188375),
  y = c(40.75728, 55.95335),
  # Restrict to these feautures
  featuretypes = "POI,StreetInt",
  # Result on this WKID
  outsr = 102100,
  verbose = TRUE, full_results = TRUE
)
#> 
  |                                                        
  |                                                  |   0%
  |                                                        
  |=========================                         |  50%
#> 
#> Entry point: https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode?
#> Parameters:
#>    - location=-73.98586,40.75728
#>    - f=json
#>    - outSR=102100
#>    - featureTypes=POI,StreetInt
#> url: https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode?location=-73.98586,40.75728&f=json&outSR=102100&featureTypes=POI,StreetInt
#> 
  |                                                        
  |==================================================| 100%
#> 
#> Entry point: https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode?
#> Parameters:
#>    - location=-3.188375,55.95335
#>    - f=json
#>    - outSR=102100
#>    - featureTypes=POI,StreetInt
#> url: https://geocode.arcgis.com/arcgis/rest/services/World/GeocodeServer/reverseGeocode?location=-3.188375,55.95335&f=json&outSR=102100&featureTypes=POI,StreetInt
#> 

dplyr::glimpse(sev)
#> Rows: 2
#> Columns: 33
#> $ x            <dbl> -73.985860, -3.188375
#> $ y            <dbl> 40.75728, 55.95335
#> $ address      <chr> "W 44th St & Broadway, New York, NY, 10036, USA", "Rabbie…
#> $ lat          <dbl> 4976603, 7549144
#> $ lon          <dbl> -8236060.8, -354928.6
#> $ Match_addr   <chr> "W 44th St & Broadway, New York, New York, 10036", "Rabbi…
#> $ LongLabel    <chr> "W 44th St & Broadway, New York, NY, 10036, USA", "Rabbie…
#> $ ShortLabel   <chr> "W 44th St & Broadway", "Rabbie's"
#> $ Addr_type    <chr> "StreetInt", "POI"
#> $ Type         <chr> NA, "Restaurant"
#> $ PlaceName    <chr> NA, "Rabbie's"
#> $ AddNum       <chr> NA, "6"
#> $ Address      <chr> "W 44th St & Broadway", "6 Waterloo Place"
#> $ Block        <chr> NA, NA
#> $ Sector       <chr> NA, NA
#> $ Neighborhood <chr> "Midtown", "Canongate"
#> $ District     <chr> "Manhattan", NA
#> $ City         <chr> "New York", "Edinburgh"
#> $ MetroArea    <chr> NA, "Edinburgh"
#> $ Subregion    <chr> "New York County", "Midlothian"
#> $ Region       <chr> "New York", "Scotland"
#> $ RegionAbbr   <chr> "NY", "SCT"
#> $ Territory    <chr> NA, NA
#> $ Postal       <chr> "10036", "EH1 3EG"
#> $ PostalExt    <chr> "4011", NA
#> $ CntryName    <chr> "United States", "United Kingdom"
#> $ CountryCode  <chr> "USA", "GBR"
#> $ X            <dbl> -73.985793, -3.188378
#> $ Y            <dbl> 40.75726, 55.95340
#> $ InputX       <dbl> -73.985860, -3.188375
#> $ InputY       <dbl> 40.75728, 55.95335
#> $ wkid         <int> 102100, 102100
#> $ latestWkid   <int> 3857, 3857
# }