Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/72.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中的几何格式_R_Dplyr_Geometry_Coordinates_Sf - Fatal编程技术网

将表格格式转换为r中的几何格式

将表格格式转换为r中的几何格式,r,dplyr,geometry,coordinates,sf,R,Dplyr,Geometry,Coordinates,Sf,我只从数据库中提取了前两行。它是表格格式,我想把它转换成几何格式(sf格式)。我对几何数据的处理知之甚少 df <- structure(list(geo_shape = c("{\"type\": \"Polygon\", \"coordinates\": [[[5.338315871184333, 48.454965608365434], [5.352256779224244, 48.45748017019558],

我只从数据库中提取了前两行。它是表格格式,我想把它转换成几何格式(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"))

df感谢@william3031的修改您的几何体数据似乎是geojson格式。使用类似于
df$geo_shape@Z.Lin的东西,我有相同的geojson格式的数据。但这是从excel格式导入的,因为我不知道如何处理geosjson文件。但是当我尝试你的代码时,它不起作用。我收到了以下错误消息:
错误:C堆栈使用量15924624太接近极限
它对我有效。这是操作系统问题吗?也许是文件长度@SeydouGORO先在几行上尝试一下?感谢您对@William3031的修改您的几何数据似乎是geojson格式的。使用类似于
df$geo_shape@Z.Lin的东西,我有相同的geojson格式的数据。但这是从excel格式导入的,因为我不知道如何处理geosjson文件。但是当我尝试你的代码时,它不起作用。我收到了以下错误消息:
错误:C堆栈使用量15924624太接近极限
它对我有效。这是操作系统问题吗?也许是文件长度@SeydouGORO先试穿几排?
# A tibble: 2 x 3
  geo_shape                                                                                                                              ZipCode Populaton
  <chr>                                                                                                                                  <chr>       <dbl>
1 "{\"type\": \"Polygon\", \"coordinates\": [[[5.338315871184333, 48.454965608365434], [5.352256779224244, 48.45748017019558], [5.35686~ 52288         113
2 "{\"type\": \"Polygon\", \"coordinates\": [[[3.505427731949752, 45.640237683009346], [3.50519896080469, 45.65034231639286], [3.495829~ 63065         156