6

このサブクエリを実行していることに気づきました

SELECT ST_Area(ST_Union(ST_Transform(ST_Intersection((SELECT poly1.the_geom from poly1 WHERE poly1.polygon_type ='P')、poly2.the_geom)、3857)))

AS area_of_P FROM poly1、poly2

この結合を実行するよりも大幅に遅い

SELECT ST_AREA(ST_Union(ST_Transform(ST_Intersection(poly1.the_geom、poly2.the_geom)、3857)))

AS area_of_poly

FROM poly2

st_intersects(poly1.the_geom、poly2.the_geom)のLEFT JOIN poly1

WHERE poly2.polygon_type ='P'

ただし、この2番目に結合されたバージョンを拡張して、より多くの列を返す必要があります。各列には、特定のポリゴンタイプの面積が計算されます。

SELECT ST_Area(ST_Union(ST_Transform(ST_Intersection((SELECT poly1.the_geom from poly1 WHERE poly1.polygon_type ='P')、poly2.the_geom)、3857)))AS area_of_P、

ST_Area(ST_Union(ST_Transform(ST_Intersection((SELECT poly1.the_geom from poly1 WHERE poly1.polygon_type ='S')、poly2.the_geom)、3857)))AS area_of_S

FROM poly1、poly2

4

1 に答える 1

7

これを試して。

SELECT ST_AREA(ST_Union(ST_Transform(ST_Intersection(poly1.the_geom,poly2.the_geom),3857)))

AS area_of_poly

FROM poly2

LEFT JOIN poly1 on st_intersects(poly1.the_geom,poly2.the_geom)

WHERE poly2.polygon_type IN ( 'P', 'S' )

編集:

SELECT ST_AREA(ST_Union(ST_Transform(ST_Intersection(ps.the_geom,poly2.the_geom),3857))) AS area_of_P,
       ST_AREA(ST_Union(ST_Transform(ST_Intersection(ss.the_geom,poly2.the_geom),3857))) AS area_of_S
FROM poly2
JOIN poly1 ps ON poly2.polygon_type = 'P' AND st_intersects(ps.the_geom,poly2.the_geom)
JOIN poly1 ss ON poly2.polygon_type = 'S' AND st_intersects(ss.the_geom,poly2.the_geom)
于 2012-06-23T08:02:53.217 に答える