geonames function

Retrieve city names and locations

Retrieve city names and locations

This function uses the geonames package to provide city names and locations from www.geonames.org.

GNcities(north, east, south, west, lang = "en", maxRows = 10, buffer=0) GNsearch(..., crs=crsLL)

Arguments

  • north: A bounding box or SpatialPoints or SpatialPolygons or Extent or Raster object, or a decimal degree of longitude.
  • east,south,west: If north is numeric, decimal degree bounding box.
  • lang: Language for internationalised returned text
  • maxRows: Limit on returned rows
  • buffer: passed to extend
  • ...: Various search arguments
  • crs: projection for the output

See Also

GNcities, GNsearch

Returns

A SpatialPointsDataFrame with the sampe projection north if it exists, otherwise in long-lat.

Examples

## Not run: GNsearch(q="Toronto Ontario", maxRows = 3) ## End(Not run) library('terra') myraster = rast( matrix(1:100,10,10), extent=ext(8,18,0,10), crs=crsLL) options(geonamesUsername="myusernamehere") if(file.exists("~/geonamesUsername.R")) source("~/geonamesUsername.R") if(requireNamespace("geonames", quietly = TRUE)) { cities=try(GNcities(myraster, max=5), silent=TRUE) mytiles = openmap(myraster, zoom=5, buffer=1) oldpar=map.new(mytiles) plot(mytiles, add=TRUE) if(!all(class(cities)=='try-error')) { points(cities, col='red') text(cities, labels=cities$name, col='red',pos=4) } par(oldpar) }
  • Maintainer: Patrick Brown
  • License: GPL
  • Last published: 2024-04-16

Useful links