如何计算两个多边形的重叠·区域

查看PDF手册有方法如下:
8.10.13 ST_Intersection
ST_Intersection — (T) Returns a geometry that represents the shared portion of geomA and geomB. The geography implementation
does a transform to geometry to do the intersection and then transform back to WGS84.
Synopsis
geometry ST_Intersection( geometry geomA , geometry geomB );
geography ST_Intersection( geography geogA , geography geogB );
Description
Returns a geometry that represents the point set intersection of the Geometries.
In other words - that portion of geometry A and geometry B that is shared between the two geometries.
If the geometries do not share any space (are disjoint), then an empty geometry collection is returned.
ST_Intersection in conjunction with ST_Intersects is very useful for clipping geometries such as in bounding box, buffer, region
queries where you only want to return that portion of a geometry that sits in a country or region of interest.


示例如下:
CREATE TABLE testintersection
(
  geom geometry(Polygon,4326),
  gid serial NOT NULL
);
insert into testIntersection values(st_geomfromtext('POLYGON((110 30,110 31, 111 31, 111 30, 110 30))',4326));
insert into testIntersection values(st_geomfromtext('POLYGON((110.5 30.5,110.5 31.5, 111.5 31.5, 111.5 30.5, 110.5 30.5))',4326));
insert into testIntersection select ST_Intersection(st_geomfromtext('POLYGON((110 30,110 31, 111 31, 111 30, 110 30))',4326), st_geomfromtext('POLYGON((110.5 30.5,110.5 31.5, 111.5 31.5, 111.5 30.5, 110.5 30.5))',4326));

使用QGIS查看效果如下





猜你喜欢

转载自flyqantas.iteye.com/blog/2260878