Download presentation
Presentation is loading. Please wait.
1
Chapter 2: Spatial Concepts and Data Models
2.1 Models of Spatial Information 2.2 Three-Step Database Design 2.3 Extending ER with Spatial Concepts 2.4 Conceptual Data Modeling with UML 2.5 Summary
2
Learning Objectives LO1: Understand concept of data models
What is a data model? Why use data models? LO2: Understand the models of spatial information LO3: Understand the 3-step design of databases LO4: Learn about the trends in spatial data models
3
2.1 Models of Spatial Information -- What is a Data Model?
What is a model? (Dictionary meaning) A set of plans (blueprint drawing) for a building A miniature(微型) representation of a system to analyze properties of interest What is Data Model? Specify structure or schema of a data set Document description of data Facilitates early analysis of some properties, e.g. querying ability, redundancy, consistency, storage space requirements, etc. Examples: GIS organize spatial set as a set of layers Databases organize dataset as a collection of tables
4
2.1 Models of Spatial Information -- Why Data Models?
Data models facilitate Early analysis of properties, e.g. storage cost, querying ability, ... Reuse of shared data among multiple applications Exchange of data across organization Conversion of data to new software / environment Example- Y2K crisis for year 2000 Many computer software systems were developed without well-defined data models in 1960s and 1970s. These systems used a variety of data models for representing time and date. Some of the representations used two digits to represent years. In late 1990s, people worried that the 2 digit representation of year may lead to erroneous behaviors. For example age of a person born in 1960 (represented as 60) in year 2000 (represented as 00) may appear negative and may be flagged as illegal data item. A large amount of effort and resources (hundreds of Billions of dollars) was spent in revising the software. Proper use of data model may have significantly reduced the costs. If time and date were modeled as abstract data types in a software, only a small portion of the software implementing the date ADT had to be reviewed and revised.
5
2.1 Models of Spatial Information -- Types of Data Models
Two Types of data models Generic data models(一般数据模型) Developed for business data processing Support simple abstract data types (ADTs), e.g. numbers, strings, date Not convenient for spatial ADTs, e.g. polygons Recall a polygon becomes dozens of rows in 3 tables (Fig. 1.4, pp. 8) Need to extend with spatial concepts, e.g. ADTs Application Domain specific, e.g. spatial models(应用模型) Set of concepts developed in Geographic Info. Science Common spatial ADTs across different GIS applications Plan of Study First study concepts in spatial models(空间模型) Then study generic model Finally put the two together
6
2.1 Models of Spatial Information-- Two common models
Field based(场模型) Object based(对象模型) Example: Forest stands 林分 Fig. 2.1 (a) forest stand map (b) Object view has 3 polygons (c ) Field view has a function Pine:松树 Fir:杉树 Oak:橡树
7
要素模型—矢量数据结构 图形表示 摘自 张超 返回
8
场模型--栅格数据结构 图形表示 点:由单个栅格表达。 线:由沿线走向有相同属性取值的一组相邻栅格表达。
3 栅格结构用密集正方形(或三角形,多边形)将地理区域划分为网格阵列。 位置由行,列号定义,属性为栅格单元的值。 点:由单个栅格表达。 线:由沿线走向有相同属性取值的一组相邻栅格表达。 面:由沿线走向有相同属性取值的一片栅格表达。 栅格数据表示的是二维表面上的地理数据的离散化数值。在栅格数据中,地表被分割为相互邻接、规则排列的地块,每个地块与一个象元相对应。因此,栅格数据的比例尺就是栅格(象元)的大小与地表相应单元的大小之比,当象元所表示的面积较大时,对长度、面积等的量测有较大影响。每个象元的属性是地表相应区域内地理数据的近似值,因而有可能产生属性方面的偏差。 2 1 3 返回
9
2.1.1 Field based Model Three main concepts:
1)Spatial Framework is a partitioning of space(空间分割框架) e.g., Grid imposed by Latitude and Longitude 2)Field Functions(场函数) f: Spatial Framework Attribute Domain(属性域) 3)Field Operations Examples, addition(+) and composition(o).(并和复合)
10
Types of Field Operations
Local: value of the new field at a given location in the spatial frame-work depends only on the value of the input field at that location(e.g., Thresholding)(局部操作) Focal:value of the resulting field at a given location depends on the values that the input field assumes in a small neighborhood of the location(e.g., Gradient,梯度)(聚焦操作) Zonal:Zonal operations are naturally associated with aggregate operators or the integration function. An operation that calculates the average height of the trees for each species is a zonal operation. (区域操作) Exercise: Classify following operations on elevation field (I) Identify peaks (points higher than its neighbors) (II) Identify mountain ranges (elevation over 2000 feet) (III) Determine average elevation of a set of river basins 第3次课结束
11
2.1.2 Object Model Object model concepts Example from a roadmap
Objects: distinct identifiable things relevant to an application(可识别的) Objects have attributes and operations(属性和操作) Attribute: a simple (e.g. numeric, string) property of an object Operations: function maps object attributes to other objects Example from a roadmap Objects: roads, landmarks, ... Attributes of road objects: spatial: location, e.g. polygon boundary of land-parcel non-spatial: name (e.g. Route 66), type (e.g. interstate, residential street), number of lanes, speed limit, … Operations on road objects: determine center line, determine length, determine intersection with other roads, ... 两大属性: 空间属性 非空间属性
12
2.1.3 Classifying Spatial objects
Spatial objects are spatial attributes of general objects Spatial objects are of many types Simple 0- dimensional (points), 1 dimensional (curves), 2 dimensional (surfaces) Example given at the bottom of this slide Collections Polygon collection (e.g. boundary of Japan or Hawaii), … See more complete list in Figure 2.2 Spatial Object Types Example Object Dimension Point City Curve River 1 Surface Country 2
13
Spatial Object Types in OGIS Data Model
Fig 2.2: Each rectangle shows a distinct spatial object type 几何操作上的闭合性
14
2.1.4 Classifying Operations on spatial objects in Object Model
Classifying operations (Tables 2.1, 2.2, pp ) 1)Set based: 2-dimensional spatial objects (e.g. polygons) are sets of points a set operation (e.g. intersection) of 2 polygons produce another polygon 2)Topological operations: Boundary of USA touches boundary of Canada 3)Directional: New York city is to east of Chicago 4)Metric(度量): Chicago is about 700 miles from New York city. Q? Identify classes of spatial operations not listed in this slide.(Overlay,Buffer) Set theory based Union, Intersection, Containment, Toplogical Touches, Disjoint, Overlap, etc. Directional East,North-West, etc. Metric Distance
15
2)Topological Relationships
invariant under elastic deformation (弹性变形,without tear, merge). Two countries which touch each other in a planar paper map will continue to do so in spherical globe maps. Topology is the study of topological relationships Example queries with topological operations What is the topological relationship between two objects A and B ? Find all objects which have a given topological relationship to object A ? GIS中三种典型的拓扑关系: (1)邻接 (2)包含 (3)关联
16
Topological Concepts Interior, boundary, exterior Green is A interior
Let A be an object in a “Universe” U. Green is A interior Red is boundary of A Blue –(Green + Red) is A exterior U A Question: Define Interior, boundary, exterior on curves and points.
17
Nine-Intersection Model of Topological Relationships
Many topological Relationship between A and B can be specified using 9 intersection model Examples on next slide Nine intersections intersections between interior, boundary, exterior of A, B A and B are spatial objects in a two dimensional plane. Can be arranged as a 3 by 3 matrix Matrix element take a value of 0 (false) or 1 (true). Q? Determine the number of many distinct 3 by 3 boolean matrices . 考虑取值有空(0)和非空(1),可以确定有29=512种二元拓扑关系。对于嵌在中的二维区域,有八个关系是可实现的,并且它们彼此互斥且完全覆盖。
18
Specifying topological operation in 9-Intersection Model
Fig 2.3: 9 intersection matrices for a few topological operations Question: Can this model specify topological operation between a polygon and a curve?
19
Specifying topological operation in 9-Intersection Model(2)
对于(point,surface)、(point,curve),其拓扑关系可以用类似方式定义
20
Specifying topological operation in 9-Intersection Model(3)
21
2.1.5 动态空间操作 静态的(static) 操作不受操作的应用影响:计算一条线的长度对线本身没有任何影响。
动态(dynamic)操作则会改变它所作用的对象:创建(create)、销毁(destroy)和更新(update)。
22
ArcGIS中的Merge 操作 云南省县界 云南省所属州 Merge
23
Using Object Model of Spatial Data
OGIS standard set of spatial data types and operations Similar to the object model in computer software Easily used with many computer software systems Programming languages like Java, C++, Visual basic Example use in a Java program is in section 2.1.6 Post-relational databases, e.g. OODBMS, ORDBMS Example usage in chapter 3 through 6
24
2.1.6 将空间对象映射到Java (自学) 讨论Java程序的主要目的是要说明空间数据类型和操作可以应用在有别于SQL(将会在本书后面的部分用到)的宿主语言中。 其次,是为了比较空间查询所需的编程工作量。在编写简单的空间查询时,利用SQL将大大减少所需的代码量,同时也减少了性能调整和数据结构选取的负担。 在后面的几章中通过比较SQL和Java来回顾这些观点。
25
Learning Objectives Learning Objectives (LO)
LO1: Understand concept of data models LO2 : Understand the models of spatial information LO3: Understand the 3-step design of databases Conceptual - ER model Logical - Relational model Physical Translation from Conceptual to Logical LO4: Learn about the trends in spatial data models Mapping chapter sections to learning objectives LO LO LO , 2.4
26
2.2 Three-Step Database Design(数据库设计的三个步骤)
Database applications are modeled using a three-step design process Conceptual-datatypes,relationships and constraints(ER model) Logical-mapping to a Relational model and associated query language(Relational Algebra,关系代数) Physical-file structures, indexing, Scope We discuss conceptual and logical data models in section 2.3 Physical model is discussed in chapter 4 交 并 差
27
Example Application Domain
Database design is for a specific application domain Often a requirements document is available(需求文档) Designers discuss requirements with end-users as needed We will use a simple spatial application domain to illustrate concepts in conceptual and logical data models to illustrate translation of conceptual DM to logical DM Spatial application domain A state-park consists of forests. A forest is a collection of forest-stands of different species State-Park is accessed by roads and has a manager State-Park has facilities River runs through state-park and supplies water to the facilities
28
2.2.1 Conceptual DM: The ER Model
3 basic concepts Entities(实体) have an independent conceptual or physical existence. Examples: Forest, Road, Manager, ... Entities are characterized by Attributes(属性) Example: Forest has attributes of name, elevation, etc. An Entity interacts with another Entity through relationships(关系). Road allow access to Forest interiors. This relationship may be name “Accesses” Comparison with Object model of spatial information Entities are collections of attributes are like objects However ER model does not permit general user defined operations Relationships are not directly supported in Object model but may be simulated via operations
29
Relationship Types Relationships can be categorized by cardinality constraints other properties, e.g. number of participating entities Binary relationship: two entities participate Types of Cardinality constraints(基数约束) for binary relationships One-One: An instance of an entity relates to a unique instance of other entity. Many-One: Many instances of an entity relate to an instance of an other. Many-Many: Many instances of one entity relate to multiple instances of another. Exercise: Identify type of cardinality constraint for following: Many facilities belong to a forest. Each facility belong to one forest. A manager manages 1 forest. Each forest has 1 manager. A river supplies water to many facilities. A facility gets water from many rivers.
30
ER Diagrams Graphical Notation(ER图形符号)
ER Diagrams are graphic representation of ER models(ER图是ER模型的图形表达) Several different graphic notation are used We use a simple notation summarized below Example ER Diagram for Forest example in next slide Q? Compare and contrast “Attributes” and “Multi-valued attributes”. Concept Symbol Entities Attributes Multi-valued Attributes Relationships Cardinality of Relationship 1:1, M:1, M:N 第4次课结束
31
ER Diagram for “State-Park”
Fig 2.4 Exercise: List the entities, attributes, relationships in this ER diagram Identify cardinality constraint for each relationship. How many roads “Accesses” a “Forest_stand”? (one or many)
32
2.2.2 Logical Data Model: The Relational Model
Relational model is based on set theory Main concepts Domain: a set of values for a simple attribute Relation: cross-product of a set of domains Represents a table, i.e. homogeneous collection of rows (tuples) The set of columns (i.e. attributes) are same for each row Comparison to concepts in conceptual data model Relations are similar to but not identical to entities Domains are similar to attributes Translation rules establishing exact correspondence are discussed in 2.2.3 元组:Row = Tuple 属性:Column = Attribute (Column Acountr = Degree,度) 关系:Table = Relation (数据类型是有限制,如整型、浮点型、字符串、日期型等) 关系模式:Table Name + Column Name = Relation Schema
33
Relational Schema Schema of a Relation Relational schema of a database
Enumerates columns, identifies primary key and foreign keys. Primary Key : one or more attributes uniquely identify each row within a table Foreign keys (外码是关系的属性集) R’s attributes which form primary key of another relation S Value of a foreign key in any tuple of R match values in some row of S Relational schema of a database collection of schemas of all relations in the database Example: Figure 2.5 (next slide) A blueprint summary drawing of the database table structures Allows analysis of storage costs, data redundancy, querying capabilities Some databases were designed as relational schema in 1980s Nowadays, databases are designed as ER models and relational schema is generated via CASE tools(e.g. ERwin、Oracle Designer 2000 and Rational Rose ) 码约束,实体完整性(entity integrity)约束和参照完整性(referential integrity]约束
34
More on Relational Model
Integrity Constraints(完整性约束) Key: Every relation has a primary key. Entity Integrity: Value of primary key in a row is never undefined(非空) Referential Integrity: Value of an attribute of a Foreign Key must appear as a value in the primary key of another relationship or must be null. Normal Forms (NF) for Relational schema Reduce data redundancy and facilitate querying 1st NF: Each column in a relation contains an atomic value. 2nd and 3rd NF: Values of non-key attributes are fully determined by the values of the primary key, only the primary key, and nothing but the primary key. Other normal forms exists but are seldom used Translating a well-designed ER model yields a relational schema in 3rd NF satisfying definition of 1st, 2nd and 3rd normal forms
35
2.2.3 Mapping ER to Relational(1)
Highlights of translation rules (section 2.2.3) 1)Entity becomes Relation Attributes become columns in the relation Multi-valued attributes become a new relation includes foreign key to link to relation for the entity
36
2.2.3 Mapping ER to Relational(2)
Highlights of translation rules (section 2.2.3) 2)Relationships (1:1):将任一实体的码属性作为其他关系的一个外码 Primary Key Foreign Key Other Attri. Entity1 Entity2 1:1
37
2.2.3 Mapping ER to Relational(3)
Highlights of translation rules (section 2.2.3) 3)Relationships (M:1):将“1”侧的关系的主码作为“M”侧关系的外码。
38
2.2.3 Mapping ER to Relational(4)
Highlights of translation rules (section 2.2.3) 4)M:N Relationships become a relation (M:N中M和N共同形成新表的关键字) containing foreign keys or relations from participating entities
39
Relational Schema Example
Example and Exercise Compare Fig. 2.4 and Fig. 2.5 Identify the relational schema components for entity Facility, its attributes and its relationships Note an empty relation box in Fig Fill in its schema. Identify relations with primary keys foreign keys other attributes Compare with ER diagram Figure 2.4, pp. 37 Fig 2.5
40
Relational Schema for “Point”, “Line”, “Polygon” and “Elevation”
Relational model restricts attribute domains simple atomic values, e.g. a number Disallows complex values (e.g. polygons) for columns Complex values need to be decomposed into simpler domains A polygon may be decomposed into edges and vertices (Fig. 2.5)
41
Learning Objectives Learning Objectives (LO)
LO1: Understand concept of data models LO2 : Understand the models of spatial information LO3: Understand the 3-step design of databases LO4: Learn about the trends in spatial data models Pictograms in conceptual models UML class diagrams Mapping Sections to learning objectives LO LO LO , 2.4
42
2.3 Extending ER with Spatial Concepts(1)
Motivation ER Model is based on discrete sets with no implicit relationships Spatial data comes from a continuous set with implicit relationships Any pair of spatial entities has relationships like distance, direction, … Explicitly drawing all spatial relationship ER模型的最初设计隐含了基于对象模型的假设。因此,场模型无法用ER模型进行自然的映射。 在传统的ER模型中,实体之间的关系由所要开发的应用来导出,而在空间建模中,空间对象之间总会有内在的联系 -- Misses implicit constraints in spatial relationships (e.g. partition), Clutters(混乱) ER diagram,generates additional tables in relational schema 建模空间对象所使用的实体类型和“地图”的比例尺有关。一个城市是用点还是用多边形表示和地图的分辨率有关。在概念模型中,如何表达同一个对象的多种表现形式?
43
2.3 Extending ER with Spatial Concepts(2)
Pictograms(象形图) Label spatial entities along with their spatial data types Allows inference of spatial relationships and constraints Reduces clutter in ER diagram and relational schema Example: Fig. 2.7 (next slide) is simpler than Fig. 2.4 象形图是一种将对象插在方框内的微缩图表示,这些微缩图用来扩展ER图
44
Specifying Pictograms
Grammar based approach Rewrite rule like English syntax diagrams Classes of pictograms Entity pictograms basic: point, line, polygon collection of basic ... Relationship pictograms partition, network 对于形状的组合,我们用通配符(*)表示,它表示各种形状,例如,一个灌溉网是由泵站(点)、水渠(线)以及水库(多边形)所组成的。 备选
45
Entity Pictograms: Basic shapes, Collections
46
Entity Pictograms: Derived and Alternate Shapes
Derived shape(导出形) example is city center point from boundary polygon Alternate shape(备选形) example: A road is represented as a polygon for construction or as a line for navigation 美国的州界形状导出美国的形状
47
ER Diagram with Pictograms: An Example
空间完整性约束 空间中任意一点至多属于一个forest_stand forest_stand在空间上位于森林“内部” 几何并集在空间上“覆盖”它们所属的森林 Fig 2.7
48
ER Diagram for “State-Park”
用象形符号扩展ER图,以便专门处理空间数据类型。这将减少ER图以及所产生的关系模式的复杂度,同时改进空间建模的质量。空间联系(例如Road-Crosses-River)就可以从ER图中省略,用隐式的方式表示。关系模式中的表达多值空间属性的关系和M:N空间联系也就不需要了 Fig 2.4 空间联系(例如Road-Crosses-River)就可以从ER图中省略,用隐式的方式表示。关系模式中的表达多值空间属性的关系和M:N空间联系也就不需要了
49
象形图增强ER模型的优势 1)图2-7并不显得杂乱,因为这里只有很少的显式联系和属性。空间联系和属性是隐含的。
2)图2-7显示了在空间联系上的更多的信息。例如,尽管图2-7没有显式列出“河流穿过森林”和“消防站在森林之中”这些联系,但是从图中可以看出这些隐含的联系。part_of(分区)象形图所暗含的空间完整性约束也是原来没有的。 3)图2-7的关系模式要比图2-4的关系模式更为简单,由M:N的空间联系生成的关系和空间数据类型都被省略。
50
2.4 Conceptual Data Modeling with UML
Motivation ER Model does not allow user defined operations Object oriented software development uses UML UML stands for Unified Modeling Language It is a standard consisting of several diagrams class diagrams are most relevant for data modeling UML class diagrams concepts Attributes are simple or composite properties Methods represent operations, functions and procedures Class is a collection of attributes and methods Relationship relate classes Example UML class diagram: Figure 2.8
51
UML Class Diagram with Pictograms: Example
Exercise: Identify classes, attributes, methods, relationships in Fig. 2.8. Compare Fig. 2.8 with corresponding ER diagram in Fig. 2.7. Fig 2.8
52
UMLCD的符号 1 ·类(class)是所有在应用中具有相同性质的对象的封装,它等价于ER模型中的实体。
例如,设施类,至少它抽象地包含了州立公园中的功能性单元,例如休息室、营地和旅游公司。正如对ER图所做的那样,我们也能对类图进行象形图扩展。这样就可以清楚看出:Facility类的实例是空间对象。更确切地说,它们的空间几何形状用点来表示。这样一来,有关点对象的所有空间属性、联系和操作都适用于Facility类。
53
UMLCD的符号 2 属性(attribute)描述类的对象。与ER符号不同,UMLCD没有符号表示码属性,这是因为在面向对象(OO)系统中,所有对象都有一个系统生成的唯一标识。属性还有一个与之关联的作用域或可见性。作用域规定是从类的内部还是外部访问属性,这是控制数据库设计中模块化程度的关键。 作用域有三个级别: 1)+(公有的):属性可以被任意类访问和操纵。 2)-(私有的):只有属性所在的类才可以访问这个属性。 3)#(受保护的):从父类派生的类(“子类型化”)可以访问该属性。State-Park例子中的属性全部选用受保护的属性。
54
UMLCD的符号 3 ·方法(method)是一些函数,它们是类定义的一部分,用来修改类的行为或状态。类的状态由属性的当前值来体现。在面向对象的设计中,属性只能通过方法来访问。在Facility类中,通过方法GetName()来访问属性name。 关系(relationship):将一个类与另一个类或者它自己相联系。它类似于ER模型中的联系。对于数据库建模,UMLCD有三种重要的关系:聚合、泛化和关联。
55
UMLCD三种重要的关系-聚合 1)聚合(aggregation)是UMLCD中特有的概念,它描述了部分-整体关系。例如类Forest- stand与类Forest是部分-整体关系(强聚合)。一个类有时可以作为多个其他类的一部分(弱聚合)。
56
UMLCD三种重要的关系-泛化 2)泛化(generalization)在图2-2所示的空间层次语境中得到最好说明。例如,Geometry类是其子类Point、Line和Polygon的泛化。
57
UMLCD三种重要的关系-关联 3)关联(association)反映了不同类的对象之间是如何联系的。和ER模型的联系一样,如果一个关联涉及两个类,那它就是二元的;如果涉及三个类,那么它是三元的(ternary)。关系supplies_water_to就是Facility类与River类之间的一个关联。注意,图2-8中有一个supplies_water_To类,它通过虚线与关联supplies_water_to相连。这是因为该关联本身就有一个Volume属性。 第4次课
58
Comparing UML Class Diagrams to ER Diagrams
Concepts in UML class diagram vs. those in ER diagrams Class without methods is an Entity Attributes are common in both models UML does not have key attributes and integrity constraints ERD does not have methods Relationships properties are richer in ERDs Entities in ER diagram relate to datasets, but UML class diagram can contain classes which have little to do with data 弱实体:其唯一标识必须依赖另一个实体 由于类图和面向对象的范型都假定所有的对象都有唯一的标识,因而不支持弱实体。
59
2.5 Summary Spatial Information modeling can be classed into Field based and Object based Field based for modeling smoothly varying entities, like rainfall (Operations:Local,Focal,Zonal) Object based for modeling discrete entities, like country (Operations :Set based, Topological, Directional, Metric ) 第5次课结束
60
Summary A data model is a high level description of the data
it can help in early analysis of storage cost, data quality There are two popular models of spatial information Field based and Object based Database are designed in 3-steps Conceptual, Logical and Physical Pictograms can simplify Conceptual data models ER & UML
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.