在使用ggmap软件包和latitude-longitude
函数的城市获取geocode
时遇到错误。
library(ggmap)
# get frequencies
mycities<- as.character(Chennai$City1)
freq <- as.data.frame(table(mycities))
library(plotrix)
library(ggmap)
freq$Freq <- rescale(freq$Freq, c(1,10)) # c(scale_min, scale_max)
geocode(freq$mycities[1])
dput(head(freq))
数据结构是
structure(list(mycities = structure(1:6, .Label = c("Alamanda Rs",
"Aluva", "Ambasamudram", "Ambattur", "Ameerpet", "Amreli", "Anakapalle",
"ANATHAPUR", "Anekal", "Aranthangi", "Aravakurichi", "Ariyalur",
"Asifnagar", "Bagalkot", "Banaganapalle", "Bandlaguda", "Bangalore",
"BANGALORE", "Bangalore North", "Bangalore South", "Bapatla",
"Belgaum", "Bellary", "BELLARY", "Bhadrachalam", "Bhadravati",
"Bibinagar", "Bidar", "Bikkavolu", "Bilgi", "Bobbili", "Buchinaidu Kandriga",
"Chengalpattu", "Chennai", "Chennai City Corporation", "Chikodi",
"Chillakur", "Chincholi", "Chinglepet", "Chittapur", "Chittur",
"Chityal", "CHOUTUPPAL", "COCHIN", "Coimbatore South", "Coonoor",
"Cuddalore", "Dachepalle", "Davangere", "Dharapuram", "Dindigul",
"Doddaballapura", "Duggirala", "Egmore", "Ernakulam", "Erode",
"Etcherla", "Ettayapuram", "Ghanpur (Mulug)", "Gokak", "Gokavaram",
"Gooty", "Gopalapuram Mandalam", "Gopannapalem", "Gulbarga",
"Gummidipundi", "Guntur", "Haliyal", "Hassan", "Hindupur", "Hoskote",
"Hospet", "Hosur", "Humnabad", "Huvinahadagali", "Huzurnagar",
"Hyd", "Hyderabad", "HYDERABAD", "Iluppur", "INDRAKARAN VILLAGE",
"Jamkhandi", "Jogipet", "KAKINADA", "Kakinada (Urban)", "Kamalapuram",
"Kamareddy", "Kanakapura", "Kanayannur", "Kanchipuram", "Kariapatti",
"Karkala", "Karthikappally", "Karunagapally", "Karur", "Karwar",
"Khairatabad", "Khammam", "KOCHI", "Kondapalli", "Koppal", "Kothakota",
"KOTHUR", "Kovvur", "Kozhikode", "Krishna", "Krishnagiri", "Kunigal",
"Kunnathunad", "Kurnool", "Lalgudi", "Laveru Mandal", "Luxettipet",
"Maddur", "Madurantakam", "MAHESWARAM MANDAL", "Malur", "Mamidikuduru",
"Manachanallur", "Manapparai", "Mandapeta", "Mangalore", "MANGALORE",
"Mangapet", "Mannargudi", "Manugurq", "Manuguru", "Mayiladuthurai",
"Medikonduru", "Melur", "Mettupalayam", "Mettur", "Miryalguda",
"Muddebihal", "Mudhol", "Mukundapuram", "Musheerabad", "Muthukur",
"Mysore", "MYSORE", "NA", "Nagapattinam", "Naidupeta", "Nalgonda",
"NALGONDA", "Nampally", "Nanguneri", "Nanjangud", "Narsapur",
"Narsipatnam", "Nedumangad", "Nedungadu Commune Panchayat", "Nelamangala",
"Nellore", "Nilakkottai", "Ongole", "Palakkad", "Paloncha", "Palwancha",
"Paravada", "Paravur", "Patancheru", "PATHANAMTHITTA", "Pedagantyada",
"Peddapalli", "Peddapuram", "Pennagaram", "Perambur Purasawalkam",
"Periyakulam", "Pollachi", "Pondicherry", "Ponneri", "Prathipadu",
"Pusapatirega", "Qutubullapur", "R.c.puram", "Radhapuram", "Raichur",
"Rajahmundry (Urban)", "Ramagundam", "Ramanagara", "Ramanathapuram",
"Ramdurg", "Ranasthalam Mandal", "Ranebennur", "RANGA REDDY",
"Rangareddy", "Renigunta", "Saidabad", "Saidapet", "Salem", "Samalkota",
"Sandur", "Sangareddy", "Sankari", "Sathankulam", "Sathyamangalam",
"Secunderabad", "Sedam", "Shahapur", "Shaikpet", "Singanamala",
"Sira", "Sirpur (t)", "Sivakasi", "Somwarpet", "SRIKAKULAM",
"Sriperumbudur", "SRIPERUMBUDUR", "Stn. Jadcherla", "Sullurpeta",
"Suryapet", "SURYAPET", "Tada", "TADA", "Tadipatri", "Tallarevu",
"Tambaram", "Tanuku", "Tanuku (mdl)", "Thanjavur", "Tharangambadi",
"Thimmajipet", "Thirumalairayan Pattinam Commune Panchayat",
"Thiruvananthapuram", "Thiruvidaimarudur", "Thondamanadu", "Thoothukkudi",
"Tindivanam", "Tiruchendur", "Tiruchengodu", "TIRUCHIRAPALLI",
"Tirukkoyilur", "Tiruklalikundram", "Tirumalagiri", "Tirunelveli",
"Tiruvallur", "Tiruvannamalai", "Tiruvidamarudur", "Tumkur",
"Tuni", "TUTICORIN", "Udupi", "Uppal", "Uppalaguptam", "Vaikom",
"Vedaranyam", "Vedasandur", "Veepangandla", "Vemula", "Venkatachalam",
"Vepada", "Villianur Commune Panchayat", "Vinjamoor", "Virudhachalam",
"Virudhunagar", "Virur", "VISAKHAPATNAM", "Vontimitta", "Walajapet",
"Yerraguntla", "Zaheerabad"), class = "factor"), Freq = c(1,
1, 1, 4.33333333333333, 1.16666666666667, 1)), row.names = c(NA,
6L), class = "data.frame")
我遇到类似的错误
地址解析错误(freq $ mycities [1]):is.character(location)不是 是
答案 0 :(得分:1)
我认为这是因为google API发生了变化,多数民众赞成在使用它时会导致此错误:
地址解析失败,状态为OVER_QUERY_LIMIT
如果将source
更改为dsk
并转换为字符,则应该可以:
geocode(as.character(freq$mycities[1]), source = "dsk")
来自URL的信息: http://www.datasciencetoolkit.org/maps/api/geocode/json?address=Alamanda%20Rs&sensor=false
lon lat
1 -54 -30