避免评估错误:R SF包中的TopologyException错误

时间:2018-09-20 11:59:11

标签: r sf

我正在尝试学习R中的SF软件包的某些功能。
一个csv包含下面的多边形数据,这些数据具有5个相互重叠的多边形。

 "id","x"
    "1","POLYGON ((72.93023 19.11215, 72.93134 19.11321, 72.93244 19.11426, 72.93355 19.11531, 72.93466 19.11637, 72.93577 19.11742, 72.93586 19.11733, 72.93596 19.11723, 72.93605 19.11714, 72.93614 19.11704, 72.93623 19.11694, 72.93632 19.11684, 72.9364 19.11674, 72.93649 19.11664, 72.93657 19.11653, 72.93665 19.11643, 72.93672 19.11632, 72.9368 19.11621, 72.93687 19.1161, 72.93694 19.11599, 72.93701 19.11588, 72.93708 19.11577, 72.93715 19.11565, 72.93721 19.11554, 72.93727 19.11542, 72.93733 19.1153, 72.93739 19.11518, 72.93744 19.11506, 72.93749 19.11494, 72.93754 19.11482, 72.93759 19.1147, 72.93764 19.11458, 72.93768 19.11446, 72.93772 19.11433, 72.93776 19.11421, 72.9378 19.11408, 72.93783 19.11396, 72.93786 19.11383, 72.93789 19.1137, 72.93792 19.11358, 72.93794 19.11345, 72.93797 19.11332, 72.93799 19.11319, 72.93801 19.11306, 72.93802 19.11293, 72.93803 19.1128, 72.93804 19.11267, 72.93805 19.11254, 72.93806 19.11241, 72.93806 19.11228, 72.93806 19.11215, 72.93806 19.11202, 72.93806 19.11189, 72.93805 19.11176, 72.93804 19.11164, 72.93803 19.11151, 72.93802 19.11138, 72.93801 19.11125, 72.93799 19.11112, 72.93797 19.11099, 72.93794 19.11086, 72.93792 19.11073, 72.93789 19.11061, 72.93786 19.11048, 72.93783 19.11035, 72.9378 19.11023, 72.93776 19.1101, 72.93772 19.10998, 72.93768 19.10985, 72.93764 19.10973, 72.93759 19.10961, 72.93754 19.10949, 72.93749 19.10936, 72.93744 19.10924, 72.93739 19.10913, 72.93733 19.10901, 72.93727 19.10889, 72.93721 19.10877, 72.93715 19.10866, 72.93708 19.10854, 72.93701 19.10843, 72.93694 19.10832, 72.93687 19.10821, 72.9368 19.1081, 72.93672 19.10799, 72.93665 19.10788, 72.93657 19.10778, 72.93649 19.10767, 72.9364 19.10757, 72.93632 19.10747, 72.93623 19.10737, 72.93614 19.10727, 72.93605 19.10717, 72.93596 19.10708, 72.93586 19.10698, 72.93577 19.10689, 72.93567 19.1068, 72.93557 19.10671, 72.93547 19.10662, 72.93537 19.10653, 72.93526 19.10645, 72.93516 19.10637, 72.93505 19.10629, 72.93494 19.10621, 72.93483 19.10613, 72.93472 19.10605, 72.93461 19.10598, 72.9345 19.10591, 72.93438 19.10584, 72.93426 19.10577, 72.93415 19.1057, 72.93403 19.10564, 72.93391 19.10558, 72.93379 19.10552, 72.93366 19.10546, 72.93354 19.1054, 72.93288 19.10675, 72.93222 19.1081, 72.93155 19.10945, 72.93089 19.1108, 72.93023 19.11215))"
    "2","POLYGON ((72.93709 19.11588, 72.9358 19.11673, 72.93452 19.11759, 72.93324 19.11844, 72.93195 19.11929, 72.93067 19.12015, 72.93075 19.12025, 72.93083 19.12036, 72.93091 19.12046, 72.931 19.12056, 72.93109 19.12066, 72.93117 19.12076, 72.93126 19.12086, 72.93136 19.12096, 72.93145 19.12105, 72.93155 19.12114, 72.93164 19.12123, 72.93174 19.12132, 72.93184 19.12141, 72.93195 19.1215, 72.93205 19.12158, 72.93216 19.12166, 72.93226 19.12175, 72.93237 19.12182, 72.93248 19.1219, 72.93259 19.12198, 72.93271 19.12205, 72.93282 19.12212, 72.93294 19.12219, 72.93305 19.12226, 72.93317 19.12233, 72.93329 19.12239, 72.93341 19.12245, 72.93353 19.12251, 72.93365 19.12257, 72.93378 19.12263, 72.9339 19.12268, 72.93403 19.12273, 72.93415 19.12278, 72.93428 19.12283, 72.93441 19.12287, 72.93454 19.12292, 72.93467 19.12296, 72.9348 19.123, 72.93493 19.12304, 72.93506 19.12307, 72.93519 19.1231, 72.93532 19.12313, 72.93546 19.12316, 72.93559 19.12319, 72.93573 19.12321, 72.93586 19.12323, 72.936 19.12325, 72.93613 19.12327, 72.93627 19.12328, 72.9364 19.1233, 72.93654 19.12331, 72.93668 19.12331, 72.93681 19.12332, 72.93695 19.12332, 72.93709 19.12332, 72.93722 19.12332, 72.93736 19.12332, 72.9375 19.12331, 72.93763 19.12331, 72.93777 19.1233, 72.93791 19.12328, 72.93804 19.12327, 72.93818 19.12325, 72.93831 19.12323, 72.93845 19.12321, 72.93858 19.12319, 72.93872 19.12316, 72.93885 19.12313, 72.93898 19.1231, 72.93912 19.12307, 72.93925 19.12304, 72.93938 19.123, 72.93951 19.12296, 72.93964 19.12292, 72.93977 19.12287, 72.9399 19.12283, 72.94002 19.12278, 72.94015 19.12273, 72.94027 19.12268, 72.9404 19.12263, 72.94052 19.12257, 72.94064 19.12251, 72.94077 19.12245, 72.94089 19.12239, 72.941 19.12233, 72.94112 19.12226, 72.94124 19.12219, 72.94135 19.12212, 72.94147 19.12205, 72.94158 19.12198, 72.94169 19.1219, 72.9418 19.12182, 72.94191 19.12175, 72.94202 19.12166, 72.94212 19.12158, 72.94223 19.1215, 72.94233 19.12141, 72.94243 19.12132, 72.94253 19.12123, 72.94263 19.12114, 72.94272 19.12105, 72.94282 19.12096, 72.94291 19.12086, 72.943 19.12076, 72.94309 19.12066, 72.94318 19.12056, 72.94326 19.12046, 72.94334 19.12036, 72.94343 19.12025, 72.94351 19.12015, 72.94222 19.11929, 72.94094 19.11844, 72.93965 19.11759, 72.93837 19.11673, 72.93709 19.11588))"
    "3","POLYGON ((72.93709 19.11588, 72.93642 19.11453, 72.93576 19.11318, 72.9351 19.11183, 72.93444 19.11048, 72.93378 19.10913, 72.93365 19.10918, 72.93353 19.10924, 72.93341 19.1093, 72.93329 19.10936, 72.93317 19.10943, 72.93305 19.10949, 72.93294 19.10956, 72.93282 19.10963, 72.93271 19.1097, 72.93259 19.10978, 72.93248 19.10985, 72.93237 19.10993, 72.93226 19.11001, 72.93216 19.11009, 72.93205 19.11017, 72.93195 19.11026, 72.93184 19.11034, 72.93174 19.11043, 72.93164 19.11052, 72.93155 19.11061, 72.93145 19.1107, 72.93136 19.1108, 72.93126 19.11089, 72.93117 19.11099, 72.93109 19.11109, 72.931 19.11119, 72.93091 19.11129, 72.93083 19.11139, 72.93075 19.1115, 72.93067 19.1116, 72.93059 19.11171, 72.93052 19.11182, 72.93044 19.11193, 72.93037 19.11204, 72.9303 19.11215, 72.93023 19.11227, 72.93017 19.11238, 72.93011 19.1125, 72.93005 19.11261, 72.92999 19.11273, 72.92993 19.11285, 72.92988 19.11297, 72.92982 19.11309, 72.92977 19.11321, 72.92972 19.11333, 72.92968 19.11345, 72.92964 19.11358, 72.92959 19.1137, 72.92956 19.11382, 72.92952 19.11395, 72.92949 19.11407, 72.92945 19.1142, 72.92942 19.11433, 72.9294 19.11446, 72.92937 19.11458, 72.92935 19.11471, 72.92933 19.11484, 72.92931 19.11497, 72.9293 19.1151, 72.92928 19.11523, 72.92927 19.11536, 72.92926 19.11549, 72.92926 19.11562, 72.92925 19.11575, 72.92925 19.11588, 72.92925 19.11601, 72.92926 19.11614, 72.92926 19.11627, 72.92927 19.1164, 72.92928 19.11653, 72.9293 19.11665, 72.92931 19.11678, 72.92933 19.11691, 72.92935 19.11704, 72.92937 19.11717, 72.9294 19.1173, 72.92942 19.11742, 72.92945 19.11755, 72.92948 19.11768, 72.92952 19.1178, 72.92956 19.11793, 72.92959 19.11805, 72.92964 19.11818, 72.92968 19.1183, 72.92972 19.11842, 72.92977 19.11855, 72.92982 19.11867, 72.92987 19.11879, 72.92993 19.11891, 72.92999 19.11902, 72.93005 19.11914, 72.93011 19.11926, 72.93017 19.11937, 72.93023 19.11949, 72.9303 19.1196, 72.93037 19.11971, 72.93044 19.11982, 72.93052 19.11993, 72.93059 19.12004, 72.93067 19.12015, 72.93075 19.12025, 72.93083 19.12036, 72.93091 19.12046, 72.931 19.12056, 72.93109 19.12066, 72.93117 19.12076, 72.93126 19.12086, 72.93136 19.12096, 72.93145 19.12105, 72.93155 19.12114, 72.93265 19.12009, 72.93376 19.11904, 72.93487 19.11798, 72.93598 19.11693, 72.93709 19.11588))"
    "4","POLYGON ((72.93709 19.11588, 72.93567 19.11525, 72.93425 19.11462, 72.93283 19.11399, 72.93141 19.11336, 72.92999 19.11273, 72.92993 19.11285, 72.92988 19.11297, 72.92982 19.11309, 72.92977 19.11321, 72.92972 19.11333, 72.92968 19.11345, 72.92964 19.11358, 72.92959 19.1137, 72.92956 19.11382, 72.92952 19.11395, 72.92949 19.11407, 72.92945 19.1142, 72.92942 19.11433, 72.9294 19.11446, 72.92937 19.11458, 72.92935 19.11471, 72.92933 19.11484, 72.92931 19.11497, 72.9293 19.1151, 72.92928 19.11523, 72.92927 19.11536, 72.92926 19.11549, 72.92926 19.11562, 72.92925 19.11575, 72.92925 19.11588, 72.92925 19.11601, 72.92926 19.11614, 72.92926 19.11627, 72.92927 19.1164, 72.92928 19.11653, 72.9293 19.11665, 72.92931 19.11678, 72.92933 19.11691, 72.92935 19.11704, 72.92937 19.11717, 72.9294 19.1173, 72.92942 19.11742, 72.92945 19.11755, 72.92948 19.11768, 72.92952 19.1178, 72.92956 19.11793, 72.92959 19.11805, 72.92964 19.11818, 72.92968 19.1183, 72.92972 19.11842, 72.92977 19.11855, 72.92982 19.11867, 72.92987 19.11879, 72.92993 19.11891, 72.92999 19.11902, 72.93005 19.11914, 72.93011 19.11926, 72.93017 19.11937, 72.93023 19.11949, 72.9303 19.1196, 72.93037 19.11971, 72.93044 19.11982, 72.93052 19.11993, 72.93059 19.12004, 72.93067 19.12015, 72.93075 19.12025, 72.93083 19.12036, 72.93091 19.12046, 72.931 19.12056, 72.93109 19.12066, 72.93117 19.12076, 72.93126 19.12086, 72.93136 19.12096, 72.93145 19.12105, 72.93155 19.12114, 72.93164 19.12123, 72.93174 19.12132, 72.93184 19.12141, 72.93195 19.1215, 72.93205 19.12158, 72.93216 19.12166, 72.93226 19.12175, 72.93237 19.12182, 72.93248 19.1219, 72.93259 19.12198, 72.93271 19.12205, 72.93282 19.12212, 72.93294 19.12219, 72.93305 19.12226, 72.93317 19.12233, 72.93329 19.12239, 72.93341 19.12245, 72.93353 19.12251, 72.93365 19.12257, 72.93378 19.12263, 72.9339 19.12268, 72.93403 19.12273, 72.93415 19.12278, 72.93428 19.12283, 72.93441 19.12287, 72.93454 19.12292, 72.93467 19.12296, 72.9348 19.123, 72.93493 19.12304, 72.93506 19.12307, 72.93519 19.1231, 72.93532 19.12313, 72.93546 19.12316, 72.93559 19.12319, 72.93573 19.12321, 72.93586 19.12323, 72.936 19.12325, 72.93613 19.12327, 72.93627 19.12328, 72.9364 19.1233, 72.93654 19.12181, 72.93668 19.12033, 72.93681 19.11884, 72.93695 19.11736, 72.93709 19.11588))"
    "5","POLYGON ((72.9433 19.11168, 72.94093 19.11063, 72.93856 19.10958, 72.93619 19.10853, 72.93382 19.10748, 72.93145 19.10643, 72.93135 19.10662, 72.93126 19.10682, 72.93118 19.10702, 72.93109 19.10723, 72.93101 19.10743, 72.93094 19.10763, 72.93086 19.10784, 72.9308 19.10805, 72.93073 19.10825, 72.93067 19.10846, 72.93061 19.10867, 72.93056 19.10888, 72.93051 19.1091, 72.93046 19.10931, 72.93042 19.10952, 72.93039 19.10974, 72.93035 19.10995, 72.93032 19.11016, 72.9303 19.11038, 72.93027 19.1106, 72.93026 19.11081, 72.93024 19.11103, 72.93023 19.11125, 72.93023 19.11146, 72.93022 19.11168, 72.93023 19.1119, 72.93023 19.11211, 72.93024 19.11233, 72.93026 19.11255, 72.93027 19.11276, 72.9303 19.11298, 72.93032 19.11319, 72.93035 19.11341, 72.93038 19.11362, 72.93042 19.11384, 72.93046 19.11405, 72.93051 19.11426, 72.93056 19.11448, 72.93061 19.11469, 72.93067 19.1149, 72.93073 19.11511, 72.9308 19.11531, 72.93086 19.11552, 72.93094 19.11573, 72.93101 19.11593, 72.93109 19.11613, 72.93118 19.11634, 72.93126 19.11654, 72.93135 19.11674, 72.93145 19.11693, 72.93155 19.11713, 72.93165 19.11732, 72.93175 19.11752, 72.93186 19.11771, 72.93198 19.11789, 72.93209 19.11808, 72.93221 19.11827, 72.93233 19.11845, 72.93246 19.11863, 72.93259 19.11881, 72.93272 19.11899, 72.93286 19.11916, 72.933 19.11933, 72.93314 19.1195, 72.93328 19.11967, 72.93343 19.11983, 72.93358 19.12, 72.93374 19.12016, 72.93389 19.12031, 72.93405 19.12047, 72.93422 19.12062, 72.93438 19.12077, 72.93455 19.12092, 72.93472 19.12106, 72.93489 19.1212, 72.93507 19.12134, 72.93525 19.12147, 72.93543 19.12161, 72.93561 19.12174, 72.9358 19.12186, 72.93599 19.12198, 72.93618 19.1221, 72.93637 19.12222, 72.93656 19.12233, 72.93676 19.12244, 72.93696 19.12255, 72.93716 19.12265, 72.93736 19.12275, 72.93757 19.12285, 72.93777 19.12295, 72.93798 19.12303, 72.93819 19.12312, 72.9384 19.1232, 72.93861 19.12328, 72.93883 19.12336, 72.93904 19.12343, 72.93926 19.1235, 72.93948 19.12357, 72.9397 19.12363, 72.93992 19.12369, 72.94014 19.12374, 72.94036 19.12379, 72.94058 19.12384, 72.9408 19.12388, 72.94103 19.12392, 72.94125 19.12396, 72.94148 19.12399, 72.94171 19.12402, 72.94193 19.12404, 72.94216 19.12406, 72.94239 19.12159, 72.94262 19.11911, 72.94284 19.11663, 72.94307 19.11416, 72.9433 19.11168))"

我正在尝试将csv以上内容读入多边形,并找到最大重叠数。

library(sf)
poly <- st_read("meuse.csv", options = "GEOM_POSSIBLE_NAMES=x")     
i = st_intersection(st_sf(poly))

我在st_intersection线上出现错误,特别是在添加第5个多边形时

  

CPL_nary_intersection(x)中的错误:评估错误:   TopologyException:找到LINESTRING之间的非节点交集   (72.9354 19.117,72.9354 19.117)和LINESTRING(72.9354 19.1171,   72.9354 19.117)在72.935370932571573 19.117042503783921。

0 个答案:

没有答案