在R中以几何格式转换表格式

问题描述

我只从数据库中提取了前两行。它采用表格格式,我想将其转换为几何格式(精确地为SF格式)。我对几何数据的处理知识很少。

df <- structure(list(geo_shape = c("{\"type\": \"Polygon\",\"coordinates\": [[[5.338315871184333,48.454965608365434],[5.352256779224244,48.45748017019558],[5.356867659649554,48.45861272223076],[5.370024462133918,48.441016094245384],[5.405569613196442,48.43914862965481],[5.415928061547558,48.431728673093616],[5.439381211779697,48.42679332254185],[5.444199380880549,48.428035237878305],[5.445944000842286,48.42484001047907],[5.455491195985311,48.4225185412161],[5.464657397091936,48.425352681093734],[5.468365530391375,48.42368241532468],[5.47004819517617,48.420929121711794],[5.465176866111291,48.41999538465838],[5.447147987326301,48.41497730281626],[5.409778594398087,48.3926106292164],[5.408032022516386,48.39578741775774],[5.40566901841934,48.40233397230922],[5.408554486817462,48.406010702893404],[5.381714974275032,48.415130518910686],[5.364561043252318,48.42722847189931],[5.365845831983447,48.43053301922544],[5.360187985333197,48.43584796495667],[5.331724869023629,48.430857645862986],[5.326376374855521,48.43651583877311],[5.330644859085079,48.446143323969885],[5.326111768828245,48.45222639592987],[5.334305718325071,48.453937534132834],[5.338315871184333,48.454965608365434]]]}","{\"type\": \"Polygon\",\"coordinates\": [[[3.505427731949752,45.640237683009346],[3.50519896080469,45.65034231639286],[3.495829620784017,45.66222554163975],[3.504789423481917,45.670209200943994],[3.507908911579412,45.67282464175393],[3.5202167693257422,45.674443403124194],[3.530494003723245,45.6678398023463],[3.53381404087812,45.66183576768132],[3.531416235839427,45.65553458489732],[3.531074298770266,45.652015234286026],[3.524797579564321,45.6386902338926],[3.526413181690557,45.63173983145512],[3.521344327827282,45.63186248025302],[3.505427731949752,45.640237683009346]]]}"
    ),ZipCode = c("52288","63065"),Populaton = c(113,156)),row.names = c(NA,-2L),class = c("tbl_df","tbl","data.frame"))

输出:

# A tibble: 2 x 3
  geo_shape                                                                                                                              ZipCode Populaton
  <chr>                                                                                                                                  <chr>       <dbl>
1 "{\"type\": \"Polygon\",[5.35686~ 52288         113
2 "{\"type\": \"Polygon\",[3.495829~ 63065         156

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...