Your SlideShare is downloading. ×
SQLBits X SQL Server 2012 Spatial
Upcoming SlideShare
Loading in...5

Thanks for flagging this SlideShare!

Oops! An error has occurred.


Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

SQLBits X SQL Server 2012 Spatial


Published on

SQLBits X Training Day Presentation on SQL Server 2012 Spatial …

SQLBits X Training Day Presentation on SQL Server 2012 Spatial

Copyright (c) Microsoft Corp.

Published in: Technology

1 Like
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

No notes for slide
  • Advances in technology have led to the proliferation of geographical services and devices, including online mapping solutions such as Microsoft Virtual Earth, and inexpensive global positioning system (GPS) solutions. Technology that was once focused towards geographic information system (GIS) specialists is now widely available to everyone for a variety of practical uses. There are two factors that bring new expectations and opportunities for software applications. The increase in user sophistication andThe ubiquity of geographical servicesSpatial information is just another component to be incorporated into applications and used as a basis for making better decisions and providing higher value services.
  • As previously mentioned, Spatial data can now be used for a variety of practical uses. The spatial support in Microsoft SQL Server 2008 can help users make better decisions through analysis of location data in scenarios such as: Customer-base management and development: i.e. visually analyze where your customers are in relation to sales reps or by territory. Environmental-related data impact, analysis, and planning: i.e.Environmental engineers canvisually display historical forest fire data on a map to better predict future threats.Financial and economic analysis in communities: i.e. Better understand the impact and/or payoff of building major developments within specific communities or areas through visual analysis.Government-based planning and development analysis:i.e. City planners can utilize spatial data to visually analyze transportation planning, zoning, population density, and housing data.Market segmentation and analysis: i.e. visually display cell phone usage by income level across a specified area or neighborhood.Scientific research study design and analysis: i.e. Researchers can incorporate spatial data for targeting participant recruitment, embed spatial-driven applications within surveys for location-related questions, and post-survey analysis. Real-estate development and analysis: i.e. Housing developers can visually compare housing density, sale prices, and zoning to make decisions about future development investments.
  • What exactly is Spatial data: Spatial data is used to represent points, lines, areas, and 3-dimensional structures on a surface. Most commonly, these elements relate to actual physical locations on Earth in which case they can be described a geospatial data. Most of us are familiar with this concept through the use of globes and maps, which generally show multiple geographic features and their relative locations.SQL Server 2008 supports two spatial data types: GEOGRAPHY and GEOMETRY.The GEOGRAPHY type Geodetic (“Round Earth”) geospatial model : the geodetic or round earth model provides the most accurate way to represent geographic features Define points, lines, and areas with longitude and latitude: these points can include a specific location like a restaurant, lines can be roads and power lines, and a polygon areas can include a lake or neighbourhood.Account for planetary curvature and obtain accurate “great circle” distances The GEOMETRY typePlanar (“Flat Earth”) geospatial model : To work with geospatial data on a flat, two dimensional surface, a projection is created to flatten the geographical objects on the spheroid. Define points, lines, and areas with coordinates on an arbitrary planeUse for localized areas or non-projected surfaces such as interior spacesThis kind of data is commonly found in regional mapping systems, such as the state plane system defined by the United States government, or for maps and interior floor plans where the curvature of the Earth does not need to be taken into account.Geometry side note: The geometry data type provides properties and methods that are compliant with the OGC Simple Features Specification for SQL, enabling you to perform operations on geometric data that produce industry-standard behavior. General Side note: There are a number of different geodetic models in use throughout the world, including the Airy 1830 ellipsoid used in the United Kingdom’s Ordnance Survey geographic system, and the WGS84 ellipsoid used by most of the world’s GPS solutions.
  • Both spatial data types in SQL Server 2008 provide a comprehensive set of instance and static methods that you can use to perform spatial queries and operations. For example, a variable named @ms of type geometry can be used to represent the area of the Microsoft campus. A query against a table of streets that includes a geometry column to define each street can be used to determine which streets intersect the campus This offers a quick visual analysis to end users.
  • Maybe something more from this post:
  • Aggregates demo
  • Related blog post
  • WPF = Windows Presentation Foundation  replaces Win Forms
  • Query performance against spatial data is further enhanced by the inclusion of spatial index support in SQL Server 2008. Spatial indexing built into query engine:You can index spatial data based on a grid-based, quad-tree  indexing model that is integrated into the SQL Server database engine. As shown by this conceptual model to the right, Spatial indexes consist of a grid-based hierarchy in which each level of the index subdivides the grid sector defined in the level above. The SQL Server query optimizer:For optimal performance, SQL Server makes cost-based decisions on which indexes to use for a given query Because spatial indexes are an integral part of the database engine, SQL Server can make cost-based decisions about whether or not to use a particular spatial index, just like any other index. This indexing method quickly eliminates unnecessary and irrelevant data from the query for improved performance.
  • With Microsoft SQL Server 2008, you can:Take advantage of comprehensive spatial supportgeometry and geography data typesMethods for spatial operationsBuild high performance spatial solutionsStore spatial data with business dataSpatial indexingExtend and integrate geospatial applicationsIndustry-standards compatibilityComprehensive programmatic library
  • Transcript

    • 1. The Business OpportunityIncreased Ubiquitous geographicaluser-sophistication technology• More data sources • GPS• More kinds of data • Online mapping services• Integrated systems and mash-ups • Availability of geographical data
    • 2. Customer-base management Real-estate and development development Environmental- and analysis related data impact, analysis, and planning Scientificresearch study Financial and design and economic analysis analysis in communities Market Government-based segmentation planning and and analysis development analysis
    • 3. Tree, Pole, Hydrant, POINT MULTIPOINT Valve Road, River,LINESTRING MULTILINESTRING Railway, Pipeline Cadastre, Park, POLYGON MULTIPOLYGON Administrative BoundaryCOLLECTION Graphics, Markups
    • 4. To match geometryMakeValid will convert them to valid objectsFULLGLOBE spatial object is available“small” holes can be created
    • 5. PointSTBuffer
    • 6. geo STDistancegeo STIntersects
    • 7. geography data type geometry data type•Geodetic (“Round Earth”) geospatial model: •Planar (“Flat Earth”) geospatial model •Ellipsoidal coordinates (Lat, Long, Z, M) •projected „flat map‟ (X, Y, Z, M)•Define points, lines, and areas with longitude and latitude •Define points, lines, and areas with coordinates•Account for planetary curvature and obtain accurate “great •Use for localized areas or non-projected surfaces such as circle” distances interior spaces
    • 8. The Mercator projection did not come out until 1569. Please play along 
    • 9. Well-Known-Binary: 0x0103000000010000000500000000000000004CDDC 000000000004C0D4100000000004CDD40000000000 04CDD4000000000C07A104100000000004CDD4000 00000000BD0F41000000000088134100000000004CD DC000000000004C0D41 Well-Known-Text: POLYGON(( -30000 240000, 30000 30000, 270000 30000, 260000 320000, -30000 240000)) GML: <Polygon xmlns=""> <exterior><LinearRing><posList> -30000 240000 30000 30000 270000 30000260000 320000 -30000 240000 </posList></LinearRing></exterior> </Polygon>
    • 10. GEOMETRYCOLLECTION (POLYGON ((228869.875 314609.75,228870.82875722542 314611.91763005778, 228852.73214285716314634.03571428568, 228869.875 314609.75)), LINESTRING(218999.875 310799.75, 218890.89169195751 310666.54817905917),POLYGON ((214987.51136363635 305790.84090909094, 215609.875305879.75, 215639.875 306329.75, 214987.51136363635305790.84090909094)), POLYGON ((214949.875 305759.75,214987.51136363635 305790.84090909094, 214922.60227272729305781.56818181818, 214949.875 305759.75)), …..
    • 11. CIRCULARSTRING(0 50, 90 50, 180 50, 270 50, 0 50) If a circular linestring encloses an area, curve polygon can be createdCURVEPOLYGON (CIRCULARSTRING (0 50, 90 50, 180 50, 270 50, 0 50)) Coordinate pair order is important for the geography type. This set of coordinates is ordered according to the “left foot rule” for exterior rings.
    • 12. Both types provide static and instance methods Calculate distances, find intersections, etc.Find streets that intersect the Microsoft campus SELECT StreetName FROM Streets WHERE Streets.StreetGeo.STIntersects(@ms) = 1
    • 13. STUnion STIntersectionBOOLEAN OPERATIONS STDifference STSymDifference STIntersects STContainsRELATION OPERATIONS STWithin STTouches STOverlaps STConvexHull STBufferCONSTRUCTIONS STReduce BufferWithCurves STDistance STLengthNUMERICAL STAreaOPERATIONS ShortestLineTo
    • 14. geometrygeography STCurveN(int n)Int STNumCurves()geometrygeography STCurveToLine()geometrygeography CurveToLineWithTolerance(int tolerance, bool relative)geometrygeography BufferWithCurves(double range)geometrygeography ShortestLineTo(geometrygeography other)Bool CompatibleWithDbCompatibilityLevel(int compatLevel)Bool STIsValid()Geography MakeValid()Bool STContains(geography other)Bool STWithin(geography other)Bool STOverlaps(geography other)Geography STConvexHull()Bool ReorientObject(geography other)
    • 15. BufferWithCurves()This method will construct theresulting polygon with circulararcs, often resulting in adramatically smaller spatialobject.DECLARE @g GEOGRAPHY =GEOGRAPHY::STGeomFromText(CIRCULARSTRING(0 50, 45 50,90 50),4326)DECLARE @b GEOGRAPHY = @g.BufferWithCurves(500000)SELECT @b.STNumPoints()--Number of vertices: 11DECLARE @g GEOGRAPHY =GEOGRAPHY::STGeomFromText(CIRCULARSTRING(0 50, 45 50,90 50),4326)DECLARE @b GEOGRAPHY = @g.STBuffer(500000)SELECT @b.STNumPoints()--Number of vertices: 257
    • 16. ReorientObject• This method will reverse the order of coordinates which define polygon rings.• This method is a NoOp on line strings, circular arcs and points.• This method does only work with the GEOGRAPHY type.
    • 17. geography::Point(lat, lon, 4326)geography::Point(lat, lon, 4326)
    • 18. geocoder
    • 19.
    • 20. aggregates
    • 21.
    • 22. Shape2SQLMapPoint Add-in for SQL ServerSAFE FMEESRI ArcGISPitney Bowes EasyLoader
    • 23. Take advantage of • geometry and geographycomprehensive spatial data types support • Methods for spatial operations • Store spatial data with business dataBuild high performance • Spatial indexing spatial solutions • Industry-standards compatibility Extend and integrate • Comprehensive programmatic librarygeospatial applications