PostGIS Topology: Porovnání verzí

Z GeoWikiCZ
m (Obsah stránky nahrazen textem „{{freegiswiki|PostGIS Topology}}“)
 
(Není zobrazeno 15 mezilehlých verzí od stejného uživatele.)
Řádek 1: Řádek 1:
{{Upravit}}
{{freegiswiki|PostGIS Topology}}
 
[http://trac.osgeo.org/postgis/wiki/UsersWikiPostgisTopology PostGIS Topology] je rozšíření pro [[PostGIS]] umožňující ''topologickou'' správu vektorových dat v prostředí PostGIS/[[PostgreSQL]].
 
Více přednášky [[153UZPD#Přednášky|Úvod do zpracování prostorových dat]].
 
== Příklad ==
 
Data z [[Cvičná databáze PostGIS|cvičné databáze]] <tt>pgis_student</tt>.
 
<source lang=sql>
CREATE SCHEMA my_schema;
SET search_path TO my_schema,public,topology,gis1;
</source>
 
=== Feature table 'tm50_cr' ===
 
<source lang=sql>
CREATE TABLE tm50_cr AS SELECT DISTINCT k.ogc_fid,k.tm50,k.geom FROM kltm50 AS k JOIN obce AS o ON ST_Overlaps(k.geom, o.geom);
SELECT COUNT(*) FROM tm50_cr;
</source>
 
<pre>
count
-------
  289
(1 row)
</pre>
 
[[Image:tm50-qgis-sf.png|640px|thumb|center|Klad mapových listu TM50 (území ČR)]]
 
=== Vytvoření topologického schématu 'tm50_cr' ===
 
* [http://postgis.org/documentation/manual-svn/CreateTopology.html CreateTopology()]
 
<source lang=sql>
SELECT topology.createtopology('tm50_cr', 2065, 1);
</source>
 
''Argumenty:''
* 2065 (EPSG)
* 1 (přesnost v mapových jednotkách, tj. v tomto případě v metrech)
 
<source lang=sql>
SELECT * from topology.topology;
</source>
 
<pre>
id |  name    | srid | precision | hasz
----+-----------+------+-----------+------
  1 | tm50_cr  | 2065 |        1 | f
</pre>
 
\dt tm50_cr.
 
<pre>
          List of relations
Schema  |  Name    | Type  |  Owner 
---------+-----------+-------+---------
tm50_cr | edge_data | table | postgis
tm50_cr | face      | table | postgis
tm50_cr | node      | table | postgis
tm50_cr | relation  | table | postgis
(4 rows)
</pre>
 
=== Přidání atributu topologie do feature table ===
 
* [http://postgis.org/documentation/manual-svn/AddTopoGeometryColumn.html AddTopoGeometryColumn()]
 
<source lang=sql>
select topology.AddTopoGeometryColumn('tm50_cr', 'my_schema', 'tm50_cr', 'topo', 'POLYGON');
</source>
 
<source lang=sql>
SELECT * FROM topology.layer;
</source>
 
<pre>
topology_id | layer_id | schema_name | table_name | feature_column | feature_type | level | child_id
-------------+----------+-------------+------------+----------------+--------------+-------+----------
          1 |        1 | my_schema  | tm50_cr    | topo          |            3 |    0 |       
</pre>
 
''Poznámka:'' <tt>feature_type</tt> '3' odpovídá 'face' (1 - node, 2 - edge).
 
=== Sestavení topologie (Geometry &rarr; TopoGeometry) ===
 
* [http://postgis.org/documentation/manual-svn/toTopoGeom.html toTopoGeom()]
 
<source lang=sql>
UPDATE tm50_cr set topo = topology.toTopoGeom(geom, 'tm50_cr', 1);
SELECT tm50,topo from tm50_cr limit 3;
</source>
 
<pre>
  tm50    |    topo   
-----------+------------
M-33-29-D | (10,1,1,3)
M-33-30-C | (10,1,2,3)
M-33-30-D | (10,1,3,3)
(3 rows)
</pre>
 
Počet uzlů:
 
<source lang=sql>
SELECT count(*) from tm50_cr.node;
</source>
<pre>
count
-------
  313
(1 row)
</pre>
 
Počet hran:
 
<source lang=sql>
SELECT count(*) from tm50_cr.edge_data;
</source>
<pre>
count
-------
  601
(1 row)
</pre>
 
Počet stěn:
 
<source lang=sql>
SELECT count(*) from tm50_cr.face;
</source>
<pre>
count
-------
  290
(1 row)
</pre>
 
== Externí odkazy ==
 
* [http://2010.foss4g.org/presentations/3555.pdf State of the art of FOSS4G for topology and network analysis]
* [http://www.postgis.org/documentation/manual-svn/Topology.html PostGIS 2.0 Topology section of manual]
* [http://cs.wikipedia.org/wiki/Topologie Topogie] {{bullet}} [http://cs.wikipedia.org/wiki/Sedm_most%C5%AF_m%C4%9Bsta_Kr%C3%A1lovce Sedm mostů města Královce] {{bullet}} [http://en.wikipedia.org/wiki/Geographic_information_system#Topological_modeling Topological modeling]
* [http://cs.wikipedia.org/wiki/Geografick%C3%BD_informa%C4%8Dn%C3%AD_syst%C3%A9m#Vektorov.C3.A9_modely Vektorové modely]
* [http://strk.keybit.net/projects/postgis/ strk's page about PostGIS]
* [http://strk.keybit.net/blog/2011/10/14/postgis-topology-iso-sqlmm-complete/ PostGIS topology ISO SQL/MM complete]
 
{{Databáze}}
{{GIS}}
{{GFOSS}}

Aktuální verze z 9. 1. 2013, 10:50

Stránky přesunuty na Free GIS Portál: http://geo.fsv.cvut.cz/freegis/PostGIS_Topology