geocode function

Georeferencing with Google

Georeferencing with Google

Uses the dismo package to geocode with Google

geocode(x, extent, lang = gsub("(_|[:]).*", "", Sys.getenv('LANGUAGE')))

Arguments

  • x: Vector of character strings to search for
  • extent: Currently unused. an Extent object, or any object from which an Extent can be obtained.
  • lang: Language for place names in result.

Returns

A SpatialPointsDataFrame with coordinates in the projection of extent if possible, or long-lat otherwise.

Details

If the option getOption('mapmiscCachePath') is set, it will be used to specify the folder to save downloaded data. getOption('mapmiscVerbose') for printing progress.

Data are retreived from Openstreetmap.org, see https://wiki.openstreetmap.org/wiki/Nominatim.

Examples

cities=try(geocode('Ulan batar'), silent=TRUE) data('worldMap') worldMap = terra::unwrap(worldMap) if(!all(class(cities) == 'try-error') ) { citiesT = project(cities, crs(worldMap)) oldpar=map.new(citiesT, buffer=5000*1000) plot(worldMap, add=TRUE) points(citiesT, col='red') suppressWarnings(text(citiesT, labels=citiesT$name, col='red',pos=4)) ## Not run: # uses unicode symbols text(citiesT, labels=citiesT$display_name, col='red',pos=1)) ## End(Not run) par(oldpar) }
  • Maintainer: Patrick Brown
  • License: GPL
  • Last published: 2024-04-16

Useful links