[postgis-devel] Uses of PostGIS 2.0 Topology?

Sandro Santilli strk at keybit.net
Mon Oct 24 00:37:43 PDT 2011


On Sun, Oct 23, 2011 at 01:31:52PM -0400, maplabs at light42.com wrote:

> The very first thing I wanted to use a topology for, was for land
> use analysis.. Count and compare.. Using standard PostGIS geometry
> to compare against a topologically consistant model.. I asked strk
> about the operators to do this briefly, and got disconcerting
> answers.. Topology it seems, is in its own world.

It's indeed easy to mix topologically-defined and simple geometries,
so you might have misunderstood what I told you (where, btw ?)

In PostGIS topology we have an implicit cast from TopoGeometry to
Geometry so any operation on Geometry (unary or binary) will be
available to TopoGeometry objects as well.

See these examples:

  =# select st_area(topo_geom)
     from topo_235._v_suolo_235_topo order by id limit 1;
  1456.43505859375
  
  
  =# select st_extent(topo_geom) from topo_235._v_suolo_235_topo;
  BOX(1604079.14890306 4890600,1620125.44 4904599.51)
  
  =# select count(id) from topo_235._v_suolo_235_topo
     where topo_geom && 'BOX(1615000 4890600,1636500 4904599)'::box2d;
  567
  
  =# select count(id) from topo_235._v_suolo_235_topo:
  1723
  
  =# \d topo_235._v_suolo_235_topo
  id|character varying(35)|
  topo_geom|topology.topogeometry|
  
  
  =# select topology.topologysummary('topo_235');
  Topology topo_235 (1294), SRID 4326, precision 0
  4896 nodes, 5687 edges, 1723 faces, 7410 topogeoms in 2 layers
  Layer 1, type Lineal (2), 5687 topogeoms
   Deploy: topo_235._v_linee_elementari_235_topo.topo_geom
  Layer 2, type Polygonal (3), 1723 topogeoms
   Deploy: topo_235._v_suolo_235_topo.topo_geom

You probably missed the TopoGeometry part completely. This is an additional
abstraction level over the base SQL/MM topology model. I don't think the
TIGER importer makes use of that level (yet). The full model (including
the additional abstraction) is documented in the topology/ folder 
(there's also an ER diagram) and on the postgis wiki.

You're welcome to enhance the wiki with anything you find undocumented
(hopefully not much).

--strk;

  ()   Free GIS & Flash consultant/developer
  /\   http://strk.keybit.net/services.html



More information about the postgis-devel mailing list