Module 19 Working with SQL Server® 2008 R2 Spatial Data.

Slides:



Advertisements
Similar presentations
Graphic Data Clean-Up Issues. Graphic Data Clean-up Very Important if you plan to use existing CAD or GIS data from another agency, department, or private.
Advertisements

The Role of Error Map and attribute data errors are the data producer's responsibility, GIS user must understand error. Accuracy and precision of map and.
Module 8 Importing and Exporting Data. Module Overview Transferring Data To/From SQL Server Importing & Exporting Table Data Inserting Data in Bulk.
Module 12: Auditing SQL Server Environments
Module 17 Tracing Access to SQL Server 2008 R2. Module Overview Capturing Activity using SQL Server Profiler Improving Performance with the Database Engine.
Module 6 Implementing Table Structures in SQL Server ®2008 R2.
Hope Foley Perpetual Technologies SQL Saturday #51 - Nashville.
Your Data Any Place, Any Time Delivering Location Intelligence with Spatial Data.
Spatial queries in SQL Server 2008 SQL Bits III – 13 th September 2008.
Geodatabases by Shawn J. Dorsch Spatial Databases Part 2.
Geog 458: Map Sources and Error January 18, 2006 Georeferencing.
19 th Advanced Summer School in Regional Science An introduction to GIS using ArcGIS.
Chapter 11 Data Management Layer Design
Module 9 Designing an XML Strategy. Module 9: Designing an XML Strategy Designing XML Storage Designing a Data Conversion Strategy Designing an XML Query.
Map Projections Displaying the earth on 2 dimensional maps
1 Nassau Community CollegeProf. Vincent Costa Acknowledgements: Introduction to Database Management, All Rights ReservedIntroduction to Database Management.
Rebecca Boger Earth and Environmental Sciences Brooklyn College.
Building Web Applications with SQL Azure David Robinson Senior Program Manager SQL Azure
Module 17 Storing XML Data in SQL Server® 2008 R2.
Overview SQL Server 2008 Overview Presented by Tarek Ghazali IT Technical Specialist Microsoft SQL Server MVP, MCTS Microsoft Web Development MCP ITIL.
Background in geospatial data modeling Presenter: Manolis Koubarakis Extended Semantic Web Conference 2012.
Module 8 Improving Performance through Nonclustered Indexes.
SQL Server 2008 Spatial Summary 2 Spatial Data Types (CLR UDT) Comprehensive set of Spatial Methods High Performance Spatial Indexes Spatial Library Sink/Builder.
Introduction to SQL Steve Perry
Taking Microsoft SQL Server into the World of Spatial Data Management Milan Stojic, Michael Rys Program Managers
Managing User and Service Accounts
Module 19 Managing Multiple Servers. Module Overview Working with Multiple Servers Virtualizing SQL Server Deploying and Upgrading Data-Tier Applications.
Module 7 Reading SQL Server® 2008 R2 Execution Plans.
Creating High Performance Spatial Databases with SQL Server 2008 Alastair Aitchison.
The OpenGIS Consortium Geog 516 Presentation #2 Rueben Schulz March 2004.
Virtual techdays INDIA │ august 2010 Developing with SQL Server Spatial & Deep Dive into Spatial Indexing Pinal Dave │ Mentor, Solid Quality Mentors.
Taking Microsoft SQL Server into the World of Spatial Data Management Michael Rys Principal Program Manager Microsoft DBI324.
Module 9 Designing and Implementing Stored Procedures.
How to Spatially Enable Your IBM Informix Database Chris Bosch.
Module 5 Planning for SQL Server® 2008 R2 Indexing.
Module 3 Designing a Physical Database Model. Module Overview Selecting Data Types Designing Database Tables Designing Data Integrity.
SQL access and working with ST_Geometry Functions
Module 10 Administering and Configuring SharePoint Search.
Module 18 Querying XML Data in SQL Server® 2008 R2.
Module 4 Designing and Implementing Views. Module Overview Introduction to Views Creating and Managing Views Performance Considerations for Views.
Module 3 Designing and Implementing Tables. Module Overview Designing Tables Working with Schemas Creating and Altering Tables.
Creating and Maintaining Geographic Databases. Outline Definitions Characteristics of DBMS Types of database Relational model SQL Spatial databases.
John Pickford IBM H11 Wednesday, October 4, :30. – 14:30. Platform: Informix Practical Applications of IDS Extensibility (Part 2 of 2)
Copyright © 2006 Pilothouse Consulting Inc. All rights reserved. Search Overview Search Features: WSS and Office Search Architecture Content Sources and.
URBDP 422 URBAN AND REGIONAL GEO-SPATIAL ANALYSIS Lecture 3: Building a GeoDatabase; Projections Lab Session: Exercise 3: vector analysis Jan 14, 2014.
Module 11 Authorizing Users to Access Resources. Module Overview Authorizing User Access to Objects Authorizing Users to Execute Code Configuring Permissions.
Geographic Data in GIS. Components of geographic data Three general components to geographic information Three general components to geographic information.
Session 1 Module 1: Introduction to Data Integrity
Microsoft Confidential Jon Jahren Produktsjef Applikasjonsplattform Microsoft.
Module 10 Merging Data and Passing Tables. Module Overview Using the MERGE Statement Implementing Table Types Using Table Types As Parameters.
Microsoft ® Official Course Module 9 Working with Business Connectivity Services.
GEOGRAPHY DATATYPES in SQL Server by jared nielsen linkedin.com/nielsendata.
Uploading Data Matthew Hanson  GeoNode made up of several components  Web Framework – Django  OGC Server – GeoServer  Database – PostGIS.
Chapter 3- Coordinate systems A coordinate system is a grid used to identify locations on a page or screen that are equivalent to grid locations on the.
Review of Projections and Coordinate Systems
Get Familiar with Spatial Data. Slava Murygin – SQL SlavaSQL.BlogSpot.com.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
GIS Project1 Physical Structure of GDB Geodatabase Feature datasets Object classes, subtypes Features classes, subtypes Relationship classes Geometric.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
DAT319 - Building Location-Aware Applications in SQL Server 2008: Introducing the Spatial Data Type Michael Rys Principal Program Manager SQL Server Engine,
Get Familiar with Spatial Data
Fast Track to SPATIAL Reporting!
Chapter 6 - Database Implementation and Use
Cameron Blashka| Informer Implementation Specialist
Spatial Data Types And Indexing SQL Server 2008
Spatial and temporal data management
Geography 413/613 Lecturer: John Masich
Module 10: Implementing Managed Code in the Database
Map Projections Displaying the earth on 2 dimensional maps
Presentation transcript:

Module 19 Working with SQL Server® 2008 R2 Spatial Data

Module Overview Introduction to Spatial Data Working with SQL Server Spatial Data Types Using Spatial Data in Applications

Lesson 1: Introduction to Spatial Data Target Applications Types of Spatial Data Planar vs. Geodetic OGC Object Hierarchy Spatial Reference Identifiers Demonstration 1A: Spatial Reference Systems

Target Applications There is a perception that spatial applications are quite separate to mainstream business applications Almost every business application can benefit from spatial data and functions  Locations of customers, stores, offices  All addresses  Intersections and distances Business Intelligence applications particularly benefit from spatial visualizations

Types of Spatial Data Vector vs. Raster Data  Vector – series of line segments  Raster – pixels or dots 2D, 3D, 4D

Planar vs. Geodetic Planar systems = Flat Earth Geodetic systems (e.g. GPS) = Round Earth

OGC Object Hierarchy Open Geospatial Consortium is the relevant industry body  OGC defined an object tree SQL Server data types are based on the Geometry hierarchy

Spatial Reference Identifiers Each spatial instance has a spatial reference identifier (SRID) SRID corresponds to a spatial reference system that is a way of performing measurements SRID 4326 is the WGS84 system (commonly implemented as the GPS system) SRID 0 is used when no system is needed (flat earth) When two spatial instances are used in a calculation, their SRIDs must match EPSG standard is used to define available SRIDs

