[postgis-users] Method to remove overlaps in a layer
Sandro Santilli
strk at keybit.net
Mon Mar 19 13:47:22 PDT 2012
On Mon, Mar 19, 2012 at 02:16:30PM -0400, Pierre Racine wrote:
> > You should really be constructing a topology out of that dataset, you know ?
> > Will be probably slow but I'm sure you can survive :)
>
> So what would be the normal/easiest steps to convert a messy polygon coverage into a clean topology? Is it documented somewhere?
>
> My guess:
>
> 1- SET search_path TO topology,public;
You shouldn't need this, when you load topology.sql you should
get "topology" already appended to the end of the search_path
associated with the database.
> 2- SELECT CreateTopoGeom('test')
Yep.
> 3- SELECT toTopoGeom(geom, 'test', 1)
> FROM mymessyone;
You didn't create a layer, see AddTopoGeometryColumn.
The third argument is a layer id, as returned by that function.
> or
>
> SELECT ST_CreateTopoGeo('test', geom)
> FROM mymessyone;
This one only works starting with an empty topology so
you'll need to pass it a full collection:
SELECT ST_CreateTopoGeo('test', ST_Collect(geom)) FROM mymessyone;
But I'd recommend using toTopoGeom instead, to keep the linking
between attributes and geometries.
> What happens when a polygon to be added to the topology overlaps a polygon already in the topology?
Two overlapping rectangles would produce a total of 3 faces.
If you're returning TopoGeometry objects (your step 2) both
of them will be defined by 2 faces, having one face in common.
--strk;
,------o-.
| __/ | Delivering high quality PostGIS 2.0 !
| / 2.0 | http://strk.keybit.net - http://vizzuality.com
`-o------'
More information about the postgis-users
mailing list