74
Spatial Analytics Workshop Pete Skomoroch, LinkedIn (@peteskomoroch) Kevin Weil, Twitter (@kevinweil) Sean Gorman, FortiusOne (@seangorman) #spatialanalytics

Where20 Spatial Analytics 2010

  • Upload
    seagor

  • View
    1.058

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Where20 Spatial Analytics 2010

Spatial Analytics WorkshopPete Skomoroch, LinkedIn (@peteskomoroch)Kevin Weil, Twitter (@kevinweil)Sean Gorman, FortiusOne (@seangorman)

#spatialanalytics

Page 2: Where20 Spatial Analytics 2010

Introduction‣ The Rise of Spatial Analytics

‣ Spatial Analysis Techniques

‣ Hadoop, Pig, and Big Data

‣ Bringing the Two Together

‣ Conclusion

‣ Q&A

Page 3: Where20 Spatial Analytics 2010

Introduction‣ The Rise of Spatial Analytics

‣ Spatial Analysis Techniques

‣ Hadoop, Pig, and Big Data

‣ Bringing the Two Together

‣ Conclusion

‣ Q&A

Page 4: Where20 Spatial Analytics 2010

Introduction‣ The Rise of Spatial Analytics

‣ Spatial Analysis Techniques

‣ Hadoop, Pig, and Big Data

‣ Bringing the Two Together

‣ Conclusion

‣ Q&A

Page 5: Where20 Spatial Analytics 2010

Spatial Analysis

Analytical techniques to determine the spatial

distribution of a variable, the relationship between

the spatial distribution of variables, and the

association of the variables in an area.

Page 6: Where20 Spatial Analytics 2010

Pattern Analysis

Page 7: Where20 Spatial Analytics 2010

Spatial Analysis Types

1. Spatial autocorrelation

2. Spatial interpolation

3. Spatial interaction

4. Simulation and modeling

5. Density mapping

Page 8: Where20 Spatial Analytics 2010

Spatial Autocorrelation

Spatial autocorrelation statistics measure and analyze

the degree of dependency among observations in a

geographic space.

First law of geography: “everything is related to everything

else, but near things are more related than distant things.”

-- Waldo Tobler

Page 9: Where20 Spatial Analytics 2010

Moran’s I - Random Variable

Moran’s I = .012

Moran’s I - Per Capita Income in Monroe County

Moran’s I = .66

Page 10: Where20 Spatial Analytics 2010

Spatial Interpolation

Spatial interpolation methods estimate the variables

at unobserved locations in geographic space based

on the values at observed locations.

Page 11: Where20 Spatial Analytics 2010

Natural Gas Demand in Response to February 21, 2003 Alberta Clipper cold front

$7.55

$14.00

$14.00

Henry

NYC

Chicago

Page 12: Where20 Spatial Analytics 2010

Natural Gas Demand in Response to February 24, 2003 Alberta Clipper cold front

$16.00

$30.00

$18.50

Henry

NYC

Chicago

Page 13: Where20 Spatial Analytics 2010

Natural Gas Demand in Response to February 25, 2003 Alberta Clipper cold front

$22.00

$37.00

$20.00

Henry

NYC

Chicago

Page 14: Where20 Spatial Analytics 2010

Spatial Interaction

Spatial interaction or “gravity models” estimate

the flow of people, material, or information

between locations in geographic space.

Page 15: Where20 Spatial Analytics 2010

Introduction‣ Motiviation

‣ Execution

‣ Prototype

‣ Service

‣ API

‣ Operations

‣ UX

Global Oil Supply and Demand Gravity Model

Page 16: Where20 Spatial Analytics 2010

Simulation and Modeling

Simple interactions among proximal entities can

lead to intricate, persistent, and functional spatial

entities at aggregate levels (complex adaptive

systems).

Page 17: Where20 Spatial Analytics 2010

Spatial Interdependency Analysis of the San Francisco Failure Simulation

InfrastructureTotal Number of Links

No. Links Congested

% Links Congested

%Volume Delay

Refined Products (National)

3,197 1 0.03% 0.05%Refined Products (MSA) 8 1 12.50% 93%

Power Grid (Regional) 1,942 4 0% N/A

Power Grid (MSA) 16 2 13% N/A

Page 18: Where20 Spatial Analytics 2010

Density Mapping

Calculating the proximity and frequency of a

spatial phenomenon by creating a probabilistic

surface.

Page 19: Where20 Spatial Analytics 2010

New York City Fiber Density Map

Page 20: Where20 Spatial Analytics 2010

Standard GIS Architectures

Page 21: Where20 Spatial Analytics 2010

Distributed Analytics

Queueing analysis tasks from disparate data sources

for agents to run across distributed servers to collate

back to the user as answers.

Page 22: Where20 Spatial Analytics 2010

User

Request Queue

Disparate Data

Age

nts

Dis

trib

uted

Ser

vers

Analysis

Page 23: Where20 Spatial Analytics 2010

User

Request Queue

Agent

Amazon S3

Amazon EC2

