将每个多线链转换为仅一个linestring
在此 8168547,8171738,8170616,8169920 )是多inineString的。
我需要将每个多界线转换为一个linestring。 我尝试过很多事情,但没有任何事情可以。例如,我在R中的SF软件包中尝试了st_cast
。但是,它增加了行的数量(它将每个多线线转换为几个线条)。
如何仅将每个多线线转换为一个细分线?
In this shapefile, the geometry column is linestring apart from 4 stream reaches (8168547, 8171738, 8170616 ,8169920
) that are multilinestring.
I need to convert each multilinestring to one linestring only .
I have tried many things but none worked. For example, I tried st_cast
in sf package in R. However, it increased the number of the rows (it converts each multilinestring to several linestrings).
How can I convert each multilinestring to one linestring only?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在geopandas中,可以用 :
in geopandas, this can be done with
explode
:正如您提到的那样,将多in子转换为线索的
{sf}
通过sf :: st_cast()
,将是通过sf :: ST_CAST()。
但是您的数据存在问题 - 某些流无法进入简单的线条。 linestring必须具有一个起点和一个终点 - 对于某些RCHID来说,这根本是不可能的。结果,您的某些对象最终被复制。
由于这是一个普遍的失败 - 而不是特定的故障 - 我希望该评论对地理杂物也有效,尽管我没有运行代码来验证。
我建议首先将您的对象投入到线林中,然后识别重复物并将其过滤掉。
The
{sf}
way of converting multilinestrings to linestrings would be, as you mention, viasf::st_cast()
.But there is a problem with your data - some of the streams are not possible to make into simple linestrings. A linestring must have a single start and a single end point - this is simply not possible for some of your rchids. As a result some of your objects end up being duplicated.
As this is a general failure - and not a R specific one - I would expect the comment to be valid also for geopandas, although I have not ran the code to verify.
I suggest first casting your object to linestrings, then identifying duplicites and filtering them out.
在Geopandas中,您可以合并Linesements。如果您的多轨道干净,则段的方向相同,并且对它们进行了正确的分类。您可以尝试这样的事情:(
但可能您必须首先清洁您的细分市场:))
In geopandas you can merge linesegments. If your multilinestring is clean, segments have the same direction and they are properly sorted. You can try something like that:
(But probably you have to clean your segments first :))