非英文地址字母导致 geocode() 到 return NA
non-english address letters causes geocode() to return NA
我正在使用来自 r-bloggers.com 的 this 配方来绘制基本地图。
geocode() returns "NA" 我试图绘制的几个地址。所有返回 "NA" 的地址都有一个共同属性,即它们包含丹麦语字母“æ、Æ、ø、Ø、å、Å”,所以我强烈怀疑这就是导致我出现问题的原因。
返回地址 "Eskærvej 50, 5700 Svendborg, denmark"
的错误消息
cannot open URL 'http://maps.googleapis.com/maps/api/geocode/json?
address=Esk%E6rvej%2050,%205700%20Svendborg,%20denmark&sensor=false': HTTP
status was '400 Bad Request'
2: In FUN(X[[i]], ...) :
geocoding failed for "Eskærvej 50, 5700 Svendborg, denmark".
if accompanied by 500 Internal Server Error with using dsk, try google.
你知道解决这个问题的方法吗?
我的代码中的示例:
# CREATE DATA FRAME
df.svendborg_locations <- tibble(location = c("Belvedere 60, 5700 Svendborg, denmark"
,"Fruerstuevej 17 B, 5700 Svendborg, denmark"
,"Enghavevej 40, 5700 Svendborg, denmark"
,"Engdraget 2, 5700 Svendborg, denmark"
,"Belvedere 54, 5700 Svendborg, denmark"
,"Eskærvej 50, 5700 Svendborg, denmark"
,"Lundbyvej 43, 5700 Svendborg, denmark"
,"Eskærvej 63 B, 5700 Svendborg, denmark"
,"Skovbrynet 1, 5700 Svendborg, denmark"
,"Wiggers Park 201, 5700 Svendborg, denmark"
,"Hellet 3, 5700 Svendborg, denmark"
,"Gambøtvej 2, 5700 Svendborg, denmark"
,"Oluf Rings Vej 19, 5881 Skårup Fyn, denmark"
,"Rantzausmindevej 172 C, 5700 Svendborg"))
# GEOCODE
geo.svendborg_locations <- geocode(df.svendborg_locations$location)
# COMBINE DATA
df.svendborg_locations <- cbind(df.svendborg_locations, geo.svendborg_locations)
会话信息
sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=Danish_Denmark.1252 LC_CTYPE=Danish_Denmark.1252 LC_MONETARY=Danish_Denmark.1252 LC_NUMERIC=C
[5] LC_TIME=Danish_Denmark.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggmap_2.6.1 gganimate_0.1.0.9000 gridExtra_2.3 dplyr_0.7.3 purrr_0.2.3 readr_1.1.1
[7] tidyr_0.7.1 tibble_1.3.4 ggplot2_2.2.1 tidyverse_1.1.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.13 lubridate_1.6.0 lattice_0.20-35 png_0.1-7 assertthat_0.2.0 digest_0.6.12 psych_1.7.8 mime_0.5
[9] R6_2.2.2 cellranger_1.1.0 plyr_1.8.4 httr_1.3.1 RgoogleMaps_1.4.1 rlang_0.1.2 lazyeval_0.2.0 readxl_1.0.0
[17] geosphere_1.5-7 miniUI_0.1.1 proto_1.0.0 labeling_0.3 stringr_1.2.0 foreign_0.8-69 munsell_0.4.3 shiny_1.0.5
[25] broom_0.4.2 compiler_3.4.1 httpuv_1.3.5 modelr_0.1.1 pkgconfig_2.0.1 mnormt_1.5-5 htmltools_0.3.6 grid_3.4.1
[33] nlme_3.1-131 jsonlite_1.5 xtable_1.8-2 gtable_0.2.0 magrittr_1.5 scales_0.5.0 stringi_1.1.5 mapproj_1.2-5
[41] reshape2_1.4.2 bindrcpp_0.2 sp_1.2-5 xml2_1.1.1 rjson_0.2.15 tools_3.4.1 forcats_0.2.0 glue_1.1.1
[49] maps_3.2.0 hms_0.3 jpeg_0.1-8 parallel_3.4.1 yaml_2.1.14 colorspace_1.3-2 rvest_0.3.2 ggExtra_0.7
[57] knitr_1.17 bindr_0.1 haven_1.1.0
使用enc2utf8
geo.svendborg_locations <- geocode(enc2utf8(df.svendborg_locations$location))
这对我有用,尽管我在测试中遇到了速率限制...
使用 OP 的代码,我得到了 5 行 NA
s,伴随着 500
错误代码。
使用 enc2utf8
,我得到 2 行 NA
s,均有错误 geocode failed with status OVER_QUERY_LIMIT, location = "Lundbyvej 43, 5700 Svendborg, denmark"
我正在使用来自 r-bloggers.com 的 this 配方来绘制基本地图。
geocode() returns "NA" 我试图绘制的几个地址。所有返回 "NA" 的地址都有一个共同属性,即它们包含丹麦语字母“æ、Æ、ø、Ø、å、Å”,所以我强烈怀疑这就是导致我出现问题的原因。
返回地址 "Eskærvej 50, 5700 Svendborg, denmark"
的错误消息cannot open URL 'http://maps.googleapis.com/maps/api/geocode/json?
address=Esk%E6rvej%2050,%205700%20Svendborg,%20denmark&sensor=false': HTTP
status was '400 Bad Request'
2: In FUN(X[[i]], ...) :
geocoding failed for "Eskærvej 50, 5700 Svendborg, denmark".
if accompanied by 500 Internal Server Error with using dsk, try google.
你知道解决这个问题的方法吗?
我的代码中的示例:
# CREATE DATA FRAME
df.svendborg_locations <- tibble(location = c("Belvedere 60, 5700 Svendborg, denmark"
,"Fruerstuevej 17 B, 5700 Svendborg, denmark"
,"Enghavevej 40, 5700 Svendborg, denmark"
,"Engdraget 2, 5700 Svendborg, denmark"
,"Belvedere 54, 5700 Svendborg, denmark"
,"Eskærvej 50, 5700 Svendborg, denmark"
,"Lundbyvej 43, 5700 Svendborg, denmark"
,"Eskærvej 63 B, 5700 Svendborg, denmark"
,"Skovbrynet 1, 5700 Svendborg, denmark"
,"Wiggers Park 201, 5700 Svendborg, denmark"
,"Hellet 3, 5700 Svendborg, denmark"
,"Gambøtvej 2, 5700 Svendborg, denmark"
,"Oluf Rings Vej 19, 5881 Skårup Fyn, denmark"
,"Rantzausmindevej 172 C, 5700 Svendborg"))
# GEOCODE
geo.svendborg_locations <- geocode(df.svendborg_locations$location)
# COMBINE DATA
df.svendborg_locations <- cbind(df.svendborg_locations, geo.svendborg_locations)
会话信息
sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=Danish_Denmark.1252 LC_CTYPE=Danish_Denmark.1252 LC_MONETARY=Danish_Denmark.1252 LC_NUMERIC=C
[5] LC_TIME=Danish_Denmark.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggmap_2.6.1 gganimate_0.1.0.9000 gridExtra_2.3 dplyr_0.7.3 purrr_0.2.3 readr_1.1.1
[7] tidyr_0.7.1 tibble_1.3.4 ggplot2_2.2.1 tidyverse_1.1.1
loaded via a namespace (and not attached):
[1] Rcpp_0.12.13 lubridate_1.6.0 lattice_0.20-35 png_0.1-7 assertthat_0.2.0 digest_0.6.12 psych_1.7.8 mime_0.5
[9] R6_2.2.2 cellranger_1.1.0 plyr_1.8.4 httr_1.3.1 RgoogleMaps_1.4.1 rlang_0.1.2 lazyeval_0.2.0 readxl_1.0.0
[17] geosphere_1.5-7 miniUI_0.1.1 proto_1.0.0 labeling_0.3 stringr_1.2.0 foreign_0.8-69 munsell_0.4.3 shiny_1.0.5
[25] broom_0.4.2 compiler_3.4.1 httpuv_1.3.5 modelr_0.1.1 pkgconfig_2.0.1 mnormt_1.5-5 htmltools_0.3.6 grid_3.4.1
[33] nlme_3.1-131 jsonlite_1.5 xtable_1.8-2 gtable_0.2.0 magrittr_1.5 scales_0.5.0 stringi_1.1.5 mapproj_1.2-5
[41] reshape2_1.4.2 bindrcpp_0.2 sp_1.2-5 xml2_1.1.1 rjson_0.2.15 tools_3.4.1 forcats_0.2.0 glue_1.1.1
[49] maps_3.2.0 hms_0.3 jpeg_0.1-8 parallel_3.4.1 yaml_2.1.14 colorspace_1.3-2 rvest_0.3.2 ggExtra_0.7
[57] knitr_1.17 bindr_0.1 haven_1.1.0
使用enc2utf8
geo.svendborg_locations <- geocode(enc2utf8(df.svendborg_locations$location))
这对我有用,尽管我在测试中遇到了速率限制...
使用 OP 的代码,我得到了 5 行 NA
s,伴随着 500
错误代码。
使用 enc2utf8
,我得到 2 行 NA
s,均有错误 geocode failed with status OVER_QUERY_LIMIT, location = "Lundbyvej 43, 5700 Svendborg, denmark"