1. Rasterize2. Kernel

density calc3. Color map

(http://finder.geocommons.com/overlays/20148)

Page 24: Where20 Spatial Analytics 2010

Vector Density Mapping Demo

Page 25: Where20 Spatial Analytics 2010
Page 26: Where20 Spatial Analytics 2010
Page 27: Where20 Spatial Analytics 2010
Page 28: Where20 Spatial Analytics 2010

Introduction‣ The Rise of Spatial Analytics

‣ Spatial Analysis Techniques

‣ Hadoop, Pig, and Big Data

‣ Bringing the Two Together

‣ Conclusion

‣ Q&A

Page 29: Where20 Spatial Analytics 2010

Data is Getting Big‣ NYSE: 1 TB/day

‣ Facebook: 20+ TB compressed/day

‣ CERN/LHC: 40 TB/day (15 PB/year!)

‣ And growth is accelerating

‣ Need multiple machines, horizontal scalability

Page 30: Where20 Spatial Analytics 2010

Hadoop‣ Distributed file system (hard to store a PB)

‣ Fault-tolerant, handles replication, node failure, etc

‣ MapReduce-based parallel computation(even harder to process a PB)

‣ Generic key-value based computation interfaceallows for wide applicability

‣ Open source, top-level Apache project

‣ Scalable: Y! has a 4000-node cluster

‣ Powerful: sorted a TB of random integers in 62 seconds

Page 31: Where20 Spatial Analytics 2010

MapReduce?‣ Challenge: how many tweets per

county, given tweets table?

‣ Input: key=row, value=tweet info

‣ Map: output key=county, value=1

‣ Shuffle: sort by county

‣ Reduce: for each county, sum

‣ Output: county, tweet count

‣ With 2x machines, runs close to 2x faster.

cat file | grep geo | sort | uniq -c > output

Page 32: Where20 Spatial Analytics 2010

MapReduce?‣ Challenge: how many tweets per

county, given tweets table?

‣ Input: key=row, value=tweet info

‣ Map: output key=county, value=1

‣ Shuffle: sort by county

‣ Reduce: for each county, sum

‣ Output: county, tweet count

‣ With 2x machines, runs close to 2x faster.

cat file | grep geo | sort | uniq -c > output

Page 33: Where20 Spatial Analytics 2010

MapReduce?‣ Challenge: how many tweets per

county, given tweets table?

‣ Input: key=row, value=tweet info

‣ Map: output key=county, value=1

‣ Shuffle: sort by county

‣ Reduce: for each county, sum

‣ Output: county, tweet count

‣ With 2x machines, runs close to 2x faster.

cat file | grep geo | sort | uniq -c > output

Page 34: Where20 Spatial Analytics 2010

MapReduce?‣ Challenge: how many tweets per

county, given tweets table?

‣ Input: key=row, value=tweet info

‣ Map: output key=county, value=1

‣ Shuffle: sort by county

‣ Reduce: for each county, sum

‣ Output: county, tweet count

‣ With 2x machines, runs close to 2x faster.

cat file | grep geo | sort | uniq -c > output

Page 35: Where20 Spatial Analytics 2010

MapReduce?‣ Challenge: how many tweets per

county, given tweets table?

‣ Input: key=row, value=tweet info

‣ Map: output key=county, value=1

‣ Shuffle: sort by county

‣ Reduce: for each county, sum

‣ Output: county, tweet count

‣ With 2x machines, runs close to 2x faster.

cat file | grep geo | sort | uniq -c > output

Page 36: Where20 Spatial Analytics 2010

MapReduce?‣ Challenge: how many tweets per

county, given tweets table?

‣ Input: key=row, value=tweet info

‣ Map: output key=county, value=1

‣ Shuffle: sort by county

‣ Reduce: for each county, sum

‣ Output: county, tweet count

‣ With 2x machines, runs close to 2x faster.

cat file | grep geo | sort | uniq -c > output

Page 37: Where20 Spatial Analytics 2010

MapReduce?‣ Challenge: how many tweets per

county, given tweets table?

‣ Input: key=row, value=tweet info

‣ Map: output key=county, value=1

‣ Shuffle: sort by county

‣ Reduce: for each county, sum

‣ Output: county, tweet count

‣ With 2x machines, runs close to 2x faster.

cat file | grep geo | sort | uniq -c > output

Page 38: Where20 Spatial Analytics 2010

But...‣ Analysis typically done in Java

‣ Single-input, two-stage data flow is rigid

‣ Projections, filters: custom code

‣ Joins: lengthy, error-prone

‣ n-stage jobs: Hard to manage

‣ Prototyping/exploration requires compilation

‣ analytics in Eclipse?ur doin it wrong...

Page 39: Where20 Spatial Analytics 2010

Enter Pig

‣ High level language

‣ Transformations on sets of records

‣ Process data one step at a time

‣ Easier than SQL?

Page 40: Where20 Spatial Analytics 2010

Why Pig?‣ Because I bet you can read the following script.

Page 41: Where20 Spatial Analytics 2010

A Real Pig Script

‣ Now, just for fun... the same calculation in vanilla Hadoop MapReduce.

Page 42: Where20 Spatial Analytics 2010

No, seriously.

Page 43: Where20 Spatial Analytics 2010

Pig Simplifies Analysis

‣ The Pig version is:

‣ 5% of the code, 5% of the time

‣ Within 50% of the execution time.

‣ Pig ♥ Geo:

‣ Programmable: fuzzy matching, custom filtering

‣ Easily link multiple datasets, regardless of size/structure

‣ Iterative, quick

Page 44: Where20 Spatial Analytics 2010

A Real Example

‣ Fire up your EMR.

‣ ... or follow along at http://bit.ly/whereanalytics

‣ Pete used Twitter’s streaming API to store some tweets

‣ Simplest thing: group by location and count with Pig

‣ http://bit.ly/where20pig

‣ Here comes some code!

Page 45: Where20 Spatial Analytics 2010
Page 46: Where20 Spatial Analytics 2010

tweets = LOAD 's3://where20demo/sample-tweets' as ( user_screen_name:chararray, tweet_id:chararray, ... user_friends_count:int, user_statuses_count:int, user_location:chararray, user_lang:chararray, user_time_zone:chararray, place_id:chararray, ...);

Page 47: Where20 Spatial Analytics 2010

tweets = LOAD 's3://where20demo/sample-tweets' as ( user_screen_name:chararray, tweet_id:chararray, ... user_friends_count:int, user_statuses_count:int, user_location:chararray, user_lang:chararray, user_time_zone:chararray, place_id:chararray, ...);

Page 48: Where20 Spatial Analytics 2010

tweets_with_location = FILTER tweets BY user_location != 'NULL';

Page 49: Where20 Spatial Analytics 2010

normalized_locations = FOREACH tweets_with_location GENERATE LOWER(user_location) as user_location;

Page 50: Where20 Spatial Analytics 2010

grouped_tweets = GROUP normalized_locations BY user_location PARALLEL 10;

Page 51: Where20 Spatial Analytics 2010

location_counts = FOREACH grouped_tweets GENERATE $0 as location, SIZE($1) as user_count;

Page 52: Where20 Spatial Analytics 2010

sorted_counts = ORDER location_counts BY user_count DESC;

Page 53: Where20 Spatial Analytics 2010

STORE sorted_counts INTO 'global_location_tweets';

Page 54: Where20 Spatial Analytics 2010

hadoop@ip-10-160-113-142:~$ hadoop dfs -cat /global_location_counts/part* | head -30

brasil 37985indonesia 33777brazil 22432london 17294usa 14564são paulo 14238new york 13420tokyo 10967singapore 10225rio de janeiro 10135los angeles 9934california 9386chicago 9155uk 9095jakarta 9086germany 8741canada 8201東京都 7696

東京 7121

jakarta, indonesia 6480nyc 6456new york, ny 6331

Page 55: Where20 Spatial Analytics 2010

Neat, but...

‣ Wow, that data is messy!

‣ brasil, brazil at #1 and #3

‣ new york, nyc, and new york ny all in the top 30

‣ Pete to the rescue.

Page 56: Where20 Spatial Analytics 2010

Introduction‣ The Rise of Spatial Analytics

‣ Spatial Analysis Techniques

‣ Hadoop, Pig, and Big Data

‣ Bringing the Two Together

‣ Conclusion

‣ Q&A

Page 57: Where20 Spatial Analytics 2010
Page 58: Where20 Spatial Analytics 2010
Page 59: Where20 Spatial Analytics 2010
Page 60: Where20 Spatial Analytics 2010
Page 61: Where20 Spatial Analytics 2010
Page 62: Where20 Spatial Analytics 2010
Page 63: Where20 Spatial Analytics 2010
Page 64: Where20 Spatial Analytics 2010
Page 65: Where20 Spatial Analytics 2010
Page 66: Where20 Spatial Analytics 2010
Page 67: Where20 Spatial Analytics 2010

Users by County

Page 68: Where20 Spatial Analytics 2010

Lady Gaga

Page 69: Where20 Spatial Analytics 2010

Tea Party

Page 70: Where20 Spatial Analytics 2010

Dallas

Page 71: Where20 Spatial Analytics 2010

Colbert

Page 72: Where20 Spatial Analytics 2010

Introduction‣ The Rise of Spatial Analytics

‣ Spatial Analysis Techniques

‣ Hadoop, Pig, and Big Data

‣ Bringing the Two Together

‣ Conclusion

‣ Q&A

Page 73: Where20 Spatial Analytics 2010

Introduction‣ The Rise of Spatial Analytics

‣ Spatial Analysis Techniques

‣ Hadoop, Pig, and Big Data

‣ Bringing the Two Together

‣ Conclusion

‣ Q&A

Page 74: Where20 Spatial Analytics 2010

Questions? Follow us attwitter.com/peteskomorochtwitter.com/kevinweiltwitter.com/seangorman