intro to gis

20
1 Media Production Support v1 26 October 2011 Blake Crosby October 25, 2011 Introduction to GIS

Upload: blakecrosby

Post on 02-Jul-2015

245 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Intro to GIS

1 Media Production Support

v1 26 October 2011

Blake CrosbyOctober 25, 2011

Introduction to GIS

Page 2: Intro to GIS

2 Media Production Support

v1 26 October 2011

What is GIS?

Geographic Information System is the merging

of cartography, statistical analysis,

and database technology.

Page 3: Intro to GIS

3 Media Production Support

v1 26 October 2011

Earliest Use

• John Snow, MD

was the man.

• Discovered the

cause of a cholera

outbreak in the UK

in 1854.

• Revolutionized

epidemiology.

Page 4: Intro to GIS

4 Media Production Support

v1 26 October 2011

Basic Principals

• Three key items:– Reliable data source (database)

– A way to query your data (statistical analysis)

– A way to display your result (cartography)

• We’ll Cover:– Spatial object types (of the vector kind)

– Geography 101 (the Earth is not round!)

– The power of a spatially aware database

– Displaying the end results to users.

Page 5: Intro to GIS

5 Media Production Support

v1 26 October 2011

Basic Vector Spatial Object Types

• A Point– (-75.6692 45.3225)

• A Line String– (-75.99 36.89,-74.16 38.78,-73.36 39.97,-72.86 40.10)

• A Polygon– ((-75.99 36.89,-74.16 38.78,-73.36 39.97,-72.86 40.10,-75.99 36.89))

Page 6: Intro to GIS

6 Media Production Support

v1 26 October 2011

Cartesian what?

• What is the shortest distance between two points?

A Straight Line

Page 7: Intro to GIS

7 Media Production Support

v1 26 October 2011

Spherical Trig? Ugh!

• What is the shortest distance between two points on a

sphere?

A Geodesic Path

(aka: Great Circle)

Page 8: Intro to GIS

8 Media Production Support

v1 26 October 2011

What do you mean it’s not round?

• The Earth:– Is not flat (thank you Pythagoras!)

– Is not round (eh?)

– Is actually an ellipsoid

SphereSpheroid

(Ellipsoid)

It is important to know this distinction!

Page 9: Intro to GIS

9 Media Production Support

v1 26 October 2011

So who cares? Sphere Vs. Ellipsoid

• What’s the distance between Ottawa and Amsterdam?

• If the Earth was a perfect sphere:– 5,631.441 KM

• Using the WGS84 Geoid– 5,648.054 KM

• A difference of 17 KM!

Page 10: Intro to GIS

10 Media Production Support

v1 26 October 2011

Geoids: Everything there is to know.

• Over 4000 “definitions” for the earth.

• Most common is WGS84 (Latitude / Longitude)

• Second most common is UTM (Meters)

• Some items to think about:– If your source data is in UTM, how do you plan on converting to WGS84?

– Can your libraries support calculating “real world distances” (meters/kilometers)

from hours, minutes, and seconds (latitude/longitude)?

Page 11: Intro to GIS

11 Media Production Support

v1 26 October 2011

The $1,000,000 question

• How do you plan on answering these questions?– Give me all the news stories within 10km of my current location.

– Will the forest fire in this story burn down my house?

– I want to know all the news events that affects the “Oakwood” Neighbourhood

• Javascript?

• PHP? Java?

• Spatially aware DB + SQL?

Page 12: Intro to GIS

12 Media Production Support

v1 26 October 2011

Javascript Stylez: News stories within 10 KMs?

• Doesn’t scale well.– Calculating distances for 10 points is fast, but for 100? 1000? 10000?

• Not particularly fast (especially on mobile devices)

• How do you handle other objects (like polygons?)

var R = 6371; // km

var dLat = (lat2-lat1).toRad();

var dLon = (lon2-lon1).toRad();

var lat1 = lat1.toRad();

var lat2 = lat2.toRad();

var a = Math.sin(dLat/2) * Math.sin(dLat/2) +

Math.sin(dLon/2) * Math.sin(dLon/2) * Math.cos(lat1) * Math.cos(lat2);

var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));

var d = R * c;

Page 13: Intro to GIS

13 Media Production Support

v1 26 October 2011

SQL Stylez: News stories within 10 KMs?

• Scales well– Using bounding boxes and spatial indexes to eliminate points

• Fast!– Runs on the server side

• Need a spatially aware database backend (such as

PostGIS)

SELECT storyid FROM storytable WHERE

st_within(userlocation,st_buffer(location,10000));

Page 14: Intro to GIS

14 Media Production Support

v1 26 October 2011

That’s great! But how do I show data to my users?

• Google Maps API– Most popular.

– Easy to use functions

– Moderately Customizable

• OpenLayers– Completely customizable

– No license restrictions

– 100% Pure JS library

Page 15: Intro to GIS

15 Media Production Support

v1 26 October 2011

I don’t like my base map.

• Do you want your base map to look like this:

• No control over look & feel

• At the “mercy” of Google

Page 16: Intro to GIS

16 Media Production Support

v1 26 October 2011

I don’t like my base map.

• Or like one of these:

• Complete control

• Data may be out of date

(crowd sourced)

Page 17: Intro to GIS

17 Media Production Support

v1 26 October 2011

OL vs. GM

Feature Google Maps Open Layers

Customizable Base Map? 4 predefined ones

(Unlimited in V3 API)

Unlimited

Map Controls Fully Customizable Fully Customizable

Mobile Compatible? Yes No

Data Sources KML only KML, Mapserver, GML,

WKT.

Spatial Functions? Yes (a few) Yes (a lot)

Learning Curve Medium Steep

Reprojection? No (everything must

be in lat/long)

Yes

Page 18: Intro to GIS

18 Media Production Support

v1 26 October 2011

“Ultimate” Solution/Technologies

• Custom Base Map– Data: Open Street Map

– Renderer: Mapnik+Tile Cache

• Datastore– PostgreSQL+PostGIS

• Google Map API– PHP backend serving it data via JSON

Page 19: Intro to GIS

19 Media Production Support

v1 26 October 2011

“Probable” Solution/Technologies

• Datastore– PostgreSQL

– Lat/Lon stored as int in database

• Google Map API– PHP backend serving it data via JSON

Page 20: Intro to GIS

20 Media Production Support

v1 26 October 2011

Questions We Need to Answer

• How are we going to geo-tagging news stories?

• How are we going to store UGC?

• What spatial questions is the application going to answer?

• Is the primary interface a map?

• Do we need to overlay only points? Or polygons as well?