课程: Data Visualization in R with ggplot2

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Geocoding points

Geocoding points

- [Instructor] As we work with map data, we often need to pinpoint specific locations on a map. You've already seen this work behind the scenes a few times with the qmap and get_map functions. We simply provided the name of a location and those functions pulled up the correct map of that area. Now, under the hood, those functions were performing an operation called geocoding. When we geocode a location, we convert it from a string to a latitude and longitude on the globe. There's no formula to do this, so R can't perform geocoding without some assistance. Fortunately, the ggmap package includes a geocoding function that uses Google Maps to perform geocoding. The geocode function takes a location name as input and returns the latitude and longitude of that location. Let's give it a try in R. I'll begin by geocoding New York City. I'm going to store in a variable called nyc the result of geocoding the location New York, New York. Now, when I look at the contents of that object, I can…

内容