Geocode addresses using the ‘HERE Geocoder’ API.
In order to geocode addresses, the function geocode
is used. The requests are sent asynchronously, which means that every geocoded address is counting as one request. The addresses have to be of type character
:
Geocode the character vector containing the addresses:
The return value is an sf
object containing POINT
geometries of the addresses:
head(geocoded, 3)
#> Simple feature collection with 3 features and 7 fields
#> geometry type: POINT
#> dimension: XY
#> bbox: xmin: 6.63222 ymin: 46.00297 xmax: 8.95121 ymax: 47.04954
#> epsg (SRID): 4326
#> proj4string: +proj=longlat +datum=WGS84 +no_defs
#> address postalCode city county state country
#> 1 Luzern, LU, Schweiz 6003 Luzern Luzern-Stadt LU CHE
#> 2 Lugano, TI, Svizzera 6900 Lugano Lugano TI CHE
#> 3 Lausanne, VD, Suisse 1003 Lausanne Lausanne VD CHE
#> type geometry
#> 1 point POINT (8.30438 47.04954)
#> 2 point POINT (8.95121 46.00297)
#> 3 point POINT (6.63222 46.51961)
Print the geocoded addresses on an interactive leaflet map: