Lecture 4 - LSGI

9/28/2011
LSGI 521: Principles of GIS
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
Lecture 4:
Spatial Data Modelling in GIS
Dr. Bo Wu
[email protected]
@p y
Department of Land Surveying & Geo-Informatics
The Hong Kong Polytechnic University
Contents
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
1.
2.
3.
4.
5.
Learning outcomes
Vector model
Raster model
Comparison of vector and raster models
Modeling terrain surface using vector and
raster models
j
Modeling
g
6. Object-oriented
7. Network Modeling
9/28/2011
2
1
9/28/2011
Learning Outcomes
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• By the end of this lecture you should be able to:
– Provide a definition of spatial data model
– Explain
E l i h
how spatial
ti l objects
bj t are used
d tto create
t ad
data
t
model
– Distinguish between vectors and rasters
– Describe a spatial data model structure
– Explain how topology is stored in the model
– List the advantages and disadvantages of different
spatial data models
– Know how to model a network
9/28/2011
3
Spatial Objects
LSGI 521: Principles of GIS
9/28/2011
Lecture 4: Data Modelling
4
2
9/28/2011
Vector and Raster Spatial Data
LSGI 521: Principles of GIS
Vector View
Lecture 4: Data Modelling
Objects in Real World
Raster View
9/28/2011
5
Basic Types of Geographic Data Models
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Vector data model
• The basic logic unit in a
geographical context
corresponds
d tto a liline, e.g.
contour lines
• Raster (Tesselation) data
model
• The basic logic units is a
single cell or unit of space
in the mesh
• Hybrid data model
• Possesses characteristics
of both vector and raster
data model
• Others
9/28/2011
6
3
9/28/2011
Typical Vector Models
LSGI 521: Principles of GIS
•
•
•
•
•
Lecture 4: Data Modelling
Spaghetti Model
Chaincodes Model
GBF/DIME Model
Topologic Model
POLYVRT Model
9/28/2011
7
Spaghetti Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Each object on the map
becomes one logic
record in the digital file,
and is defined as strings
of x, y coordinates.
• The spaghetti model
remains the conceptual
map model - direct line
to line translation.
Spaghetti
p g
Noodles
9/28/2011
8
4
9/28/2011
Advantages & Disadvantages of Spaghetti Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Advantages
– Good for computer-assisted cartographic production
where no topologic
p g relation is required
q
• Disadvantages
– No spatial relationships are reordered
– Common boundary of two adjacent polygon are
stored twice
– Inefficient for most type of spatial analyses
– Spatial relationships which are implicit in the original
analog document must be derived through
computation
– Correction and updates of the data must rely on
visual checks of graphic output
9/28/2011
9
Chaincodes Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Classical chaincode model was presented by FreemanHoffman in1974
• Unique direction code
• Encode line data on grid unit
• Record x, y coordinates only for beginning point of each line
9/28/2011
10
5
9/28/2011
An Example of Chaincodes Model
LSGI 521: Principles of GIS
9/28/2011
Lecture 4: Data Modelling
11
Advantages & Disadvantages of
Chaincodes Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Advantages
– Compactness
– Using unit vector direction code - easier for
some
measurement
and
analytical
procedures (distance, shape analysis)
• Disadvantages
– No spatial relationships are retained - a
compact spaghetti
– Coordinate
transformations,
particularly
rotation, are more difficult
9/28/2011
12
6
9/28/2011
GBF/DIME Model
LSGI 521: Principles of GIS
• GDF/DIME (Geographic
Base File/ Dual Independent
Map
p Encoding)
g) from US
Census Bureau
• Each street, river, railroad
line etc is represented as a
series of straight line
segments
• Usage:
Lecture 4: Data Modelling
12
– Digitally storing street maps
– Providing geographically
referenced address
information in computerized
form
9/28/2011
13
Advantages & Disadvantages of
GBF/DIME Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Advantages
– As a directed graph, missing segments and other
errors can be
b automatically
t
ti ll checked.
h k d
– Some location systems (e.g. street address) can be
directly derived from the model.
• Disadvantages
– Line segments are not stored in any particular order;
to retrieve any particular line segment
segment, exhaustive
search must be performed on the entire file.
9/28/2011
15
7
9/28/2011
Topologic Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Definition
– Basic logic entity is straight line segment
– A line segment begins or ends at the
intersection with another line or at a bend
• Files
– X, Y coordinate node file
– Line segment file
– Topologically coded network polygon file
9/28/2011
16
An Example of Topologic Model
LSGI 521: Principles of GIS
9/28/2011
Lecture 4: Data Modelling
17
8
9/28/2011
Advantages & Disadvantages of Topologic Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Advantages
– Most popular method of retaining spatial
relationships among objects
– Explicitly record adjacency information
– Points, line, polygons are stored in a nonredundant manner
• Disadvantages
– It is a time consuming process to properly
define the topology depending on the size and
complexity of the data set
9/28/2011
20
POLYVRT
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• POLYVRT (POLYgon conVERTer) presented by
Peucker and Chrisman in 1975.
• Explicitly and separately storing each type of
data entity in a hierarchical data structure
– A chain is denoted as the basic line entity comprised
from a sequence of straight line segments
– A line segment begins and ends at a node
– A node is defined as the intersection point between
two chains and its position is indicated by x,
x y
coordinates
9/28/2011
21
9
9/28/2011
An Example of POLYVRT Model
LSGI 521: Principles of GIS
•
•
•
•
•
•
Lecture 4: Data Modelling
Polygons
Chain List
Chains
Points
Nodes
Files are linked
by pointers
9/28/2011
22
Advantages & Disadvantages of
POLYVRT Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Advantages
– More efficient in retrieving than simpler topologic structures;
– S
Selective retrieval of only
y specific
p
classes in the data model at a
time;
– The queries concerning the adjacency of polygons need only
deal with the polygons of interest. Only individual chains which
bound the polygons of interest are retrieved
• Disadvantages
– The physical separation of files cause the need for a link or
pointer structure
– Incorrect pointers can be extremely difficult to detect or correct
– Initial generation of this structure can be cumbersome and timeconsuming
9/28/2011
23
10
9/28/2011
Raster Models
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
For Vector Models:
Individual entities are the basic data units for
which geometric information is explicitly
recorded.
While Raster Models:
The basic unit become a unit of space for
which entity
y information is explicitly
p
y recorded.
9/28/2011
24
A Simple Raster Data Model
LSGI 521: Principles of GIS
9/28/2011
Lecture 4: Data Modelling
25
11
9/28/2011
Another Example of Raster Model
LSGI 521: Principles of GIS
9/28/2011
Lecture 4: Data Modelling
26
Typical Raster Models
LSGI 521: Principles of GIS
•
•
•
•
•
•
Lecture 4: Data Modelling
Run-Length Encoding
g
Block Encoding
Chain Encoding
Quadtree Model
Point Quadtree Model
K-D Tree
9/28/2011
27
12
9/28/2011
Run-Length Encoding
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Run-length encoding allow the points in each mapping
unit to be stored per row in terms, from left to right, of a
begin
g cell and an end cell.
9/28/2011
28
Block Encoding
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Block encoding extends the run-length encoding idea to
two dimensions by using a series of square blocks to
store data
9/28/2011
29
13
9/28/2011
Chain Encoding
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Chain encoding works by defining the boundary of the entity. The
boundary is defined as a sequence of unit cells starting from and
returning to a given origin. The direction of travel around the
boundary is usually given using a numbering system (e
(e.g.,
g 0=North
0=North,
1=East, 2=South, and 3=West).
9/28/2011
30
Advantages & Disadvantages of Encoding Models
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Advantage
– more compact than square grid
– suitable
it bl for
f linear
li
or parallel
ll l algorithms
l ith
processing
i
• Disadvantage
– not suitable for processes which depend upon
neighborhood effects
9/28/2011
31
14
9/28/2011
Quadtree Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Recursive subdivision
of space in quadtree
model results in a
regular, balanced tree
structure of degree 4
– A hierarchical or tree
data model
– Each node has 4 sons
9/28/2011
32
Advantages & Disadvantages of Quadtree Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Advantages
– Tree file structure - well developed already
– Suitable for handling a very large database
– Compatible with conventional cartesian
coordinate systems
• Disadvantages
– There is a trade-off
trade off between the complexity of
the object and the dimensions of the smallest
grid cell.
9/28/2011
33
15
9/28/2011
Point Quadtree Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Point quadtree is a special quadtree that divides space
based on the location of ordered points, rather than
regular
g
spatial
p
decomposition
p
(0,100)
(100,100)
TORONTO
(60,75)
DENVER
(5,45)
CHICAGO
OMAHA (35,40)
(25,35)
Y
(0,0)
MOBILE
(50,10)
X
BUFFALO
(80,65)
ATLANTA
(85,15)
MIAMI
(90,5)
(100,0)
CHICAGO
DENVER
TORONTO
BUFFALO
9/28/2011
OMAHA
ATLANTA
MOBILE
MIAMI
34
Advantages & Disadvantages of Point
Quadtree Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Advantages
– Location based
– Save space
• Disadvantages
– The shape of the tree is highly dependent on
the order in which the points are added
– Additions and deletions are impossible except
at the leaves of the tree
9/28/2011
35
16
9/28/2011
K-D Tree
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• K-D tree divides the area into two parts instead of four,
yielding a tree of degree 2
(0,100)
(100,100)
TORONTO
(60,75)
Y
DENVER
CHICAGO
(5,45)
OMAHA(35,40)
(25,35)
MOBILE
(50,10)
(0,0)
X
BUFFALO
(80,65)
ATLANTA
(85,15)
MIAMI
(90,5)
(100,0)
CHICAGO
DENVER
OMAHA
MOBILE
MIAMI
TORONTO
BUFFALO
ATLANTA
9/28/2011
36
Modeling Terrain Surface
LSGI 521: Principles of GIS
9/28/2011
Lecture 4: Data Modelling
39
17
9/28/2011
Raster-based Digital Terrain Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Raster-based Digital Terrain Model (DTM) is simply a grid of height
values in which each cell contains a single value representative of
the height of the terrain that is covered by that cell.
• DEM (Digital Elevation Model)
9/28/2011
40
An Example of DEM
LSGI 521: Principles of GIS
9/28/2011
Lecture 4: Data Modelling
41
18
9/28/2011
1:1,000,000 Map Scale DEM
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
42
1:250,000 Map Scale DEM
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
43
19
9/28/2011
1:50,000 Map Scale DEM
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
44
1:10,000 Map Scale DEM
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
45
20
9/28/2011
Vector-based Digital Terrain Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• A more advanced, more complex and more common
form of vector-based DTM is the Triangulated Irregular
Network (TIN)
9/28/2011
46
TIN Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
6
1
A
11 J
K
5
B
7
C
8
EDGES
NODES
2
adjacent
N
I
L
M
D
10
9
node#
H
G
A
B, K
A
1, 6, 7
B
A, C, L
B
1, 7, 8
C
B, D
C
1, 2, 8
D
C, E, L
D
2, 8, 9
E
D, F
E, G
E
F
F
2, 3, 9
3, 4, 9
G
F, H, M
G
4, 9, 10
H
G, I
H
4, 5, 10
I
H, J, N
I
5, 10, 11
X-Y Coordinates
Z Coordinates
J
I, K
J
5, 6, 11
node#
node#
K
A, J, N
K
6, 7, 11
1
x1, y1
1
z1
L
L
7, 8, 9
2
x2, y2
2
z2
M
B, D, M
G, L, N
M
7, 9, 10
3
x3, y3
3
z3
N
I, K, M
N
7, 10, 11
...
...
...
...
E
3
11
9/28/2011
4
F
coordinates
x11, y11
11
z_value
z11
47
21
9/28/2011
An Example of TIN
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
9/28/2011
48
Advantages & Disadvantages of TIN
Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Advantages
– Adapt to the nature terrain
– Facilitate the calculation of slope and other
terrain-specific parameters
• Disadvantages
– More time is required in dividing irregular
space point set
– For some point set, there are many possible
different triangulations
9/28/2011
49
22
9/28/2011
Object-Oriented Modeling
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• An object is a self-contained package of information
describing the characteristics and capabilities of an entity
• In a geographical object data model, the real world is
modeled as a collection of objects and relationships
between them
9
Each entity in the GIS is an
object
A collection of objects of the
same type is called a class
Each class has a superclass
from which it can inherit both
instance variables and
methods
9
9
9/28/2011
50
Object-Oriented Data Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
OBJECT
POLYGON
Polygon-1
Polygon-1
LAND PARCEL
Land
parcel-1
Land
parcel-2
Land
parcel-3
• Three key hallmarks of object orientation
– Polymorphism
– Encapsulation
– Inheritance
9/28/2011
51
23
9/28/2011
Advantages & Disadvantages of ObjectOriented Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Advantages
– The ‘natural’ model: directly corresponds to the object
found in reality.
– Completeness: every object is completely bounded
with a defined ‘shell’.
– Inheritance: a class can include subclasses that can
inherit both its data and methods.
– Openness: allows to modify and expand instance
variables and methods.
methods
• Disadvantages
– Complicated
– Difficulty of implementation
9/28/2011
52
What is a Network?
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
Any system of interconnected
linear features
9/28/2011
53
24
9/28/2011
How to Represent a Network?
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
9/28/2011
54
Network Elements
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Network nodes
• Network links
•
•
•
•
Impedance and demand
Turn
Stops (intermediate nodes)
Centers (resource provider/center)
End point of
8 route bus
Centers
Impedance
Links
School
Turn
N lleft
No
ft turn
t
here
h
Start point of
8 route bus
Demand
9/28/2011
10 people get
on the bus
deman
Stops
Barrier
Links
55
25
9/28/2011
The Simplest Node-Link Model
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
Two fundamental tables are required in the Node-Link Model that
can be stored in a relational database
• Node table
– This table contains at least three fields; one to store a unique identifier
and the others to store the node's X and Y coordinates..
• Link table
– This table also contains at
least three fields; one to store
an unique identifier, one to
store the node of origin and
one to store the node of
destination. A fourth field can
be used to state if the link is
unidirectional or not.
9/28/2011
56
Network – Impedance and Demand
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Impedance
– Length by default
– ‘from-node’ to ‘to-node’ and ‘to-node’ to ‘from-node’ impedances
– Different impedance may be assigned to different turn types
• Demand
– Attributes added to the network
9/28/2011
57
26
9/28/2011
Network - Turn
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• There are n2 possible turns at every network node,
where n is the number of edges connected at that node
• Four types of action
–
–
–
–
Passing straight through an intersection
Backtracking, i.e. making a U-turn
Turning left
Turning right
9/28/2011
58
An Example of a Turntable
LSGI 521: Principles of GIS
•
•
•
•
•
Lecture 4: Data Modelling
Node# - internal node no. of the network node at which turn is made
Arc1# - internal node no. of arc entering the node
Arc2# - internal node no. of arc leaving the node
Azimuth – north azimuth of arc entering
g the node
Angle – angle of turn from Arc1# to Arc2#, left turns have + angles, right
turns have – angles
9/28/2011
59
27
9/28/2011
Network - Stop
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Cover-ID
– Unique user-id for each stop
Unlike nodes, stops do not
affect or alter path direction
• In-order
– Value for the order in which the stops will be visited
• Route-ID
– Feature-id of the route
created
• Impedance
– The cost associated with
the stop, e.g. time, money
cost
• Transfer
– Loading or unloading of
resources or commodities
at a stop
9/28/2011
61
Network - Center
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Cover-ID
– Unique user-id for each center
• Route-ID
– Feature-id of the route created
• Max-Impedance
– Serving area (distance, time)
• Supply
– The maximum total demand
9/28/2011
62
28
9/28/2011
An Example of the Allocation Problem
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
9/28/2011
63
Typical Applications
LSGI 521: Principles of GIS
Best Route
9/28/2011
Lecture 4: Data Modelling
Closest Facility
64
29
9/28/2011
Typical Applications
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
Service Area
Origin-Destination Cost Matrix
9/28/2011
65
Review
LSGI 521: Principles of GIS
Lecture 4: Data Modelling
• Further readings
– D. Buckey, Vector and Raster - Advantages and Disadvantages
(http://bgis.sanbi.org/gis-primer/page_19.htm)
– Finding Your Way with ArcGIS Network Analyst
(http://proceedings.esri.com/library/userconf/devsummit06/papers/network_analy
st.pdf)
• Summarization of the main ideas presented in this lecture:
• Questions?
2011/9/28
66
30