[postgis-users] Newbie question on SQL

Nicolas Ribot nicky666 at gmail.com
Fri Jan 5 00:33:38 PST 2007


Hi Sean,

You should first intersect your tables to create a new one, with the
attributes you want to keep from them, then dissolve the generated
polygons based on attributes (group by clause).

Something like

create table t3 as (
select t1.attribute1, t2.attribute2, ..., intersection(t1.the_geom,
the2.the_geom) as the_geom
from t1, t2
where t1.the_geom && t2.the_geom AND
intersects(t1.the_geom, t2.the_geom)
)

Then, dissolve based on attributes
create table t4 as (
select t3.attribute1, t3.attribute2, geomunion(t3.the_geom) as the_geom from t3
group by t3.attribute1, t3.attribute2, ...
)

You can use a single query (I think) or temporary tables instead of
creating real tables.

Also, bear in mind that t1 and t2 must have the same SRID (same
spatial reference system), otherwise, you will have to perform a
transform() operation on one of the tables.

Hope that helps

Nicolas

On 1/4/07, Sean Grimland <skgstyle at yahoo.com> wrote:
> Hi all,
>
> I am new to Postgis and SQL so please forgive the
> newbie question.  I have 2 polygon tables that I want
> to, using SQL, intersect and then dissolve based on 2
> attributes to produce a new polygon table.
>
> Thanks in advance,
>
> Sean Grimland
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>



More information about the postgis-users mailing list