]> www.wagner.pp.ru Git - sites/home_page.git/blob - geography/fGIS/topology.html
Added fGIS
[sites/home_page.git] / geography / fGIS / topology.html
1 <HTML>
2 <HEAD>
3 <TITLE>
4  Creating topology from raster
5 </TITLE>
6 <BODY>
7
8
9 [<A HREF=index.html><I>f(</I><B>GIS</B><I>)</I> home</A>]
10 [<A HREF=EPU.html>EPU</A>]
11 <HR>
12 <H1>Creating topology from raster and vice versa</H1>
13 <!--CONTENT NUMBERED BACKREFS--><OL>
14 <LI><A NAME="toc_entry0"></A><A HREF="#toc_section0">Generation of polygon labels</A>
15 <LI><A NAME="toc_entry1"></A><A HREF="#toc_section1">Generation of vector topology from raster</A>
16 <LI><A NAME="toc_entry2"></A><A HREF="#toc_section2">Rasterizing polygon coverages</A>
17 </OL>
18 <!-- END CONTENT -->
19
20 <A NAME="toc_section0"></A><A HREF="#toc_entry0"><H3>Generation of polygon labels</H3></A>
21 <A HREF=EPU.html>EPU</A> border command should have option to generate
22 polygon labels along with polygon boundaries.
23 <P>
24 This would allow to import polygon maps into vector-based systems like
25 Arc/Info and also have some additional applications like plotting barchart
26 and piecharts on the map.
27 <P>
28 Currently both EPPL7 and Arc/Info are able to generate polygon labels
29 given raster map (EPPL7) or correct set of polygon boundaries (ARC/Info).
30 But their algorithms both have shortcomings. EPPL7 always and Arc/Info in case
31 of polygon with complex shape put label point too close to polygon boundary.
32 <P>
33 While it can be bearable if sole purpose of this label point is to identify
34 polygon in vector topology map, it is not good for plotting charts other 
35 possible applications of label points.
36 <P>
37 So following algorithm is proposed:
38 <OL>
39 <LI> Generate unique numbers for polygons (EPU <B>cluster</b> command
40      already can do this)
41 <LI> Calculate distance of each raster cell to nearest polygon boundary
42      (combination of EPPL7  <B>border</B>(epp) and <B>radius</B> commands 
43      can do this and
44       EPU <B>thiessen</B> command eventually would)
45  
46 <LI> Find out maximal distance from boundaries for each polygon
47     (<B>outtable</B> command)
48 <LI> Retrieve coordinates of any point with given distance and polygon
49      ID and use it as label point. (can be done with EPPL7
50      <B>intable</B> and  <B>evaluate</B> and is trivial thing if coded
51      in C.
52 </OL>
53
54 Analysis of this algorithm shows that it can be performed using at most
55 two passes over raster, given that all intermediate structures are kept
56 in memory.
57 <P>
58 <I>First pass</I> perform cluster and radius operations in parallel. 
59 Write three intermediate rasters, two of which contain low and high half-words of uniquie polygon numbers and third - distance to boundaries. During
60 this pass table of maximal distance for each polygon should be accumulated.
61 <P>
62 <I>Second pass</I> Find a point for each entry of polygon-distance table and
63 write its coordinates along with polygon ID.
64 <P>
65
66 <A NAME="toc_section1"></A><A HREF="#toc_entry1"><H3>Generation of vector topology from raster</H3></A>
67
68 Vector topology as used by arc/info consist of following parts
69 <OL>
70   <LI> No arc in coverage should intersect each other
71   <LI> Each polygon should have exactly one label
72   <LI> Each arc should have atributes denoting left and right polygons.
73   <LI> Each point where arcs are joined (node) should have a record
74       which lists IDs of arcs joined in it.
75 </OL>
76 If we are building polygon coverage from file, generated via EPPL7 or EPU
77 <B>border</B> commands, constraints 1 and 2 are ensured by border algorithm.
78 If we are using algorithm described above, for label points, we have
79 enough information to assign left and right polygon IDs for any polyline
80 (arc), provided that polylines are generated on second pass of above algorithm.
81 <P>
82 So, only thing we need is to create list of nodes. It is also much simplier
83 to do during raster scan, than processing vector file, becouse while we are
84 passing location of node, we have all lines joined here at hand, while in
85 the vector file they can be very far from each other, becouse lines which
86 <I>starts</I> at this node would be written to the file only when they would
87 <I>end</I>.
88 <P>
89 The only thing which prevents me (and possible other authors of raster-based GIS) to export ready to use topology to ARC/Info instead of exporting GEN files
90 and requiring user to do time-consuming CLEAN or BUILD operation, is closeness of ARC/Info export format.
91 <A NAME="toc_section2"></A><A HREF="#toc_entry2"><H3>Rasterizing polygon coverages</H3></A>
92
93 EPPL7 <B>rasterize</B> command operates on non-topological vector files.
94 Therefore it have to do three passes over file and often leave small
95 holes which have to be eliminated using <b>fill</B> command. But it works
96 very fast and have (especially in incarnation of EPU <B>cluster</B> command)
97 almost no limitation concerning raster size and polygon complexity.
98 <P>
99 ARC/Info <B>polygrid</B> command produces raster without holes, but it works
100 very slowly (it seems that it scans entire vector file for each point of 
101 generated raster. In PC Arc/Info 3.5 it also have some very restrictive size
102 limitation (5000x5000) and doesn't understand EPPL format correctly (doesn't
103 write coordinate information into header, doesn't support 16-bit rasters).
104 <P>
105 But combining of these two algorithms can produce rasterization algorithm
106 which would be even faster than EPPL7 rasterize and work without holes.
107 <P>
108 Idea is that while drawing lines from vector file in the raster (as EPPL
109 does on the first pass) we plot each line two-cell wide, giving left cell
110 value of left polygon and right cell value of right polygon. The only thing
111 left is  to fill remaining parts of file by color of nearest non-offsite
112 point, which is guarantied to be same for all surrounding lines, due to
113 ARC/Info topology.
114 <P>
115 This algorithm can be implemented without knowledge of ARC/Info propieritary
116 formats, becouse lines from coverage along with their unique IDs can
117 be legitimately exported into open GEN format, and arc attribute table,
118 which contains IDs of right and left polygons can be exported into RDBMS,
119 as well as polygon attribute table which contain information we really
120 want to plot.
121
122
123 </BODY>
124 </HTML>
125    
126
127
128