Top Banner
Geographic Database Systems Emmanuel Stefanakis http://www2.unb.ca/~estef/ Stefanakis, E., 2014. Geographic Databases and Information Systems. CreateSpace Independent Publ. [In English], pp.386. Get a copy from Amazon Chapter 15
38

UNB - Teaching Presentation

Jan 29, 2022

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: UNB - Teaching Presentation

Geographic Database Systems

Emmanuel Stefanakis

http://www2.unb.ca/~estef/

Stefanakis, E., 2014. Geographic Databases and Information Systems.

CreateSpace Independent Publ. [In English], pp.386.

Get a copy from Amazon

Chapter 15

Page 2: UNB - Teaching Presentation

2

Geographic Data in GIS

• Two main components…

– Spatial (geometry)

– Non-Spatial (attribute data)

x

y

Page 3: UNB - Teaching Presentation

3

Geographic Data in GIS

• How are those stored in a GIS ?…

– A common approach is to use two systems (hybrid architecture)

CAD

SYSTEM

DATABASE

SYSTEM

x

y

Page 4: UNB - Teaching Presentation

4

Geographic Data in GIS

• Data related to the same entity…

– is split and stored into the two systems

– Re-structuring through common identifiers

CAD

SYSTEM

DATABASE

SYSTEM

x

yid=16

Page 5: UNB - Teaching Presentation

5

Geographic Data in GIS

• Hybrid Architecture…

CAD

SYSTEM

DATABASE

SYSTEM

GIS Application Layer

Users

Page 6: UNB - Teaching Presentation

6

Geographic Data in GIS

• Hybrid Architecture…

CAD

SYSTEM

DATABASE

SYSTEM

GIS Application Layer

The application layer

is responsible of

making the two sub-

systems work

together Users

Arc Info /

Page 7: UNB - Teaching Presentation

7

Geographic Data in GIS

• Hybrid Architecture… The users feel that

they interact with

one single system.

CAD

SYSTEM

DATABASE

SYSTEM

GIS Application Layer

Users

Page 8: UNB - Teaching Presentation

Querying Geographic Data

• Three types of queries…

– Spatial

• based on geometries

– Non-spatial

• based on attributes

– Combined

• both spatial and non-spatial predicates

8

Page 9: UNB - Teaching Presentation

Where is the processing performed…

• Spatial Query: Find all streets that are less than 5 km away from point A.

9

x

y

A

Page 10: UNB - Teaching Presentation

Where is the processing performed…

• Spatial Query: Find all streets that are less than 5 km away from point A.

10

CAD

SYSTEM

DATABASE

SYSTEM

GIS Application

Layer

The query is

forwarded and

processed at the

CAD System.

Page 11: UNB - Teaching Presentation

Where is the processing performed…

• Non-Spatial Query: Find all streets that are of type AVE (avenues).

11

x

y

Page 12: UNB - Teaching Presentation

Where is the processing performed…

• Non-Spatial Query: Find all streets that are of type AVE (avenues).

12

CAD

SYSTEM

DATABASE

SYSTEM

GIS Application

Layer

The query is

forwarded and

processed at the

Database System.

Page 13: UNB - Teaching Presentation

Where is the processing performed…

• Combined Query: Find all avenues that are less than 5 km away from point A.

13

x

y

A

Page 14: UNB - Teaching Presentation

Where is the processing performed…

• Combined Query: Find all avenues that are less than 5 km away from point A.

14

CAD

SYSTEM

DATABASE

SYSTEM

GIS Application

Layer

The query is

forwarded and

processed at

both Systems.

Page 15: UNB - Teaching Presentation

Where is the processing performed…

• Combined Query… – Appl. Layer is responsible to find the intersection.

15

CAD

SYSTEM

DATABASE

SYSTEM

GIS Application

Layer

id's

of roads

near A

id's

of

avenues !

the result

Page 16: UNB - Teaching Presentation

Where is the processing performed…

• Combined Query… – Appl. Layer is responsible to find the intersection.

16

CAD

SYSTEM

DATABASE

SYSTEM

GIS Application

Layer

id's

of roads

near A

id's

of

avenues !

the result

Not efficient!

Page 17: UNB - Teaching Presentation

17

Geographic Data in GIS

• A similar Architecture (Geodatabase)…

DATABASE

SYSTEM

GIS Application Layer

Users

No CAD System; single DB.

Geometries are stored as binary

fields in the traditional database.

Relational technology

Page 18: UNB - Teaching Presentation

18

Geographic Data in GIS

• A similar Architecture (Geodatabase)…

DATABASE

SYSTEM

GIS Application Layer

Users The spatial processing is performed

at the application layer.

Not effective either !

Relational technology

Page 19: UNB - Teaching Presentation

Geographic Data in GIS

• A more efficient Architecture (Spatial DB)…

SPATIAL DATABASE

SYSTEM

GIS Application Layer

