我有一个任务,使用GEOCODE()函数从R返回坐标(lon,lat)。所有的一切都顺利地使用了API和安装包等等。
但是,在测试坐标时,我注意到R返回了short (lon,lat),例如,对于'LV-2114‘R返回的是短版本:
> geocode("LV-2114", output = "latlon", "latlona", source="google",
full_results = TRUE, return_type = 'geographies',method = 'census')
#> A tibble: 1 x 2
#> lon lat
#> 23.9 56.8对于"LV-2114“项目,lat应该是(23.94453,56.79256)。我输入的其他地方也是如此。
我很确定这是我犯的错误。如何返回长坐标?
发布于 2020-10-21 13:44:19
您所遇到的错误只是print.tibble的默认行为,它舍入数值。
df <- geocode("LV-2114", output = "latlon", "latlona", source="google",
full_results = TRUE, return_type = 'geographies',method = 'census')
as.data.frame(df)[,, drop=T]
#> $lon
#> [1] 23.94453
#>
#> $lat
#> [1] 56.79256
# or
as.matrix(df)
#> lon lat
#> [1,] 23.94453 56.79256
#> [2,] 23.94453 2.00000当您要在计算中使用Ti球内的值时,它将使用非舍入值,只有当打印值被舍入时。
https://stackoverflow.com/questions/64463798
复制相似问题