PostGIS Topology: Difference between revisions
m (→Comparison) |
m (→Comparison) |
||
Line 46: | Line 46: | ||
|- | |- | ||
|nlines,lines,angles || containing_face, geom(Point) | |nlines,lines,angles || containing_face, geom(Point) | ||
|- | |||
|colspan=2 style="text-align: center" | '''Edge''' | |||
|- | |||
| | |||
| start/end node, next left/right edge, left/right face, geom (LineString) | |||
|- | |||
|colspan=2 style="text-align: center" | '''Line''' | |||
|- | |||
|start/end node | |||
| | |||
|- | |||
|colspan=2 style="text-align: center" | '''Boundary''' | |||
|- | |||
|start/end node, left/right area | |||
| | |||
|- | |||
|colspan=2 style="text-align: center" | '''Centroid''' | |||
|- | |||
|area | |||
| | |||
|- | |||
|colspan=2 style="text-align: center" | '''Face''' | |||
|- | |||
| | |||
|mbr(Polygon) | |||
|- | |||
|colspan=2 style="text-align: center" | '''Area''' | |||
|- | |||
|nlines,lines,nisles,isle,centroid | |||
| | |||
|- | |||
|colspan=2 style="text-align: center" | '''Isle''' | |||
|- | |||
|nlines,lines,area | |||
| | |||
|- | |- | ||
|} | |} | ||
== PostGIS Topology implementation for GRASS GIS == | == PostGIS Topology implementation for GRASS GIS == |
Revision as of 09:16, 21 July 2013
PostGIS Topology allows to store topological vector data in PostGIS database. It's available in PostGIS 2.0 and later. GRASS GIS supports PostGIS Topology in version GRASS 7.0 and later through GRASS-PostGIS data provider.
Background
Topological models used by GRASS GIS and PostGIS Topology are different - see below.
GRASS GIS Topology Data Model
In the GRASS GIS data model are defined various topological elements:
- nodes - 0D elements
- For each node is defined which lines/boundaries starts and ends in this node.
- lines - 1D elements which cannot form areas
- For each line is defined a start and end node.
- boundaries - 1D elements which can form areas
- For each boundary is defined a start and end node, and an area on the left and right.
- centroids - point located inside area
- For each centroid is defined an area
- areas - 2D elements formed by closed set of boundaries and optionally by one centroid located inside the area
- For each area is defined the list of boundaries which forms the area (outer ring), and the list of isles located inside the area.
- isle - 2D elements formed by areas
- For each isle is defined the list of boundaries which forms the isle (it's outer ring), and optionally by the area where the isle is located.
For other info and examples, see programmer's manual.
PostGIS Topology Model
PostGIS Topology model is based on ISO standard 13249. The model defines only topological elements:
- nodes - 0D elements
- Is defined by geometry (point) and by the face where the node is located (can be NULL)
- edges - 1D elements
- Is defined by geometry (linestring), start and end node, next left and right edge (ie. connectivity) and by the face on the left and right.
- faces - 2D elements
- Is defined by bounding box.
PostGIS Topology validation: see for example here
Comparison
GRASS GIS | PostGIS Topology |
---|---|
Nodes | |
nlines,lines,angles | containing_face, geom(Point) |
Edge | |
start/end node, next left/right edge, left/right face, geom (LineString) | |
Line | |
start/end node | |
Boundary | |
start/end node, left/right area | |
Centroid | |
area | |
Face | |
mbr(Polygon) | |
Area | |
nlines,lines,nisles,isle,centroid | |
Isle | |
nlines,lines,area |
PostGIS Topology implementation for GRASS GIS
- Points are stored as isolated nodes (containing_face is null)
- Centroids are stored as isolated nodes (containing_case is not null)
- Lines are stored as edges (left_face and right_face is 0)
- Boundaries are stored edges
- Areas are stored as faces (with id > 0)
- Isles are stored as faces (with id <= 0) (including universal face defined by PostGIS Topology)
Currently the areas and isles are build from GRASS Topology. It's planned to add to the PostGIS Topology model information about areas and isles:
- new table 'areas'
- new table 'isles'
GRASS also stores important metadata in 'topology.grass' table, currently only bounding box for the map.
SELECT * from topology.grass; topology_id | bbox -------------+--------------------------------------------------------------------------------- ... 767 | BOX3D(264003.759398496 55720.5513784461 0,654141.604010025 270194.235588972 0) ...
Example
In GRASS native format:
| Number of points: 0 Number of centroids: 2 | | Number of lines: 0 Number of boundaries: 4 | | Number of areas: 3 Number of islands: 2 |
Topology dump for native GRASS format (v.build):
Nodes (3 nodes, alive + dead): node = 1, n_lines = 3, xyz = 100.000000, 0.000000, 0.000000 line = 3, type = 4, angle = 0.000000 (0.0000) line = 2, type = 4, angle = 1.570796 (90.0000) line = 1, type = 4, angle = 3.141593 (180.0000) node = 2, n_lines = 3, xyz = 100.000000, 100.000000, 0.000000 line = -2, type = 4, angle = -1.570796 (270.0000) line = -3, type = 4, angle = 0.000000 (0.0000) line = -1, type = 4, angle = 3.141593 (180.0000) node = 3, n_lines = 2, xyz = 110.000000, 25.000000, 0.000000 line = 6, type = 4, angle = 0.000000 (0.0000) line = -6, type = 4, angle = 1.570796 (90.0000) ----------------------------------- Lines (6 lines, alive + dead): line = 1, type = 4, offset = 18, n1 = 1, n2 = 2, left = -1, right = 1 line = 2, type = 4, offset = 87, n1 = 1, n2 = 2, left = 1, right = 2 line = 3, type = 4, offset = 124, n1 = 1, n2 = 2, left = 2, right = -1 line = 4, type = 8, offset = 193, area = 1 line = 5, type = 8, offset = 222, area = 2 line = 6, type = 4, offset = 251, n1 = 3, n2 = 3, left = 3, right = -2 ----------------------------------- Areas (3 areas, alive + dead): area = 1, n_lines = 2, n_isles = 0 centroid = 4 line = 1 line = -2 area = 2, n_lines = 2, n_isles = 1 centroid = 5 line = 2 line = -3 isle = 2 area = 3, n_lines = 1, n_isles = 0 centroid = 0 line = -6 ----------------------------------- Islands (2 islands, alive + dead): isle = 1, n_lines = 2 area = 0 line = -1 line = 3 isle = 2, n_lines = 1 area = 2 line = 6
In PostGIS Topology model will be this example stored as
- 3 nodes (n1, n2, n3)
SELECT node_id,containing_face,st_astext(geom) from topo_example.node; node_id | containing_face | st_astext ---------+-----------------+------------------------------------------ 1 | | POINT(452944.862155388 246704.260651629) 2 | | POINT(453966.165413534 122105.263157895) 3 | | POINT(475413.533834587 128233.082706767)
- 4 edges (3, 4, 5, 6)
SELECT edge_id,next_left_edge,next_right_edge,left_face,right_face,st_geometrytype(geom) from topo_example.edge; edge_id | next_left_edge | next_right_edge | left_face | right_face | st_geometrytype ---------+----------------+-----------------+-----------+------------+----------------- 1 | -4 | 3 | 0 | 1 | ST_LineString 2 | 2 | -2 | 2 | 1 | ST_LineString 3 | -1 | 4 | 1 | 3 | ST_LineString 4 | -3 | 1 | 3 | 0 | ST_LineString
- 3 faces (two areas and one hole)
SELECT face_id,st_geometrytype(mbr) from topo_example.face; face_id | st_geometrytype ---------+----------------- 0 | 1 | ST_Polygon 2 | ST_Polygon 3 | ST_Polygon
See also
- v.out.postgis manual
- Working with external data in GRASS 7 and v.external.out manual
- PostGIS support in GRASS GIS
External links
GRASS GIS:
- GRASS GIS Topology manual
PostGIS:
- http://trac.osgeo.org/postgis/wiki/UsersWikiSimplifyWithTopologyExt
- PostGIS Topology manual
- PostGIS Topology wiki page
- State of the art of FOSS4G for topology and network analysis (FOSS4G 2010)
- strk's page about PostGIS
- PostGIS topology ISO SQL/MM complete (strk's blog)
- Simplifying a map layer using PostGIS topology (strk's blog)
Concepts:
- Topo-Geo-and-Topo-Net - The Concepts • Routine Details
- ISO 13249-3 Information Technology - Database languages - SQL Multimedia and application packages (Text for FDIS)