Users All processing is performed in the

database (at the lowest level)

Very effective !

Object relational technology

the_geom

Page 20: UNB - Teaching Presentation

Define the Spatial Schema

• New Geometry types…

Page 21: UNB - Teaching Presentation

Define the Spatial Schema

• New Functions…

– Distance()

– Area()

– Intersection()

– …

• New Index Structures (Spatial indices)

– R-tree

– Quadtree

Page 22: UNB - Teaching Presentation

Define the Spatial Schema

• New Geometry types / Functions…

CREATE TYPE POINT AS OBJECT ( X NUMBER, Y NUMBER, Ζ NUMBER, FUNCTIONS ( DISTANCE (U: POINT, V:POINT) RETURNS NUMBER ) );

Page 23: UNB - Teaching Presentation

Define the Spatial Schema

• New Geometry types / Functions…

CREATE TABLE TOWNS ( ID NUMBER, NAME VARCHAR(20), LOCATION POINT, ); SELECT DISTANCE(T1,T2) FROM TOWNS WHERE T1.NAME = ‘Fredericton’ AND T2.NAME = ‘Oromocto’

Page 24: UNB - Teaching Presentation

Define the Spatial Schema

• New Geometry types / Functions…

CREATE TYPE LINESTRING AS OBJECT ( P: ARRAY OF POINT, FUNCTIONS ( LENGTH (L: LINESTRING) RETURNS NUMBER ) );

Page 25: UNB - Teaching Presentation

Define the Spatial Schema

• New Geometry types / Functions…

Etc…

Too much work !!!

Page 26: UNB - Teaching Presentation

Define the Spatial Schema

• The work has been done for us !

Geometry

Point LineString Polygon

MultiPolygon MultiLineString MultiPoint

Geom_Collection

Spatial Reference System

LinearRing Line

2..* 2..* 2..* 2..*

1..*

Page 27: UNB - Teaching Presentation

Define the Spatial Schema

• The work has been done for us !

O-Rel DBMS

SPATIAL MODEL

Application model (built on top of that)

Page 28: UNB - Teaching Presentation

Define the Spatial Schema

• The work has been done for us !

O-Rel DBMS

SPATIAL MODEL

Application model (built on top of that)

Page 29: UNB - Teaching Presentation

29

Create a GeoDB in PostgreSQL/PostGIS

• Use the shp2pgsql utility offered by PostGIS (it is located inside bin directory)

– It converts a shapefile to an sqlscript (set of SQL commands)

shapefile SQL

commands

shp2pgsql.exe

PostgreSQL

PostGIS

Page 30: UNB - Teaching Presentation

30

Create a GeoDB in PostgreSQL/PostGIS

• spit plugin (Quantum GIS)

– Import Shapefiles to PostgreSQL (spit)

shapefiles

spit plugin

PostgreSQL

PostGIS

Quantum GIS

Page 31: UNB - Teaching Presentation

31

Connect and Visualize the PostGIS Layers from Quantum

Page 32: UNB - Teaching Presentation

32

1. Select Population from Prefectures 2. Sum-up Population from Municipalities

prefectures municipalities

Page 33: UNB - Teaching Presentation

33

1. Select Population from Prefectures 2. Sum-up Population from Municipalities

SELECT "NAME", "POP_01" FROM prefectures;

SELECT sum("POP_01") FROM municipalities;

(Prefecture: Irakleio)

Page 34: UNB - Teaching Presentation

34

Towns in the municipality of Mallia.

SELECT r."NAME" as municipality, m. "NAME" as town

FROM municipalities AS r, towns AS m

WHERE r.the_geom && m.the_geom

AND ST_contains(r.the_geom, m.the_geom)

AND r."NAME" = 'Mallia';

Page 35: UNB - Teaching Presentation

35

Municipalities sharing a boundary with the municipality of Arkalochori (report the geometry)

SELECT n.gid, n.the_geom INTO Arkalochori_neighbours

FROM municipalities as m, municipalities as n

WHERE m."NAME" = 'Arkalochori'

AND ST_Touches(m.the_geom, n.the_geom);

Page 36: UNB - Teaching Presentation

36

Buffer Zone of 5km around Larani

SELECT "ID", ST_Buffer(the_geom, 5000, 16) INTO Larani_Buffer

FROM towns

WHERE "NAME" = 'Larani';

Page 37: UNB - Teaching Presentation

37

Buffer Zone of 3km around Mallia

SELECT ST_Buffer(the_geom, 3000, 16) INTO mallia_buffer

FROM municipalities

WHERE "NAME" = 'Mallia';

Page 38: UNB - Teaching Presentation

Geographic Database Systems

Emmanuel Stefanakis

http://www2.unb.ca/~estef/

Stefanakis, E., 2014. Geographic Databases and Information Systems.

CreateSpace Independent Publ. [In English], pp.386.

Get a copy from Amazon

Chapter 15