Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

SQLBits X SQL Server 2012 Spatial

SQLBits X Training Day Presentation on SQL Server 2012 Spatial

Copyright (c) Microsoft Corp.

  • Login to see the comments

SQLBits X SQL Server 2012 Spatial

  1. 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. 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. 3. Tree, Pole, Hydrant, POINT MULTIPOINT Valve Road, River,LINESTRING MULTILINESTRING Railway, Pipeline Cadastre, Park, POLYGON MULTIPOLYGON Administrative BoundaryCOLLECTION Graphics, Markups
  4. 4. To match geometryMakeValid will convert them to valid objectsFULLGLOBE spatial object is available“small” holes can be created
  5. 5. PointSTBuffer
  6. 6. geo STDistancegeo STIntersects
  7. 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. 8. The Mercator projection did not come out until 1569. Please play along 
  9. 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="http://www.opengis.net/gml"> <exterior><LinearRing><posList> -30000 240000 30000 30000 270000 30000260000 320000 -30000 240000 </posList></LinearRing></exterior> </Polygon>
  10. 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. 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. 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. 13. STUnion STIntersectionBOOLEAN OPERATIONS STDifference STSymDifference STIntersects STContainsRELATION OPERATIONS STWithin STTouches STOverlaps STConvexHull STBufferCONSTRUCTIONS STReduce BufferWithCurves STDistance STLengthNUMERICAL STAreaOPERATIONS ShortestLineTo
  14. 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. 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. 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. 17. geography::Point(lat, lon, 4326)geography::Point(lat, lon, 4326)
  18. 18. geocoder webgis.usc.edu/Services/Geocode/About/GeocoderList.aspx
  19. 19. www.idvsolutions.com/products_spatialWiki.aspx
  20. 20. aggregates
  21. 21. www.geodata.gov www.openstreetmap.org www.census.gov/geo/www/cobdatamarket.azure.com
  22. 22. Shape2SQLMapPoint Add-in for SQL ServerSAFE FMEESRI ArcGISPitney Bowes EasyLoader
  23. 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

×