[postgis-users] Preparing for Topology - St_CreateTopoGeo

Chris English sglish at hotmail.com
Fri Dec 2 19:53:16 PST 2011


Exito!! (well, nearly so) 

select topology.st_createtopogeo('union_cty_topo',ST_Collect(geom)) from summit_parcels;<a smaller portion, 6800+/- of the prior 147,000 county>"Topology union_cty_topo populated"

create table union_cty_topo.summit_parcels(gid serial primary key, pams_pin varchar(38), cost smallint);


NOTICE:  CREATE TABLE will create implicit sequence "summit_parcels_gid_seq" for serial column "summit_parcels.gid"NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "summit_parcels_pkey" for table "summit_parcels"Query returned successfully with no result in 438 ms.

(we're doing this live here and where I'm certain to mess it up...)So, variation 1:select topology.addtopogeometrycolumn('union_cty_topo','union_cty_topo','summit_parcels', 'topo','POLYGON');

select topology.addtopogeometrycolumn('union_cty_topo','union_cty_topo','summit_parcels', 'topo','POLYGON');Total query runtime: 250 ms.1 row retrieved.

Variation 2:select topology.addtopogeometrycolumn('summit_topo','union_cty_topo','summit_parcels', 'topo','POLYGON');

ERROR:  Topology summit_topo does not exist  -- just something I was wondering about in process- don"t go here

(so, I'm going go painfully plod along, because most of us have to plod, rather than seamlessly and deftlyperceive the obvious next steps as Leo or Regina would, whose style and directness guide 10.Topology as bestI can make out, and hence I plod..)

At this point, I have checked my various tables in <database>. <your-database.edge, your_database.node,your-database.face> and indeed they have data/stuff. 

The table previously created, (in my case) union-cty_topo.summit_parcels has no data. Neither does union_cty_topo.relation

I assume these await the next step for plodders of topology, as seen  in Postgis 2.0.0 Manual of operations10.8 - Topology Constructors - and given that (fortuitously) I seem to be in the best of all possible worlds, ie.=

select topology.addtopogeometrycolumn('union_cty_topo','union_cty_topo','summit_parcels', 'topo','POLYGON');Total query runtime: 250 ms.1 row retrieved.

I am going to blithely go forward using (something very close to this, if I can figure it out, again from10.8 Topology Constructors):

update our column assuming 
-- everything is perfectly aligned with our edges
UPDATE boston.blockgroups AS bg
	SET topo = topology.CreateTopoGeom('topo_boston'
        ,3,1
        , foo.bfaces)
FROM (SELECT b.gid,  topology.TopoElementArray_Agg(ARRAY[f.face_id,3]) As bfaces
	FROM boston.blockgroups As b
            INNER JOIN topo_boston.face As f ON b.geom && f.mbr
        WHERE ST_Covers(b.geom, topology.ST_GetFaceGeometry('topo_boston', f.face_id))
            GROUP BY b.gid) As foo
WHERE foo.gid = bg.gid; 
well, I can't figure out how to get rid o the beige lines, but I'm thinking that something like that is my target as I am somewhat reassured by myprior select ~~1 row retrieved that I have arrived in a golden space wherein after, if I can get it right, the above code will serve mypurposes;I will review, for myself:schema-- union_cty_topotablename-- summit_parcelstg_type-- 3 (polygon)layer_id-- 1
(And frankly, at this point I have to say my understanding gets hazy due to the Inner Join, but what they hay...)so, I'm thinking it'll be something like (in my case, your mileage may vary):

update union_cty_topo.summit_parcels as sp   -- sp is  summit_parcels	set topo = topology.createtopoGeom('union_cty_topo',			3,1			, foo.sfaces)from (Select s.gid, topology.TopoElementaryArray_Agg(Array[f.face.id,3]) as sfaces		From union_cty_topo.summit_parcels as s			Inner Join union_cty_topo.face as f on s.topo && f.mbr -- a little confusion here 		where ST_Covers (s.geom, topology.ST_GetFaceGeometry('union_cty_topo', f.face_id))			Group by s.gid) as fooWhere foo.gid =sp.gid;
(which results in)ERROR:  schema "f" does not exist
And I've been troubled by this Inner Join thing and wondering how do I have something to Join againstif I don't have my first table in there yet which leads me back to thinking I should be following the RI esample toget my first table finally populated in the 'topo' column...ummmm...
or stuck at this point and tired...no presenta como exito, que pena, adelante manana, por supuesto
chris

---------------------------------------> From: sglish at hotmail.com
> To: postgis-users at postgis.refractions.net
> Date: Fri, 2 Dec 2011 13:56:43 -0500
> Subject: Re: [postgis-users] Preparing for Topology - St_CreateTopoGeo
>
>
> -I'm assuming all geometries in <your_testing_database> were
> -already converted to the new binary storage format of PostGIS-2.0.
> How does one test that it is in the new binary storage formatwhich I suspect has something to do with bytea.
> > Date: Fri, 2 Dec 2011 17:33:50 +0100
> > From: strk at keybit.net
> > To: postgis-users at postgis.refractions.net
> > Subject: Re: [postgis-users] Preparing for Topology - St_CreateTopoGeo
> >
> > On Fri, Dec 02, 2011 at 11:28:05AM -0500, Chris English wrote:
> >
> > > -- $Id: topology.sql.in.c 8239 2011-11-24 21:13:22Z strk $--Pretty recent in the scheme of things
> >
> > That numbre is not very meaningful on itself.
> > The code containing the recent bug fixes is in sql/sqlmm.sql
> > Anyway, just make sure to:
> > $ svn up
> > $ ./configure --with-topology
> > $ make && make check
> > $ psql -f topology/topology.sql <your_testing_database>
> >
> > I'm assuming all geometries in <your_testing_database> were
> > already converted to the new binary storage format of PostGIS-2.0.
> >
> > --strk;
> >
> > ,------o-.
> > | __/ | Thank you for PostGIS-2.0 Topology !
> > | / 2.0 | http://www.pledgebank.com/postgistopology
> > `-o------'
> >
> > _______________________________________________
> > 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
 		 	   		  


More information about the postgis-users mailing list