PostGIS and Spatial Queries Steve Signell, Instructor Robert Poirier, TA School of Science Rensselaer Polytechnic Institute.

Slides:



Advertisements
Similar presentations
Yukon – What is New Rajesh Gala. Yukon – What is new.NET Framework Programming Data Types Exception Handling Batches Databases Database Engine Administration.
Advertisements

Relational Algebra Relational algebra consists of a set of relational operators Each operator has one or more relations as input and creates a new relation.
What is a Database By: Cristian Dubon.
Introduction To SQL Lynnwood Brown President System Managers LLC Copyright System Managers LLC 2003 all rights reserved.
Introduction to Structured Query Language (SQL)
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Query-By-Example (QBE) 2440: 180 Database Concepts.
Midterm Review Lecture 14b. 14 Lectures So Far 1.Introduction 2.The Relational Model 3.Disks and Files 4.Relational Algebra 5.File Org, Indexes 6.Relational.
Chapter 8 Special-Purpose Languages. SQL SQL stands for "Structured Query Language". Allows the user to pose complex questions of a database. It also.
Introduction to Structured Query Language (SQL)
Structured query language This is a presentation by JOSEPH ESTRada on the beauty of Structured Query Language.
Geographic Information Systems
Introduction to Structured Query Language (SQL)
1 Chapter 2 Reviewing Tables and Queries. 2 Chapter Objectives Identify the steps required to develop an Access application Specify the characteristics.
Concepts of Database Management Sixth Edition
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Advance Computer Programming Java Database Connectivity (JDBC) – In order to connect a Java application to a database, you need to use a JDBC driver. –
Concepts of Database Management, Fifth Edition
Spatial Databases ENVE/CE 424/524. Definitions Database – an integrated set of data on a particular subject Spatial database - database containing geographic.
Introduction to SQL Steve Perry
Analyzing Data For Effective Decision Making Chapter 3.
Computer Science 101 Database Concepts. Database Collection of related data Models real world “universe” Reflects changes Specific purposes and audience.
Data Scrounging 101 Steve Signell, Instructor Robert Poirier, TA School of Science Rensselaer Polytechnic Institute Monday,
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
Concepts of Database Management Seventh Edition
5/24/01 Leveraging SQL Server 2000 in ColdFusion Applications December 9, 2003 Chris Lomvardias SRA International
PostGIS and Spatial Queries Steve Signell, Instructor Robert Poirier, TA School of Science Rensselaer Polytechnic Institute.
SQL access and working with ST_Geometry Functions
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
Unit 6 Data Storage Design. Key Concepts 1. Database overview 2. SQL review 3. Designing fields 4. Denormalization 5. File organization 6. Object-relational.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
BACS 287 Structured Query Language 1. BACS 287 Visual Basic Table Access Visual Basic provides 2 mechanisms to access data in tables: – Record-at-a-time.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
5. Simple SQL using Oracle1 Simple SQL using Oracle 5. Working with Tables: Data management and Retrieval 6. Working with Tables: Functions and Grouping.
Creating and Maintaining Geographic Databases. Outline Definitions Characteristics of DBMS Types of database Relational model SQL Spatial databases.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Computing & Information Sciences Kansas State University Monday, 17 Sep 2007CIS 560: Database System Concepts Lecture 12 of 42 Monday, 18 February 2008.
John Pickford IBM H11 Wednesday, October 4, :30. – 14:30. Platform: Informix Practical Applications of IDS Extensibility (Part 2 of 2)
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
Troubleshooting: Web maps & Joins Steve Signell, Instructor Robert Poirier, TA School of Science Rensselaer Polytechnic.
Literate Programming and the Process of GIS Steve Signell, Instructor Robert Poirier, TA School of Science Rensselaer.
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Aliya Farheen October 29,2015.
SqlExam1Review.ppt EXAM - 1. SQL stands for -- Structured Query Language Putting a manual database on a computer ensures? Data is more current Data is.
Lecture 10 Creating and Maintaining Geographic Databases Longley et al., Ch. 10, through section 10.4.
9-1 © Prentice Hall, 2007 Topic 9: Physical Database Design Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
Oracle & SQL. Oracle Data Types Character Data Types: Char(2) Varchar (20) Clob: large character string as long as 4GB Bolb and bfile: large amount of.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
 CONACT UC:  Magnific training   
