PostGIS,更新表,设置“ true”在具有相同ID的最大区域
我在Postgres/Postgis中有一个表格,其中包含以下列: ID(PK),官方ID,AREANAME,IS_MAINAREA(BOOL),GEOM(Polygon) 数据中的行可能具有相同的名称和官方身份证,但几乎不同。具有相同名称和ID的“主要区域”有一个或多个次要的“卫星区域”。 示例:
Id officialId areaname is_mainarea geom
3034 217044 Boda false POLYGON(xxxx)
4381 217044 Boda false POLYGON(xxxx)
4382 217044 Boda false POLYGON(xxxx)
3047 217026 Djura false POLYGON(xxxx)
4516 217026 Djura false POLYGON(xxxx)
我想做的是更新表格,以便具有相同官方ID的最大区域的行在is_mainarea中具有“ true”。因此,在上面的示例中,IS_MainaRea应该在ID 3034和2047上行时。
是否可以使用SQL进行此操作?
I have a table in Postgres/PostGis with the following columns:
Id (PK), officialId, areaname, is_mainarea (bool), geom (Polygon)
The rows in the data could have the same name and official id, but different geom. There are one or more minor "satellite areas " to a "main area" that have the same name and id.
Example:
Id officialId areaname is_mainarea geom
3034 217044 Boda false POLYGON(xxxx)
4381 217044 Boda false POLYGON(xxxx)
4382 217044 Boda false POLYGON(xxxx)
3047 217026 Djura false POLYGON(xxxx)
4516 217026 Djura false POLYGON(xxxx)
What I want to do is to update the table so that the row with the largest area of the ones with the same official id has "true" in is_mainarea. So, in the example above is_mainarea should be true on row with Id 3034 and 2047.
Is there a way to do this with just SQL?
Example of polygons. I would need to find a way to set is_mainarea=true for the larger of the polygons with the same officialid.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可以通过以下对Netanels的调整来解决:
I got it to work with the following adjustment to Netanels answer:
该查询应该为您提供帮助:
That query should help you: