Presentation on theme: "Introduction to Spatial Databases"— Presentation transcript:
1Introduction to Spatial Databases Assist. Prof. Dr. Ahmet SayarComputer Engineering DepartmentAdvanced Database ApplicationsKocaeli UniversitySpring 2013
2What is a SDBMS ? A SDBMS is a software module that can work with an underlying DBMSsupports spatial data models, spatial abstract data types (ADTs) and a query language from which these ADTs are callablesupports spatial indexing, efficient algorithms for processing spatial operations, and domain specific rules for query optimizationGIS, SPATIAL DB VE DATABASE ILISKISI NE?Gis is the principle technology motivating interest in SDBMS.A GIS provides a rich set of operations over few object and layers, whereas an SDBMS provides simpler operations on a set of objects and sets of layers.SDB sits in traditional DB.
3Why Spatial DatabasesGIS is the principle technology motivating interest in SDBMS. GIS is not the only area using SDBMSMany important application domains have spatial data and queries. Some ExamplesInsurance Risk Manager: Which homes are most likely to be affected in the next great flood on the Brisbane river?Molecular Biologist: Is the topology of the amino acid biosynthesis gene in the genome found in any other sequence feature map in the database ?Medical Doctor: Based on this patient's MRI, have we treated somebody with a similar condition ?
4What is a Spatial Database? A spatial database is a database system (DBMS) that is optimized to store and query basic spatial objects :Point: a house, a moving car, a cityLine/Polyline: river, cable, roadPolygon: a county, forest, lake, cityAnd some more – see the nest slide
5Spatial Object Types in OGIS Data Model Each rectangle shows a distinct spatial object type2-dim geometryCollection of islandsCollection of oil wells
6Spatial Data Examples Examples of non-spatial data Names, phone numbers, addresses of peopleExamples of Spatial dataNASA satellites imagery - terabytes of data per dayWeather and Climate DataRivers, Farms, ecological impactMedical ImagingExercise: Identify spatial and non-spatial data items inA phone bookA cookbook with recipes
7Spatial and Non-Spatial Queries List the names of all bookstore with more than ten thousand titles.List the names of ten customers, in terms of sales, in the year 2001Where is Building 78?Which courses are meeting in GP Building?Spatial Queries:List the names of all bookstores with ten miles of MinneapolisList all customers who live in Tennessee and its adjoining statesWhich buildings are adjacent to the lake?Which building is adjacent to a lake?A majority of the DBMS in existence today are either incapable of managing spatial data or are not user-friendly when doing so.
8Spatial Query Example -1 Spatial query languageSpatial data types, e.g. point, linestring, polygon, …Spatial operations, e.g. overlap, distance, nearest neighbor, …Callable from a query language (e.g. SQL3) of underlying DBMSSELECT S.nameFROM Senator SWHERE S.district.Area() > 300StandardsSQL3 (a.k.a. SQL 1999) is a standard for query languagesOGC is a standard for spatial data types and operatorsBoth standards enjoy wide support in industrySpatial query mantigina uyarlamak icin su anki SQL (SQL2) extend edilmeli.Bu genel istek standart bodyler tarafindan ele alindi ve SQL3 diye sql:1999 yeni bir yapi gelistirildi.SQL3 provides support for ADTs and other data structures. It gives the freedom to customize their implementations.
9Spatial Query Example -2 “Display all countries that border Turkiye”.This query can be implemented using the following SQL command:select c1.name as name,transform(c1.the_geom,4326) as the_geomfrom county c1,county c2Where touches(c1.the_geom,c2.the_geom)And c2.name=‘Turkiye';
10Result 2Algorithms for GIS: Intersection of lines, operations on polygons, network traversal, auto-correlation, statistical operations, searching. We focus on the use of algorithms, not their design. The actual algorithms are provided as database extensions (e.g. PostGIS) or desktop GIS (e.g. OpenJump or uDig)
11Spatial Query Example -3 Query: For all the rivers listed in the River table, find the counties through which they pass.SELECT r.name, r.nameFROM river AS r, county AS cWHERE crosses(r.the_geom,c.the_geom)=TrueThe spatial predicate “Cross” is used to join River and Country tablesTo view this we would add asbinary(R.the_geom,C.the_geom)A spatial join associates two tables based on a spatial relationship, rather than an the classic non-spatial relational attribute. A spatial join operation is used to combine two or more dataset with respect to a spatial predicate or spatial operation. Predicates can be a combination of directional, distance, and topological spatial relations (e.g. overlap, contains). In case of non-spatial join, the joining attributes must of the same type, but for spatial join they can be of different types.
12Spatial Query Example -4 A spatial join associate two tables based on a spatial relationship, rather than an attribute relationship. For example the query:Summarize the provincial election results by municipality.SELECT m.name, sum(v.ndp) AS ndp, sum(v.lib) AS liberal, sum(v.gp) AS green, sum(v.upbc) AS unity, sum(v.vtotal) AS total FROM bc_voting_areas v, bc_municipality m, WHERE intersects(v.the_geom, m.the_geom) GROUP BY m.name ORDER BY m.name;Note the && speeds up the join by using PostgreSQL’s native indexing on the geometry elements. v.So we could add the following to the where clause.the_geom && m.the_geom
13Spatial Query Example -5 Spatial join exampleSELECT S.name FROM Senator S, Business BWHERE S.district.Area() > 300 AND Within(B.location, S.district)Non-Spatial Join exampleSELECT S.name FROM Senator S, Business BWHERE S.soc-sec = B.soc-sec AND S.gender = ‘Female’
14SDBMS vs GIS ?GIS is a software to visualize and analyze spatial data using spatial analysis functions such asSearch Thematic search, search by region, (re-)classificationLocation analysis Buffer, corridor, overlayTerrain analysis Slope/aspect, catchment, drainage networkFlow analysis Connectivity, shortest pathDistribution Change detection, proximity, nearest neighborSpatial analysis/Statistics Pattern, centrality, autocorrelation, indices of similarity, topology: hole descriptionMeasurements Distance, perimeter, shape, adjacency, directionGIS uses SDBMSto store, search, query, share large spatial data sets
15SDBMS vs GIS ? SDBMS focuses on Efficient storage, querying, sharing of large spatial datasetsProvides simpler set based query operationsExample operations: search by region, overlay, nearest neighbor, distance, adjacency, perimeter etc.Uses spatial indices and query optimization to speedup queries over large spatial datasets.SDBMS may be used by applications other than GISAstronomy, Genomics, Multimedia information systems, …
16Components of a SDBMS Recall: a SDBMS is a software module that can work with an underlying DBMSsupports spatial data models, spatial ADTs and a query language from which these ADTs are callablesupports spatial indexing, algorithms for processing spatial operations, and domain specific rules for query optimizationComponents includespatial data model, query language, query processing, file organization and indices, query optimization, etc.
17Three Layer Architecture Three-layer architecture to build a SDBMS on top of ORDBMSMMIS: Multimedia Information SystemCAD: Computer-aided design
18SDBMS Example Consider a spatial dataset with: County boundary (dashed white line)Census block - name, area, population, boundary (dark line)Water bodies (dark polygons)Satellite Imagery (gray scale pixels)Storage in a SDBMS table:create table census_blocks (name string,area float,population number,boundary polyline);What is the problem here?Unfortunately, such a table is not natural for a traditional relational database because polyline is not a built-in data type.
19Modeling Spatial Data in Traditional DBMS A row in the table census_blocksQuestion: Is Polyline datatype supported in DBMS?Hint: 1. Create a collection of tables with overlapping attributes or 2. use “stored procedures”
20Mapping “census_table” into a Relational Database