Reverse geocode a set of coordinates, an 'sf' point, or an 'sfc' point

reverse_geocode(input, distance = NULL, crs = 4326)

Arguments

input

Either a 2-element numeric vector (longitude, latitude), an 'sf' point object, or an 'sfc' object.

distance

Max distance to search around coordinates (in feet). Default is NULL.

crs

Coordinate reference system code of points. Default is 4326.

Value

Dataframe with place name and address corresponding to coordinates.

Examples

reverse_geocode(c(-74.44513, 40.49297)) # Using longitude and latitude
#> njgeo: downloading data
#>                                       Match_addr
#> 1 33 Livingston Avenue, New Brunswick, NJ, 08901
#>                                        LongLabel           ShortLabel
#> 1 33 Livingston Avenue, New Brunswick, NJ, 08901 33 Livingston Avenue
#>      Addr_type Type PlaceName AddNum              Address Block Sector
#> 1 PointAddress                    33 33 Livingston Avenue             
#>   Neighborhood District          City MetroArea Subregion Region RegionAbbr
#> 1                       New Brunswick           Middlesex     NJ         NJ
#>   Territory Postal PostalExt CntryName CountryCode
#> 1            08901      1900       USA            
# Or using an sf point object:
library(sf)
#> Linking to GEOS 3.11.0, GDAL 3.5.3, PROJ 9.1.0; sf_use_s2() is TRUE
point_sf <- st_sfc(st_point(c(-74.44513, 40.49297)), crs = 4326)
reverse_geocode(point_sf)
#> njgeo: downloading data
#>                                       Match_addr
#> 1 33 Livingston Avenue, New Brunswick, NJ, 08901
#>                                        LongLabel           ShortLabel
#> 1 33 Livingston Avenue, New Brunswick, NJ, 08901 33 Livingston Avenue
#>      Addr_type Type PlaceName AddNum              Address Block Sector
#> 1 PointAddress                    33 33 Livingston Avenue             
#>   Neighborhood District          City MetroArea Subregion Region RegionAbbr
#> 1                       New Brunswick           Middlesex     NJ         NJ
#>   Territory Postal PostalExt CntryName CountryCode
#> 1            08901      1900       USA            
# Or using an sfc object:
point_sfc <- st_point(c(-74.44513, 40.49297))
reverse_geocode(point_sfc)
#> njgeo: downloading data
#>                                       Match_addr
#> 1 33 Livingston Avenue, New Brunswick, NJ, 08901
#>                                        LongLabel           ShortLabel
#> 1 33 Livingston Avenue, New Brunswick, NJ, 08901 33 Livingston Avenue
#>      Addr_type Type PlaceName AddNum              Address Block Sector
#> 1 PointAddress                    33 33 Livingston Avenue             
#>   Neighborhood District          City MetroArea Subregion Region RegionAbbr
#> 1                       New Brunswick           Middlesex     NJ         NJ
#>   Territory Postal PostalExt CntryName CountryCode
#> 1            08901      1900       USA