UNIT - 5 : 20ACS04 – PROBLEM SOLVING AND PROGRAMMING USING PYTHON
Sql Server 2008 Spatial Analysis
1. SQL Server 2008 Spatial Analysis Dan Crawford Integrated Network Strategies dcrawford@insindy.com http://www.insindy.com
2. What is spatial data? Geometric Represents data in a 2D plain, similar to graph paper in high school. Units are user-defined and could be inches, miles, pixels, etc.
3. What is spatial data? Geographic Represents data points using angles of Latitude and Longitude. Latitude measures North/South, and Longitude measures degrees East/West of Prime Meridian
4. System Requirements SQL Server 2008 Express or higher – recommend R2 to use maps in SSRS Dev Tools Visual Studio 2005, 2008, or 2010 SQL Management Studio 2008 Now supported on SQL Azure
5. Uses of spatial data Used by central cancer registries for statistical analysis with other geography specific data sources, such as census data Integrated route mapping with MapPoint, Google Maps, etc Geographical business intelligence analytics
6. Geometry data type Geometry data type stores points, lines, polygons, and collections of geometric objects Represent using WKT (well-known text), WKB (well-known binary), or GML (geography markup language) WKT seems to be most common
10. Geocoding Geography data type does not directly understanding mailing address data Mailing addresses must be converted to latitude/longitude coordinates Geocoding = conversion of geographic data like address or zip code to geographic coordinates Options – MapPoint/Bing Map Services, Google Maps API, many others
11. Rendering Options SQL Management Studio 2008 – very basic for query testing VirtualEarth Google Maps or similar 3rd party mapping component (e.g. Dundas) SSRS/Report Builder in R2
13. Spatial Indexing CREATE SPATIAL INDEX SPATIAL_Hospitals ON dbo.Hospitals(LocationGeography) USING GEOGRAPHY_GRID WITH( GRIDS = ( LEVEL_1 = MEDIUM, LEVEL_2 = MEDIUM, LEVEL_3 = MEDIUM, LEVEL_4 = MEDIUM), CELLS_PER_OBJECT = 16, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
14. Spatial Indexing - Utilization SELECT * FROM Hospitals WITH (INDEX(SPATIAL_Hospitals)) WHERE LocationGeography.STIntersects(@P.STBuffer(@eps*1609.344)) = 1
15. Goal of Geographic Analysis “I want SQL Server to tell me when there are clusters of geographic data points and where they are located.” - Dan Crawford, 2010
16. It’s easy to see points on a map with SQL Server
17. Why use cluster analysis? Analysis of injury severity and hospital resource use in a regional health care system Customer purchasing patterns Choosing a business or advertising location Crime analysis Easy visualization for dashboard
21. DBSCAN DBSCAN(D, eps, MinPts) C = 0 for each unvisited point P in dataset D mark P as visited N = getNeighbors (P, eps) if sizeof(N) < MinPts mark P as NOISE else C = next cluster expandCluster(P, N, C, eps, MinPts) Source: http://en.wikipedia.org/wiki/DBSCAN
22. DBSCAN (cont’d) expandCluster(P, N, C, eps, MinPts) add P to cluster C for each point P' in N if P' is not visited mark P' as visited N' = getNeighbors(P', eps) if sizeof(N') >= MinPts N = N joined with N' if P' is not yet member of any cluster add P' to cluster C Source: http://en.wikipedia.org/wiki/DBSCAN
23.
24. To make life easier Report Builder 3.0 SQL Server Spatial Tools – http://sqlspatialtools.codeplex.com