将自定义谷歌地图后面的 json 导入 R

时间:2021-02-03 00:03:20

标签: r json google-maps-api-3 geojson sf

我想将这个谷歌地图后面的 shapefile 导入到 R 中: https://motoneiges.ca/magazines/motoneiges/cartes/carte.jsp

我找到了这个 JSON,它似乎是它背后的来源: https://mca.viaexplora.com/db/graphSentiersSS.json

我已使用 jsonlite::fromJSON 将其读入 R,但所有内容都显示为已编码,我不确定如何处理它。

test <- fromJSON("graphSentiersSS.json")
str(test)
List of 7
 $ : int 2
 $ : chr "I2loB2m4CI| __truncated__
 $ : chr "BdItBqAI"| __truncated__
 $ : chr [1:4] "DI66tcrI137Bz"| __truncated__ 
               "DB74slI14sB16__truncated__
               "DB5wGFGHHFHGHHFHGFHACGFHHGHHHHHGJAFAFG"| __truncated__ 
               "DIzFGFACHGGFGFHFGHCA"| __truncated__
 $ :List of 14
 $ :List of 200
  .. [list output truncated]
 $ : num 3e-06

将 "googlePolylines::decode()" 应用到它的部分“有点工作”,因为它返回了一些东西,但所有的纬度/经度都在 0 度纬度 0 度经度附近

test2 <- googlePolylines::decode(test[[2]])
> test2
[[1]]
            lat           lon
1    0.00005000 -1.000000e-04
2   -0.01794000 -2.000000e-04
3   -0.01451000 -1.800000e-04
4   -0.01446000 -2.900000e-04
5    0.00372000 -4.000000e-04
6    0.05790000  1.900000e-04
7    0.05976000  1.500000e-04
8    0.05981000  5.000000e-05
...

这就是我放弃的地方。

0 个答案:

没有答案