Geocodes
One of the fundamental things about spatial data and mapping is the geographic coordinate system used to uniquely identify locations. We use longitude (x axis, abbreviated lon) and latitude (y axis, abbreviated lat) for locations on our planet. The longitude is the angle from the meridian through Greenwich and the latitude is the angle from the equator. We can use street addresses and locations. Here are a few examples.
geocode("Singapore")
## lon lat
## 1 103.8198 1.352083
geocode("11 Bunda Street, Canberra")
## lon lat
## 1 149.1319 -35.27705
geocode("Raffles Place", output="more")
## lon lat type loctype address north
## 1 103.8513 1.2841 route geometric_center raffles place, singapore 1.285651
## south east west route neighborhood locality country
## 1 1.282702 103.8527 103.85 Raffles Place Downtown Core Singapore Singapore
For later use we will save some of our locations.
cityhall <- as.numeric(geocode("City Hall, Singapore")) %T>% print()
## [1] 103.852460 1.293186
raffles <- as.numeric(geocode("Raffles Place")) %T>% print()
## [1] 103.8513 1.2841
sentosa <- as.numeric(geocode("Sentosa")) %T>% print()
## [1] 103.830321 1.249404