Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在R中通过ggmap包获取邮政编码数据集_R_Ggmap - Fatal编程技术网

如何在R中通过ggmap包获取邮政编码数据集

如何在R中通过ggmap包获取邮政编码数据集,r,ggmap,R,Ggmap,通过使用geocode('Zip')我可以得到位置坐标。 给定坐标,我能得到那个位置的邮政编码吗? 比如说 geocode('130022,长春') 这给了我家乡的坐标。130022是邮政编码,长春 这就是城市。通过这样做,我想得到唯一的地理坐标长春 城市,这是(125.35,43.86364)。 如果我给出了坐标,我如何才能取回邮政编码数据呢?使用revgeocode() 如果需要更多详细信息,请指定output='all' res <- revgeocode(location = c

通过使用
geocode('Zip')
我可以得到位置坐标。 给定坐标,我能得到那个位置的邮政编码吗? 比如说

geocode('130022,长春')
这给了我家乡的坐标。130022是邮政编码,长春 这就是城市。通过这样做,我想得到唯一的地理坐标长春 城市,这是(125.35,43.86364)。 如果我给出了坐标,我如何才能取回邮政编码数据呢?

使用
revgeocode()

如果需要更多详细信息,请指定
output='all'

res <- revgeocode(location = c(125.35, 43.8634), output = 'all')

str(res)
# List of 2
# $ results:List of 6
# ..$ :List of 5
# .. ..$ address_components:List of 6
# .. .. ..$ :List of 3
# .. .. .. ..$ long_name : chr "Jun Zhuan Hu Tong"
# .. .. .. ..$ short_name: chr "Jun Zhuan Hu Tong"
# .. .. .. ..$ types     : chr "route"
# .. .. ..$ :List of 3
# .. .. .. ..$ long_name : chr "Nanguan Qu"
# .. .. .. ..$ short_name: chr "Nanguan Qu"
# .. .. .. ..$ types     : chr [1:3] "political" "sublocality" "sublocality_level_1"
# .. .. ..$ :List of 3
# .. .. .. ..$ long_name : chr "Changchun Shi"
# .. .. .. ..$ short_name: chr "Changchun Shi"
# .. .. .. ..$ types     : chr [1:2] "locality" "political"
# .. .. ..$ :List of 3
# .. .. .. ..$ long_name : chr "Jilin Sheng"
# .. .. .. ..$ short_name: chr "Jilin Sheng"
# .. .. .. ..$ types     : chr [1:2] "administrative_area_level_1" "political"
# ... etc
res
res <- revgeocode(location = c(125.35, 43.8634), output = 'all')

str(res)
# List of 2
# $ results:List of 6
# ..$ :List of 5
# .. ..$ address_components:List of 6
# .. .. ..$ :List of 3
# .. .. .. ..$ long_name : chr "Jun Zhuan Hu Tong"
# .. .. .. ..$ short_name: chr "Jun Zhuan Hu Tong"
# .. .. .. ..$ types     : chr "route"
# .. .. ..$ :List of 3
# .. .. .. ..$ long_name : chr "Nanguan Qu"
# .. .. .. ..$ short_name: chr "Nanguan Qu"
# .. .. .. ..$ types     : chr [1:3] "political" "sublocality" "sublocality_level_1"
# .. .. ..$ :List of 3
# .. .. .. ..$ long_name : chr "Changchun Shi"
# .. .. .. ..$ short_name: chr "Changchun Shi"
# .. .. .. ..$ types     : chr [1:2] "locality" "political"
# .. .. ..$ :List of 3
# .. .. .. ..$ long_name : chr "Jilin Sheng"
# .. .. .. ..$ short_name: chr "Jilin Sheng"
# .. .. .. ..$ types     : chr [1:2] "administrative_area_level_1" "political"
# ... etc