[postgis-users] area resulting from ST_Within

Paragon Corporation lr at pcorp.us
Sun Sep 21 14:44:14 PDT 2008


Try
 
 
SELECT ws.name <http://ws.name/> ,dt.name <http://dt.name/> ,
sum(ST_area(ST_intersection(ws.the_geom,dt.the_geom)))/sum(st_area(ws.the_ge
om)) As pct
FROM  watersheds as ws, districts as dt
WHERE ST_intersects(ws.the_geom,dt.the_geom)
GROUP BY ws.name <http://ws.name/> ,dt.name <http://dt.name/> 
ORDER BY dt.name <http://dt.name/> 

  _____  

From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of surya
Sent: Sunday, September 21, 2008 12:42 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] area resulting from ST_Within


Dear Fred,
 
Thank you very much. It works correctly !!. I try to further convert the
area of  each district in a watershed as percentage to the watershed area in
question. Please give me more help.
 
best regards,
 
surya

----- Original Message ----- 
From: Fred Lehodey <mailto:lehodey at gmail.com>  
To: PostGIS Users  <mailto:postgis-users at postgis.refractions.net> Discussion

Sent: Sunday, September 21, 2008 4:35 PM
Subject: Re: [postgis-users] area resulting from ST_Within

Hi Surya,
you can try something like that:
 
SELECT ws.name,dt.name,
sum(ST_area(ST_intersection(ws.the_geom,dt.the_geom)))
FROM  watersheds as ws, districts as dt
WHERE ST_intersects(ws.the_geom,dt.the_geom)
GROUP BY ws.name,dt.name
ORDER BY dt.name
 
Fred.
 


 
On Sun, Sep 21, 2008 at 3:37 AM, surya <storma-ipb at indo.net.id> wrote:


Dear List,

I have two  tables, one table contains   5 polygons depicting 5 watersheds
or river basin boundaries. Another table contain district bondaries. Using
ST-contain function below, I have obtained districts belong to a certain
watershed . My qestion is how to calculate area of each district contained
in a certain watershed using sum(area)(), taking into consideration that one
district might be splitted in two or more different watershed

SELECT watersheds.name <http://watersheds.name/> , districts.name
<http://districts.name/> 
FROM watersheds, districts
WHERE ST_contains (watersheds.the_geom, districts.the_geom)
GROUP BY watersheds.name <http://watersheds.name/> , districts.name
<http://districts.name/>  ;

best regards,

surya

_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users





  _____  




_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20080921/9ca4f7b0/attachment.html>


More information about the postgis-users mailing list