Learn R Programming

geostatsp (version 0.7.0)

GNcities: Retrieve city names and locations

Description

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

Usage

GNcities(north, east, south, west, lang = "en", maxRows = 10)

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

Value

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

See Also

GNcities in the geonames package.

Examples

Run this code
myraster = raster(matrix(0,10,10),xmn=8,xmx=18,ymn=0,ymx=10, crs="+proj=longlat")
values(myraster) = seq(0,1,len=ncell(myraster))
myPoints = SpatialPoints(myraster, proj4string=CRS(proj4string(myraster)))[
	seq(1,ncell(myraster),len=5)]

cities=GNcities(myPoints, max=5)
mytiles = openmap(myraster,  type="bing")

par(mar=c(0,0,0,0))
plot(cities)
plot(mytiles, add=TRUE)
points(cities, col='red')
text(cities, labels=cities$name, col='red',pos=4)


cities=GNcities(myraster, max=5)

plot(cities)
plot(mytiles, add=TRUE)
points(cities, col='red')
text(cities, labels=cities$name, col='red',pos=4)

Run the code above in your browser using DataLab