Demonstration 1A: Spatial Reference Systems In this demonstration, you will see: The available Spatial Reference Identifiers The available units of measurement

Lesson 2: Working with SQL Server Spatial Data Types SQL Server Spatial Data System vs. User SQL CLR Types geometry Data Type geography Data Type Spatial Data Formats OGC Methods and Properties Microsoft Extensions Demonstration 2A: Spatial Data Types

SQL Server Spatial Data Data Types  geometry data type (flat Earth - planar)  geography data type (round Earth - geodetic) Bing Maps SDK updated SQL Server Reporting Services map control Microsoft.SqlServer.Types assembly OGC and Microsoft extension methods  ST prefix on OGC defined methods  No prefix on Microsoft extension methods

System vs. User SQL CLR Types System types are enabled regardless of ‘clr enabled’ setting geometry, geography, hierarchyid use large CLR object support Call properties and methods on CLR objects via: Calling MethodExample Instance.PropertyNewYork.STArea Instance.Method()Border.MakeValid() Type::StaticMethod()geometry::STGeomFromText() SELECT name, assembly_id, permission_set_desc, is_user_defined FROM sys.assemblies; SELECT name, assembly_id, permission_set_desc, is_user_defined FROM sys.assemblies;

geometry Data Type geometry; = geometry::STGeomFromText( 'POLYGON ((10 10, 10 30, 40 40, 20 10, 10 10))',0); geometry; = geometry::STGeomFromText( 'POLYGON ((10 10, 10 30, 40 40, 20 10, 10 10))',0); 2D data type STX and STY properties SRID is not relevant – defaults to zero Comprehensive OGC coverage

geography Data Type SELECT Border FROM dbo.Countries WHERE CountryName = 'Italy'; SELECT Border FROM dbo.Countries WHERE CountryName = 'Italy'; 2D data type Long and Lat properties Order is important for polygons Single value cannot span more than a single hemisphere

Spatial Data Formats Internal binary format of the spatial types not normally used directly Need to be able to input/output as strings Parsing  WKT – Well known text  WKB – Well known binary  GML – Geography markup language (XML variant)  Parse() assumes WKT Output  Options to output above formats including Z and M values  ToString() provides WKT

OGC Methods and Properties Common methods Common Collection Properties MethodDescription STDistanceThe distance between two shapes STIntersectsThe shape formed by the intersection of two shapes STAreaThe area of a shape STLengthThe length of a shape (for a polygon, the sum of the lengths of all sides) STUnionThe shape formed by uniting two shapes STBufferThe shape formed by providing a buffer region around a shape PropertiesDescription STPointNReturns a specific point in a collection of points STGeometryNReturns a specific geometric shape from a collection of geometries

Microsoft Extensions Microsoft has provided a number of extensions to the OGC defined methods and properties Common extensions: MethodDescription MakeValidReturns a valid shape from a potentially invalid shape ReduceReduces the complexity of a shape without changing its basic shape IsNullReturns if an object is NULL AsGmlReturns the object coded as GML (Geographic Markup Language) BufferWithToleranceReturns a buffer around an object but uses a tolerance value to allow for rounding errors

Demonstration 2A: Spatial Data Types In this demonstration, you will see how to work with SQL Server spatial data types

Lesson 3: Using Spatial Data in Applications Performance Issues in Spatial Queries Tessellation Process Spatial Indexes Implementing Spatial Indexes geometry Methods Supported by Spatial Indexes geography Methods Supported by Spatial Indexes Extending SQL Server Spatial Demonstration 3A: Spatial Data in Applications