Oracle Spatial Extension of the RDBMS Oracle by spatial data types and operations –introduced in version 8 (current version.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
Lesson 3 GIS Fundamentals MEASURE Evaluation PHFI Training of Trainers May 2011.
PostGIS and Spatial Queries
PostGIS and Spatial Queries
SQL Query Getting to the data ……..
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
SQL in Oracle.
Geographic Information Systems
Prof: Dr. Shu-Ching Chen TA: Yimin Yang
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Prof: Dr. Shu-Ching Chen TA: Haiman Tian
Database systems Lecture 3 – SQL + CRUD
Access: SQL Participation Project
Structured Query Language – The Fundamentals
Introduction To Structured Query Language (SQL)
Contents Preface I Introduction Lesson Objectives I-2
IST 318 Database Administration
Introduction to SQL Server and the Structure Query Language
Presentation transcript:

PostGIS and Spatial Queries Steve Signell, Instructor Robert Poirier, TA School of Science Rensselaer Polytechnic Institute Monday, March 3, 2014 GIS in the Sciences ERTH 4750 (38031)

Spatial Databases PostGIS is a spatial database. Oracle Spatial and SQL Server 2008 are also spatial databases. But what does that mean; what is it that makes an ordinary database a spatial database? The short answer, is... Spatial databases store and manipulate spatial objects like any other object in the database.

Databases & SQL: Review The four “verbs” of SQL (Structured Query Language) SELECT, returns rows in response to a query INSERT, adds new rows to a table UPDATE, alters existing rows in a table DELETE, removes rows from a table

Databases & SQL: Review SELECT QUERIES Required: SELECT (field(s)) FROM (tables) Optional: JOIN (combines two FROM items) WHERE (conditions) GROUP BY (fields– used for AGGREGATE functions) ORDER BY (field(s)) LIMIT (# rows returned)

JOIN Combines two FROM items (tables) using a common identifier. Usage:

WHERE… WHERE…. ALSO: BETWEEN x AND y Mathematical functions (+ - * /, etc.) See math.htmlhttp:// math.html OperatorDescription <less than >greater than <=less than or equal to >= greater than or equal to =equal <> or !=not equal

Aggregate Functions AGGREGATE functions: compute a single result from a set of input values aggregate.html avg(), sum(), min(), count() Also statistics: corr(), regr_slope(), stdev() Always have a ‘GROUP BY’ in the SQL statement

Spatial Databases 1. Spatial data types refer to shapes such as point, line, and polygon; 2. Multi-dimensional spatial indexing is used for efficient processing of spatial operations; 3. Spatial functions, posed in SQL, are for querying of spatial properties and relationships.SQL

Spatial Indexing Spatial indexing & Bounding Boxes Answering the question “is A inside B?” is very computationally intensive for polygons but very fast in the case of rectangles. Even the most complex polygons and linestrings can be represented by a simple bounding box.

Spatial Functions Conversion: Functions that convert between geometries and external data formats. Management: Functions that manage information about spatial tables and PostGIS administration. Retrieval: Functions that retrieve properties and measurements of a Geometry. Comparison: Functions that compare two geometries with respect to their spatial relation. Generation: Functions that generate new geometries from others.

Conversion Functions Well-known text (WKT)WKT ST_GeomFromText(text, srid) returns geometry ST_AsText(geometry) returns text ST_AsEWKT(geometry) returns text Well-known binary (WKB)WKB ST_GeomFromWKB(bytea) returns geometry ST_AsBinary(geometry) returns bytea ST_AsEWKB(geometry) returns bytea Geographic Mark-up Language (GML)GML ST_GeomFromGML(text) returns geometry ST_AsGML(geometry) returns text Keyhole Mark-up Language (KML)KML ST_GeomFromKML(text) returns geometry ST_AsKML(geometry) returns text GeoJSON ST_AsGeoJSON(geometry) returns text Scalable Vector Graphics (SVG)SVG ST_AsSVG(geometry) returns text

Management Functions AddGeometryColumnAddGeometryColumn - Adds a geometry column to an existing table of attributes. DropGeometryColumnDropGeometryColumn - Removes a geometry column from a spatial table. DropGeometryTableDropGeometryTable - Drops a table and all its references in geometry_columns. PostGIS_VersionPostGIS_Version - Returns PostGIS version number and compile-time options. Populate_Geometry_ColumnsPopulate_Geometry_Columns - Ensures geometry columns have appropriate spatial constraints and exist in the geometry_columns table. Probe_Geometry_ColumnsProbe_Geometry_Columns - Scans all tables with PostGIS geometry constraints and adds them to the geometry_columns table if they are not there. UpdateGeometrySRIDUpdateGeometrySRID - Updates the SRID of all features in a geometry column, geometry_columns metadata and srid table constraint

Management Functions AddGeometryColumnAddGeometryColumn - Adds a geometry column to an existing table of attributes. DropGeometryColumnDropGeometryColumn - Removes a geometry column from a spatial table. DropGeometryTableDropGeometryTable - Drops a table and all its references in geometry_columns. PostGIS_VersionPostGIS_Version - Returns PostGIS version number and compile-time options. Populate_Geometry_ColumnsPopulate_Geometry_Columns - Ensures geometry columns have appropriate spatial constraints and exist in the geometry_columns table. Probe_Geometry_ColumnsProbe_Geometry_Columns - Scans all tables with PostGIS geometry constraints and adds them to the geometry_columns table if they are not there. UpdateGeometrySRIDUpdateGeometrySRID - Updates the SRID of all features in a geometry column, geometry_columns metadata and srid table constraint

Retrieval Functions ST_AreaST_Area: Returns the area of the surface if it is a polygon or multi-polygon. For “geometry” type area is in SRID units. For “geography” area is in square meters. ST_LengthST_Length: Returns the 2d length of the geometry if it is a linestring or multilinestring. geometry are in units of spatial reference and geography are in meters (default spheroid) ST_NPointsST_NPoints: Returns the number of points (vertexes) in a geometry. ST_NumGeometriesST_NumGeometries: If geometry is a GEOMETRYCOLLECTION (or MULTI*) returns the number of geometries, otherwise return NULL. ST_PerimeterST_Perimeter: Returns the length measurement of the boundary of an ST_Surface or ST_MultiSurface value. (Polygon, Multipolygon) ST_StartPointST_StartPoint: Returns the first point of a LINESTRING geometry as a POINT. ST_XST_X: Returns the X coordinate of the point, or NULL if not available. Input must be a point. ST_YST_Y: Returns the Y coordinate of the point, or NULL if not available. Input must be a point.

Comparison Functions Questions like “Which are the closet bike racks to a park?” or “Where are the intersections of subway lines and streets?” can only be answered by comparing geometries representing the bike racks, streets, and subway lines. Other Questions: “What neighborhood and borough is Atlantic Commons in?” “What streets does Atlantic Commons join with?” “Approximately how many people live on (within 50 meters of) Atlantic Commons?”

Comparison Functions

BREAK

Part II: Demos Lean-tos Campsites Trail Registers Aquatic Invasives

Questions? 24 Homework for Thursday 1 page proposal for group Project Sections 1-9, Boundless PostGIS Tutorial