spatial data and geographic/spatial databases vania bogorny

Download Spatial Data and Geographic/Spatial Databases Vania Bogorny

If you can't read please download the document

Upload: silvester-warner

Post on 17-Jan-2018

228 views

Category:

Documents


2 download

DESCRIPTION

3 What is Spatial/Geographic data? Data which describes a location or a shape e.g. House, Hospital, Road, River, Forests, Parks, Soil Is something that describes objects or phenomena that happen on the Earth and that have associated a geographic position

TRANSCRIPT

Spatial Data and Geographic/Spatial Databases Vania Bogorny 2 What is a Spatial/Geographic Database? Database that: Stores spatial objects Provides operations to manipulate spatial objects Manipulates spatial objects just like other objects in the database 3 What is Spatial/Geographic data? Data which describes a location or a shape e.g. House, Hospital, Road, River, Forests, Parks, Soil Is something that describes objects or phenomena that happen on the Earth and that have associated a geographic position 4 Three main characteristics describe a geographic object: Non-spatial attributes (what): describe either quantitatively or qualitatively a geographic entity. This data may be treated by non- spatial databases; Spatial attribute (where): refers to the location and the representation of the geographic object, considering geometry and coordinate system. This aspect requires a specific data type not available in conventional DBMS; Spatial relationships (how): neighbourhood relationships (e.g. topology, distance). Requires special operations that are not available in conventional DBMS; What is Spatial/Geographic data? 5 How are spatial data represented? Points, Lines, Polygons, and complex geometries. 6 Spatial Representation: object 0-dimensional representation: point E.g.: school, hospital, Uni-dimensional representation: line E.g.: river, road Bi-dimensional representation: polygon E.g.: state, city Tri-dimensional representation: surface E.g.:building 7 Spatial Representation: field clula Irregular points (e.g. temperature) Adjacent polygons (e.g. soil) Regular Points Grid Triangual Network(e.g. ) Isoline (e.g. relief) 8 Example: Geographic Data and Geographic Database Street GidNameShape 1IjuiMultiline [(x1,y1),(x2,y2),..] 2LavrasMultiline [(x1,y1),(x2,y2),..] WaterResource GidNameShape 1JacuiMultiline [(x1,y1),(x2,y2),..] 2GuaibaMultiline [(x1,y1),(x2,y2),..] 3UruguaiMultiline [(x1,y1),(x2,y2),..] GasStation Gid Name VolDiesel VolGas Shape 1 BR Point[(x1,y1)] 2 IPF Point[(x1,y1)] 3 Esso Point[(x1,y1)] 9 Districts are represented as green polygons Slums are represenetd as yellow polygons Water bodies are represented as blue lines Example of geographic data 10 Districts, Squares and Trees Example of geographic data 11 Districts and Slums Example of geographic data 12 Districts and Hospitals Example of geographic data 13 Combination of some previous data Overlay of Geographic Data 14 Maps as Layers 15 Spatial Relationships Main characteristic which differs spatial data from non-spatial data 16 District contains soccer field Viaduct intersects road OR Road crosses viaduct Disjuno Crosses relationship 17 18 Spatial Relationships What is the average distance between industrial repositories and water collecting points? 19 Spatial Relationships How distant are water bodies (blue line) from industrial repository (pink dot) ? 20 Spatial Relationships Which is the closest put to my house? 21 Main Spatial Relationships B C A BnorthA CsoutheastA B C A BnorthA CsoutheastA Order Distance C B d C B d B A touches A B overlaps B inside A contains B A crosses A B equals A B B A overlaps inside A contains A B disjoint A B disjoint B A crosses A B equals A B Topological 22 Advantages of Spatial Databases Spatial querying using SQL use simple SQL expressions to determine spatial relationships distance order topology use simple SQL expressions to perform spatial operations area length intersection union buffer 23 Original Polygons UnionIntersection Examples of Spatial Operations 24 Rivers Buffered Rivers Examples of Spatial Operations 25 Spatial Databases ESRI ArcSDE (on top of several different DBs) Oracle Spatial IBM DB2 Spatial Extender Informix Spatial DataBlade MS SQL Server (with ESRI SDE) Geomedia on MS Access PostGIS / PostgreSQL 26 Spatial Query Language Spatial query language Spatial data types, e.g. point, linestring, polygon, Spatial operations, e.g. overlap, distance, nearest neighbor, SELECTS.name FROMStates S WHERE area(s.the_geom) > 300 Standards OGIS is a standard for spatial data types and operators 27 Spatial Query Example Q1: For all rivers in the relation River, which countries do they pass? select r.name,c.cntry_name from river r, country c where crosses (r.the_geom,c.the_geom) = 'True' name | cntry_name Pembina | United States Pembina | Canada Rainy | United States Rainy | Canada Souris | United States Souris | Canada Red River of the North | United States Red River of the North | Canada (8 rows) 28 Spatial Query Example Q2: Find the names of all countries which are neighbors of the United States (USA) select c1.cntry_name as USA_Neighbors from country c1, country c2 where touches(c1.the_geom,c2.the_geom)='True' and c2.cntry_name='United States'; usa_neighbors Canada (1 row) Como criar um BDG no PostgreSQL 1) createdb -E SQL_ASCII -T template_postgis -Uusername nomeDaBase ou criar via PGADMIN 2) importao dos dados geogrficos: Transformao dos arquivos shape em.sql (Fazer isso para todos os arquivos.shp) a) shp2pgsql -I arquivo.shp nomeDaTabela > tabela.sql Importao para o banco de dados: b) psql -Uusuario nomeDaBase