Performance Issues in Spatial Queries Spatial queries can involve a large number of data points Imagine trying to locate streets that intersect your suburb or region Executing methods like STIntersects for a large number of points is slow How could you simplify the problem? Spatial indexes are designed to help avoid these unnecessary calculations

Tessellation Process Spatial indexes allow us to break large problems into ever smaller problems as we move through relevant levels SQL Server uses a four-level grid Tessellation rules are applied to eliminate areas not touched by the shape

Spatial Indexes Spatial indexes in SQL Server work in a two-phase method Primary filter  Finds all possible candidates  False positives are ok at this stage  No false negatives Secondary filter  Removes false positives  Applies the spatial method (that is, STIntersects) from the original predicate in your WHERE clause Filter method shows effectiveness of the Primary filter

Implementing Spatial Indexes CREATE SPATIAL INDEX IX_ObjectOutline_Shape ON dbo.ObjectOutline (Shape) WITH (BOUNDING_BOX=(0,0,512,512), GRIDS =(LOW,LOW,LOW,LOW)); CREATE SPATIAL INDEX IX_ObjectOutline_Shape ON dbo.ObjectOutline (Shape) WITH (BOUNDING_BOX=(0,0,512,512), GRIDS =(LOW,LOW,LOW,LOW)); Use the CREATE SPATIAL INDEX statement  geometry has a BOUNDING_BOX  ONLINE builds are not supported Can be useful to index one column more than once with different tessellation levels Table must have a clustered primary key

geometry Methods Supported by Spatial Indexes Not all methods benefit from spatial indexes Not all predicate forms benefit from spatial indexes Supported forms: geometry1.STContains(geometry2) = 1 geometry1.STDistance(geometry2) < number geometry1.STDistance(geometry2) <= number geometry1.STEquals(geometry2)= 1 geometry1.STIntersects(geometry2)= 1 geometry1.STOverlaps(geometry2) = 1 geometry1.STTouches(geometry2) = 1 geometry1.STWithin(geometry2)= 1

geography Methods Supported by Spatial Indexes Not all methods benefit from spatial indexes Not all predicate forms benefit from spatial indexes Supported forms: geography1.STIntersects(geography2)= 1 geography1.STEquals(geography2)= 1 geography1.STDistance(geography2) < number geography1.STDistance(geography2) <= number

Extending SQL Server Spatial Functions from CodePlex  IsValidGeographyFromGeometry, IsValidGeographyFromText, MakeValidGeographyFromGeography, MakeValidGeographyFromText, ConvexHullGeography, ConvexHullGeographyFromText, DensifyGeography, InterpolateBetweenGeog, InterpolateBetwenGeom, LocateAlongGeog, LocateAlongGeom, ShiftGeometry, VacuousGeographyToGeometry, VacuousGeometryToGeography Types from CodePlex  SqlProjection (Abers Equal Area, Equirectangular, Lambert Conformal Conic, Mercator, Oblique Mercator, Transverse Mercator, Gnomonic)  AffineTransform Aggregates from CodePlex  GeographyUnionAggregate, GeometryEnvelopeAggregate

Demonstration 3A: Spatial Data in Applications In this demonstration you will see how to use SQL Server spatial data to solve some business questions

Lab 19: Working with SQL Server Spatial Data Exercise 1: Familiarity With Geometry Data Type Exercise 2: Adding Spatial Data to an Existing Table Challenge Exercise 3: Business Application of Spatial Data (Only if time permits) Logon information Estimated time: 45 minutes

Lab Scenario Your organization has only recently begun to acquire spatial data within its databases. The new Marketing database was initially designed prior to the company beginning to implement spatial data. One of the developers has provided a table of the locations where prospects live. It is called Marketing.ProspectLocation. A second developer has added columns to it for Latitude and Longitude and geocoded the addresses. You will make some changes to the system to help support the need for spatial data.

Lab Review Where would you imagine you might use spatial data in your own business applications?

Module Review and Takeaways Review Questions Best Practices