[英]postgis eliminate inner boundaries from polygons
I constructed a postgis table in PostgreSQL that cointains a set of polygons that are the result of joining many smaller polygons. 我在PostgreSQL中构建了一个postgis表,它包含了一组多边形,这些多边形是连接许多较小多边形的结果。 The result of the join is a polygon with an outer boundary and some of them have inner boundaries (polygons inside).
连接的结果是具有外边界的多边形,其中一些具有内边界(内部多边形)。 I like to remove the inner boundaries.
我喜欢删除内部边界。
The construction of the new table was with: 新表的构建是:
insert into dl_table
select 1 as id_level, 18 as id_sublevel,
ST_snaptogrid(ST_Union(geom),0.0001) as geom
from small_polygons_table
where id_sp in
(select id_sp from cdl where id_level=1 and id_sublevel=18);
and the result for geom is: 而geom的结果是:
<Polygon>
<outerBoundaryIs>
<LinearRing>
<coordinates>
...points...
</coordinates>
</LinearRing>
</outerBoundaryIs>
<innerBoundaryIs>
<LinearRing>
<coordinates>
...points...
</coordinates>
</LinearRing>
</innerBoundaryIs>
<innerBoundaryIs>
<LinearRing>
<coordinates>
...points...
</coordinates>
</LinearRing>
</innerBoundaryIs>
</Polygon>
Now I like to remove those inner boundaries. 现在我想删除那些内在的界限。
ST_Union()
will dissolve internal boundaries so are you sure that all coordinates are exactly the same? ST_Union()
将解散内部边界,所以你确定所有坐标都完全相同吗?
Your query is more commonly written with a JOIN
like this: 您的查询更常用
JOIN
编写,如下所示:
insert into dl_table
select id_level, id_sublevel, ST_snaptogrid(ST_Union(geom),0.0001) as geom
from small_polygons_table
join cdl using (id_sp)
where id_level = 1 and id_sublevel = 18;
Just for future reference for others finding this question: the problem here is that the source data doesn't include any topology. 仅供其他人发现此问题参考:此处的问题是源数据不包含任何拓扑。 There is no "magic" way of cleaning up overlapping polygons that shouldn't overlap, or gaps between polygons that should share a common boundary.
没有“神奇”的方法来清理不应重叠的重叠多边形,或者应该共享共同边界的多边形之间的间隙。 One option here is to do the
St_snaptogrid
before the ST_Union
, which will clean it up a bit at least, at the cost of loosing accuracy. 这里的一个选择是在
ST_Union
之前执行St_snaptogrid
,这将至少清除它一点,但代价是失去准确性。 But in the end it really depends on the source data and a lot of trial and error will be involved, and possibly manual work too. 但最终它确实取决于源数据,并且将涉及大量的反复试验,也可能涉及手动工作。 See https://gis.stackexchange.com/questions/31895/joining-lots-of-small-polygons-to-form-larger-polygon-using-postgis for more info.
有关详细信息,请参阅https://gis.stackexchange.com/questions/31895/joining-lots-of-small-polygons-to-form-larger-polygon-using-postgis 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.