简体   繁体   English

PostGIS几何数据库查询

[英]PostGIS geometry database query

I have several tables that contain multipolygons. 我有几个包含多面体的表。 I need to find points within these polygons that I can use in my java test class. 我需要在这些多边形中找到可以在Java测试类中使用的点。 What I have been doing is sending a query to return all the multi polygons, choose a vertex to use as a point, and most times it works. 我一直在做的是发送一个查询以返回所有的多面体,选择一个顶点作为点,大多数情况下它可以工作。

However these tables represent risk data, 1 in 100, 1 in 200 etc, and so some of the points are shared between tables (the higher risk multi polygons are encapsulated by the lower risk). 但是,这些表代表风险数据,每100个中有1个,在200中有1个,依此类推,因此表之间共享一些点(较高风险的多面体由较低风险封装)。 what query can I use to return a point that will be within 1 multipolygon in 1 table, but not in any others that I specify? 我可以使用什么查询来返回一个点,该点将在1个表中的1个多面体之内,但不在我指定的任何其他点中?

the tables are river_100_1k, river_200_1k, and river_1000_1k 这些表是river_100_1k,river_200_1k和river_1000_1k

Well you could do a multiple left join: 好吧,您可以进行多个左联接:

SELECT a.gid, a.the_geom FROM pointsTable a
LEFT JOIN river_100_1k b 
ON ST_Intersects(a.the_geom, b.the_geom)
LEFT JOIN 
river_200_1k c
ON NOT ST_Intersects(a.the_geom, c.the_geom) -- Not Intersects
LEFT JOIN
river_1000_1k d 
ON NOT ST_Intersects(a.the_geom, d.the_geom) -- Not Intersects
WHERE 
AND c.gid IS NULL AND d.gid IS NULL AND b.gid=2 AND c.gid=2 AND d.gid=2 ; 

I'm not sure if I understand correctly but this is the path you should take. 我不确定我是否理解正确,但这是您应该采取的方法。

使用ST_PointOnSurface(polygon)获取ST_PointOnSurface(polygon)的点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM