GEOGRAPHY DATATYPES in SQL Server. by jared nielsen linkedin.com/nielsendata

Similar documents
Mississippi Private Schools 2015

Introduction to Using PostGIS Training Workbook Last Updated 18 June 2014

City of Tigard. GIS Data Standards

University of Arkansas Libraries ArcGIS Desktop Tutorial. Section 5: Analyzing Spatial Data. Buffering Features:

Studying Topography, Orographic Rainfall, and Ecosystems (STORE)

Big Data: Using ArcGIS with Apache Hadoop. Erik Hoel and Mike Park

GeoPackage, The Shapefile Of The Future

Pro Spatial with SQL Server 2012

Oracle Spatial 10g. An Oracle White Paper August 2005

New York City Neighborhood Tabulation Areas

SQL SUPPORTED SPATIAL ANALYSIS FOR WEB-GIS INTRODUCTION

3.6A Calling Geodetic Location

HELCOM Data and Map Service. User Manual

Primitive type: GEOMETRY: matches SDO_GEOMETRY and GEOMETRY_COLUMN types.

GEOGRAPHIC INFORMATION SYSTEMS CERTIFICATION

Building a Spatial Database in PostgreSQL

Quick and Easy Web Maps with Google Fusion Tables. SCO Technical Paper

Cookbook 23 September 2013 GIS Analysis Part 1 - A GIS is NOT a Map!

An Introduction to Open Source Geospatial Tools

ADWR GIS Metadata Policy

Buurten van gemeente Groningen

Lecture 2. Map Projections and GIS Coordinate Systems. Tomislav Sapic GIS Technologist Faculty of Natural Resources Management Lakehead University

LNG Terminals. File Geodatabase Feature Class. Tags natural gas, lng, liquid natural gas, terminals

GIS EXAM #2 QUERIES. Attribute queries only looks at the records in the attribute tables to some kind of

Introduction to PostGIS

Data Visualization Techniques and Practices Introduction to GIS Technology

Reef Explorer User Guide

Software: AutoCAD Civil 3D 2014, NRCS C3D 2014 template, ESRI ArcMap. Notation:Button to Press Displayed Text Icon Action {Text to Enter} Menu Item

Data Integration for ArcGIS Users Data Interoperability. Charmel Menzel, ESRI Don Murray, Safe Software

Finding GIS Data and Preparing it for Use

Geodatabase Programming with SQL

Introduction to GIS.

ArcGIS online Introduction Module 1: How to create a basic map on ArcGIS online Creating a public account with ArcGIS online...

Contents. The OWRB Floodplain Viewer. Creating Maps Helpful Tips... 10

There are various ways to find data using the Hennepin County GIS Open Data site:

Introduction to GIS (Basics, Data, Analysis) & Case Studies. 13 th May Content. What is GIS?

Chapter 6: Data Acquisition Methods, Procedures, and Issues

Questions. Strategies August/September Number Theory. What is meant by a number being evenly divisible by another number?

Bentley ArcGIS. Connector

RDS Migration Tool Customer FAQ Updated 7/23/2015

Creating a File Geodatabase

Guide to Viewing Maps in Google Earth

GIS III: GIS Analysis Module 2a: Introduction to Network Analyst

Spatial Database Support

Vehicle Tracking Using ArcIMS and Geocortex IMF: A Winning Combination. Combination

EasyLoader. Version Easy Loader User Guide

GIS Introduction to Geographic Information Systems Last Revision or Approval Date - 9/8/2011

SQL/MM Spatial: The Standard to Manage Spatial Data in Relational Database Systems

Introduction to GIS Mapping and ESRI s ArcGIS Software

GIS III: GIS Analysis Module 1a: Network Analysis Tools

The manual can be used as a practical tutorial and aims to teach users how to:

PLOTTING SURVEYING DATA IN GOOGLE EARTH

UNLEASHED. The Field Calculator. By Tom Neer, EDAW, Inc.

GIS Databases With focused on ArcSDE

Documentation of open source GIS/RS software projects

Using GIS to Develop a Control Map and Database

OpenGIS Implementation Specification for Geographic information - Simple feature access - Part 2: SQL option

Tutorial 8 Raster Data Analysis

A Web services solution for Work Management Operations. Venu Kanaparthy Dr. Charles O Hara, Ph. D. Abstract


Microsoft SQL Server Connector for Apache Hadoop Version 1.0. User Guide

Geofencing Extension API

A WEB GIS FOR WETLANDS OF KERALA USING OPEN SOURCE GEOSPATIAL SOFTWARE. Santosh Gaikwad* and S Narendra Prasad**

database abstraction layer database abstraction layers in PHP Lukas Smith BackendMedia

Chapter 5 Spatial is not Special: Managing Tracking Data in a Spatial Database

MapInfo SpatialWare Version 4.6 for Microsoft SQL Server

GIS Data in ArcGIS. Pay Attention to Data!!!

Maintaining High Accuracy in Modern Geospatial Data

Big Data and Analytics: A Conceptual Overview. Mike Park Erik Hoel

GIS I Business Exr02 (av 9-10) - Expand Market Share (v3b, Jul 2013)

Metadata for Big River Watershed Geologic and Geomorphic Data

Terry Sherman Oklahoma South Central Arc-Users Group th Annual Conference 9/23/2014

Project Zip Code. Version CUNA s Powerful Grassroots Program. User Manual. Copyright 2012, All Rights Reserved

ELECTRONIC JOURNAL OF POLISH AGRICULTURAL UNIVERSITIES

Measuring the Earth Using a GPS M. Scott Wilkerson & M. Beth Wilkerson, DePauw University, May 10, 2007

Remote Sensitive Image Stations and Grid Services

10. Creating and Maintaining Geographic Databases. Learning objectives. Keywords and concepts. Overview. Definitions

Using Geocoded TIFF & JPEG Files in ER Mapper 6.3 with SP1. Eric Augenstein Earthstar Geographics Web:

Supporting coolest GEOS v advanced features (and other miscellaneous stuff)

PostgreSQL as an integrated data analysis platform

1. To start Installation: To install the reporting tool, copy the entire contents of the zip file to a directory of your choice. Run the exe.

Exploring GIS Integration Options for SAP BusinessObjects

The Attendance Management System Based on Micro-cellular and GIS technology

GIS. Digital Humanities Boot Camp Series

Raster to Vector Conversion for Overlay Analysis

What is GIS? Geographic Information Systems. Introduction to ArcGIS. GIS Maps Contain Layers. What Can You Do With GIS? Layers Can Contain Features

What is GIS. What is GIS? University of Tsukuba. What do you image of GIS? Copyright(C) ESRI Japan Corporation. All rights reserved.

Technical Article Developing Software for the CN3 Integrated GPS Receiver

Websense SQL Queries. David Buyer June 2009

Getting Started with Oracle Spatial

Contouring and Advanced Visualization

Contents WEKA Microsoft SQL Database

Earth Coordinates & Grid Coordinate Systems

SWAMP DATA MANAGEMENT PLAN

Transcription:

GEOGRAPHY DATATYPES in SQL Server by jared nielsen linkedin.com/nielsendata

GEOGRAPHY vs GEOMETRY Geography Plots ellipsoidal Round Earth data using latitude, longitude and altitude* coordinates Geometry Plots polygonal, geometric and linear data using X, Y and Z* coordinates * not implemented well

Measuring the Earth Coordinates Longitude = X Latitude = Y Altitude = Z

Measuring the Earth Ranges Longitude = 0 to 360 Latitude = 90 to -90 Altitude = 0 to (ft)

World Geodetic System Global standards body that defines the coordinate systems for Earth The latest revision is WGS 84 - referred to as EPSG:4326 www.nga.mil

EPSG: 4326 This geodetic standard is specified in many geography datatype queries: UPDATE SQLDevelopers SET GeoPosition = geography:: Point(29.5786422, -95.2049992, 4326)

BASIC GIS CONCEPTS Well Known Text ESRI Shape and Data Sources

Well Known Text - WKT Type Example Convert to Spatial Point Point(x,y).STPointFromText() MultiPoint MultiPoint( (x,y), (x,y) ).STMPointFromText() LineString LineString( x y, x y, x y).stlinefromtext() MultiLineString MultiLineString( (x y, x y) (x y, x y) ).STMLineFromText() Polygon Polygon ( (x1 y1, x2 y2, x3 y3, x1 y1) ).STPolyFromText() MultiPolygon You get the idea Keep using those parenthesis.stmpolyfromtext() www.nga.mil

How LONG is your LAT? Sometimes you should use LON/LAT (WKT) Other times you need to use LAT/LON (SQL) LAT LON San Jacinto College = 29.578, -95.204 SET GeoPosition = geography:: STGeomFromText('POINT(-95.204 29.578)', 4326) SET GeoPosition = geography:: Point(29.578, -95.204, 4326)

Get Some Data Positions for the International Space Station: http://sscweb.gsfc.nasa.gov/cgi-bin/locator.cgi Global Country Maps: http://www.vdstech.com/world-data.aspx Zip Codes, School Districts, Demographics: http://www.data.gov Railroads, Rivers, Cities, Volcanoes: http://webgis.wr.usgs.gov/globalgis/datasets.htm

ESRI Shapefile Converters Convert ESRI Shapefiles to SQL Geography: http://www.sharpgis.net/page/shape2sql Queries SQL Geography to a Map: http://www.sharpgis.net/page/sqlspatial-query-tool ESRI Metadata Translation: http://resources.esri.com/help/9.3/arcgisengine/ java/gp_toolref/conversion_tools/ esri_metadata_translator_conversion_.htm

SQL SERVER SPATIAL Make a Table Load Data Query Spatial-ly

Making a Table CREATE TABLE dbo.issposition( Longitude decimal(18, 15) NULL, Latitude decimal(18, 15) NULL, Sampled datetime NULL, LocalTime nvarchar(50) NULL, GeoPosition geography NULL, GeomShape geometry NULL )

Loading Data INSERT INTO ISSPosition (Sampled, Longitude, Latitude, LocalTime) VALUES ('01/01/2015 00:00:00',-125.4,41,'15:38:18 ) Naturally I loaded more data one data point per minute from January 1 to present It turns out that the Space Station falls fast at 17,136 mph

Convert to Geography UPDATE ISSPosition SET GeoPosition = geography:: Point([Latitude], [Longitude], 4326) GO (note we are using the native SQL Point method so we keep LAT/LON)

Query our Data select top 180 * from dbo.issposition Not the most thrilling outcome Let s try the Spatial Results Tab

Spatial Results Tab select top 180 * from dbo.issposition Still not that exciting a bunch of dots

Space Station Orbit select top 180 * from dbo.issposition order by Sampled Now we are getting somewhere!

Comma Delimited Points DECLARE @ISSOrbitWKT nvarchar(max) SELECT @ISSOrbitWKT = STUFF((SELECT TOP 180 ',' + Convert(nvarchar(25),Longitude) + ' ' + Convert(nvarchar(25),Latitude) FROM dbo.issposition ORDER BY Sampled FOR XML PATH('')),1,1,'')

Convert Points to LineStrings DECLARE @ISSOrbit geography SET @ISSOrbit = geography::stlinefromtext('linestring(' +@ISSOrbitWKT+')',4326)

Space Station Orbit SELECT @ISSOrbit Now you have connected points in a linestring showing the orbit

Space Station Orbit CREATE TABLE CoolShapes( Name Nvarchar(100) NOT NULL, GeoShape geography NULL) GO INSERT into CoolShapes (Name, GeoShape) values ( ISS Orbital Path,@ISSOrbit) I like this shape so much I m going to keep a copy of it

World Geography Global Datasets From ESRI Shapefiles

Load Global Maps

Load Global Maps select @ISSOrbit union all select GeoMap from dbo.world With a UNION, we simply plot the orbit on the Global ESRI Shapefile Map http://www.vdstech.com/world-data.aspx

GEOGRAPHY Case Studies INTERSECTION BUFFERS

Spatial Methods Type Example Syntax Buffer @IISOrbit.STBuffer(75000).STBuffer(radius) Intersect @IISOrbit.STIntersection(@China).STIntersection(object) Distance @China.STDistance(@Guatemala).STDistance(object) Crosses @IISOrbit.Crosses(@China).STCrosses(object) Within Contains @SQLDeveloper.STWithin(@SanJac intocollege.stbuffer(4000)) @SanJacintoCollege.STContains( @Jared).STWithin(object).STContains(object) www.nga.mil

STIntersection Method SELECT @ISSOrbit UNION ALL SELECT GeoMap FROM World WHERE Name='China' A human knows that the orbit crosses China, but how do we tell the computers? http://www.vdstech.com/world-data.aspx

STIntersection Method SELECT @ISSOrbit.STIntersects(@China) We know it intersects but WHERE? http://www.vdstech.com/world-data.aspx

STIntersection Method SELECT @ISSOrbit.STDifference(@China).STIntersection(@China) Can you see them? http://www.vdstech.com/world-data.aspx

STIntersection Method SELECT @ISSOrbit.STDifference(@China).STIntersection(@China).STBuffer(75000) UNION ALL SELECT @China Let s add a few.stbuffer(s) http://www.vdstech.com/world-data.aspx

MAKING IT LOCAL San Jacinto College

Make Some Developers insert into SQLDevelopers (Name, Latitude, Longitude, Altitude) values ('Jared Nielsen Dark Matter', 29.5786422, -95.2049992, 15) insert into SQLDevelopers (Name, Latitude, Longitude, Altitude) values ('Jared Nielsen', 29.5786422, -95.2049992, 15) insert into SQLDevelopers (Name, Latitude, Longitude, Altitude) values ('Nancy Hidy Wilson', 29.578, -95.2049, 14) insert into SQLDevelopers (Name, Latitude, Longitude, Altitude) values ('Robert Gremillion', 29.5552929,-95.1133171,16) UPDATE SQLDevelopers SET GeoPosition = geography::point([latitude], [Longitude], 4326) GO http://www.vdstech.com/world-data.aspx

San Jacinto College is Cool ALTER TABLE CoolShapes ADD GeoPosition geography NULL GO INSERT INTO CoolShapes (Name, GeoPosition) VALUES ('San Jacinto College', geography::point(29.5786422, -95.2049992, 4326)) http://www.vdstech.com/world-data.aspx

STIntersection Method SELECT GeoPosition.STBuffer(100) FROM CoolShapes WHERE Name='San Jacinto College' UNION ALL SELECT GeoPosition.STBuffer(30) FROM SQLDevelopers One Developer is Not Attending http://www.vdstech.com/world-data.aspx

STIntersection Method SELECT GeoPosition.STBuffer(100) FROM CoolShapes WHERE Name='San Jacinto College' UNION ALL SELECT GeoPosition.STBuffer(30) FROM SQLDevelopers WHERE NAME NOT IN ('Robert Gremillion') Who else is here? http://www.vdstech.com/world-data.aspx

More Methods DECLARE @Jared geography DECLARE @Robert geography DECLARE @Nancy geography DECLARE @SanJAC Geography DECLARE @JaredGhost geography SELECT @Jared = GeoPosition.STBuffer(5) FROM SQLDevelopers WHERE Name = 'Jared Nielsen' SELECT @Robert = Geoposition.STBuffer(5) from SQLDevelopers WHERE Name='Robert Gremillion' SELECT @Nancy = Geoposition.STBuffer(5) from SQLDevelopers where Name LIKE 'Nancy%' SELECT @SanJAC = Geoposition.STBuffer(100) from CoolShapes WHERE Name = 'San Jacinto College' SELECT @JaredGhost = Geoposition.STBuffer(2) from SQLDevelopers WHERE Name = 'Jared Nielsen Dark Matter http://www.vdstech.com/world-data.aspx

More Methods SELECT @Jared.STWithin(@SanJAC) = Boolean True SELECT @SanJAC.STContains(@Robert) = Boolean False SELECT @Jared.STDistance(@Nancy) = 61.832 meters Declare @BodyOdorPerimeter geography SELECT @BodyOdorPerimeter = @Jared.STBuffer(10) Declare @OlfactoryPerimeter geography SELECT @OlfactoryPerimeter= @Nancy.STBuffer(60) Do I stink? http://www.vdstech.com/world-data.aspx

More Methods SELECT @OlfactoryPerimeter.STOverlaps (@BodyOdorPerimeter) Boolean = 1 http://www.vdstech.com/world-data.aspx

JARED NIELSEN Serial Entrepreneur Investor Software Architect Questions?