location matters - madexpo
TRANSCRIPT
-
8/6/2019 Location Matters - MADExpo
1/114
Location Matters!Peter Jackson, Intridea
@peteonrails
1
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
2/114
Thats Not Me
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
3/114
Also Not Me
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
4/114
Still not me
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
5/114
Thats Me
@peteonrails
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
6/114
My company is hiring.
Can you hack Ruby on Rails and work in DC or NYC?
Find me after the talk or tweet @peteonrails.
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
7/114
Agenda
What is Spatial Programming?
Important Spatial Terms
The Spatial Stack
How you get started!
7
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
8/114
What is Spatial
Programming?
Exposing physical space as a first-order
programming concept.
Rich, built-in support for shapes, space, and
the relationship of physical objects to one
another.
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
9/114
Describing Objects
Spatially Locations on the earth
Geometric equations
Shapes of buildings
Parts in an assembly (a blueprint)
Positions of your battleships
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
10/114
Spatial Logic
We can use spatial techniques to answer questions that aredifficult to answer with typical object relational data.
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
11/114
Spatial Logic
Find components of a vehicle close to the fuel
line that emit heat.
Determine which customers are in certain
census tracts
Find competitors located within 10 miles ofRoute 95 where there is an available
billboard within 20 miles.
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
12/114
Spatial Logic Components of a vehicle close to the fuel line
that emit heat.
RGeo::Shapefile::Reader.open('car_blueprint.shp') do |file|
file.each do |record|components fuel line}danger_zone = fuel_line.buffer(15) # 15 units away.oh_noes = components.select { |c| c.intersects?(buffer) && c.hot? }
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
13/114
Spatial Logic New York Neighborhoods / Graduate Degrees.
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
14/114
Spatial Logic
SELECT
Round(100.0 * Sum(t.edu_graduate_dipl) / Sum(t.edu_total), 1)AS graduate_pct,
n.name, n.boronameFROM nyc_neighborhoods nJOIN nyc_census_tracts tON ST_Contains(n.the_geom, ST_Centroid(t.the_geom)) # MAGIC!WHERE
t.edu_total > 0GROUPBY n.name, n.boronameORDERBY graduate_pct DESCLIMIT 10;
New York Neighborhoods / Graduate Degrees.
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
15/114
New York Neighborhoods / Graduate Degrees.
Spatial Logic
graduate_pct | name | boroname
--------------+-------------------+-----------40.4 | Carnegie Hill | Manhattan40.2 | Flatbush | Brooklyn34.8 | Battery Park | Manhattan33.9 | North Sutton Area | Manhattan33.4 | Upper West Side | Manhattan
33.3 | Upper East Side | Manhattan32.0 | Tribeca | Manhattan31.8 | Greenwich Village | Manhattan29.8 | West Village | Manhattan29.7 | Central Park | Manhattan
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
16/114
Important terms
15
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
17/114
Important terms
GIS: Geographical InformationSystem
Layers: just like the layers in
Photoshop, but they'regeoreferenced.
WMS: Web Mapping Service
Projection: algorithm for flattingthe globe
Geometry: the core data type ina GIS
15
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
18/114
GIS
A Geographical
Information System
visually represents data
about geography.
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
19/114
Most widely used GIS
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
20/114
Most widely used GIS
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
21/114
Most widely used GIS
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
22/114
LayersJust like in Photoshop, Spatial tools let you
layer RASTER and VECTOR data on the
screen to tell a story.
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
23/114
Layers
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
24/114
Layers
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
25/114
Layers
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
26/114
Layers
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
27/114
Layers
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
28/114
Layers
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
29/114
WMSChoose the best map service for highlighting your data
OpenStreetMap
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
30/114
-
8/6/2019 Location Matters - MADExpo
31/114
WMSChoose the best map service for highlighting your data
Bing
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
32/114
WMSChoose the best map service for highlighting your data
Private Commercial
Sources (i-Cubed)
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
33/114
WMS Being replaced with services
like MapBox TileMill andGeoCommons
WMS will remain relevant,though.
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
34/114
Projection Method for representing the spheroid earth on a flat surface,
such as a screen or paper map. They can be:
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
35/114
Projection
Polar
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
36/114
Projection
Planar
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
37/114
Projection
Conic
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
38/114
Projection
Cylindrical
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
39/114
Projections are
important for Layering
Mercator Projection
Satellite Imagery
+
Braun Projection
Boundary Lines
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
40/114
Projections are
important for Layering
= FAIL
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
41/114
Projections are
important for Calculation
Source: http://www.sharpgis.net/post/2008/01/12/Straight-lines-on-a-sphere.aspx
Friday, July 8, 2011
http://www.sharpgis.net/post/2008/01/12/Straight-lines-on-a-sphere.aspxhttp://www.sharpgis.net/post/2008/01/12/Straight-lines-on-a-sphere.aspx -
8/6/2019 Location Matters - MADExpo
42/114
Projections are
important for Calculation
Source: http://www.sharpgis.net/post/2008/01/12/Straight-lines-on-a-sphere.aspx
Friday, July 8, 2011
http://www.sharpgis.net/post/2008/01/12/Straight-lines-on-a-sphere.aspxhttp://www.sharpgis.net/post/2008/01/12/Straight-lines-on-a-sphere.aspx -
8/6/2019 Location Matters - MADExpo
43/114
ProjectionsPick the one that tells your story.
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
44/114
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
45/114
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
46/114
Projection Hints
Roughly equivalent to SRID (System Reference ID) in the various spatial
databases
When in doubt, try EPSG:4326 or EPSG:900913 (Google). These are the most
widely used, but there are many more available.
EPSG:4326 and EPSG:4236 are similar, but have different origin points.
Dyslexia FTW.
If you really want to know more: http://spatialreference.org/
Friday, July 8, 2011
http://spatialreference.org/http://spatialreference.org/ -
8/6/2019 Location Matters - MADExpo
47/114
Geometry
The basic spatial data type
-
8/6/2019 Location Matters - MADExpo
48/114
GeographyJust like the Geometry type, but uses a curved coordinate set.
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
49/114
Spatial Stack
A Spatial DBMS
An Adapter
A Class Library in your language
A Visualization Technology
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
50/114
Spatial DBMS
Stores GEOMETRY in your tables
Provides spatial functions like DISTANCE()
Implements spatial indexing, so you can
forget your High School math.
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
51/114
Spatial DBMS
PostGIS -> The best, IMHO.
SqlServer 2008+
Oracle Spatial -> Powerful, but moody
MySQL Spatial -> Good, but use PostGIS if you can.
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
52/114
:id :abbrev :name :geom
1 MD Maryland
2 PA Pennsylvania
3 VA Virginia
4 WV West Virginia
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
53/114
:id :route :locality :geom
1 95 MD
2 295 DC
3 395 DC
4 50 DC
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
54/114
:id :first_name :last_name :location
1 Peter Jackson38.91094,-77.0327
2 Joe Grossberg38.91094,-77.0327
3 John Doe
41.22,
-79.01
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
55/114
An Adapter
Translates GEOMETRY columns in your DB
into the Geometry types of your Framework
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
56/114
Geo Library
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
57/114
Geo Library
Exposes the Geometry data types in your chosen
language.
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
58/114
Geo Library
Should handle interchange formats like
GeoRSS, KML, and GeoJSON
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
59/114
Geo Library
Should convert ESRI Shapefile data
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
60/114
Geo Library
Provides in-memory geometric calculations
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
61/114
VisualizationOpenLayers is one way.
Supports display of:
Bing Maps Google Maps Yahoo Maps
NASA Worldwind KML Overlays Your own custom imagery
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
62/114
Visualization
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
63/114
You can also use
YM4R
Google Maps
Bing Maps
OpenStreetMap
Any number of new mapping visualizationtoolkits: GeoCommons, MapBox, GeoPage, etc.
Friday, July 8, 2011
Ho it all hangs together
-
8/6/2019 Location Matters - MADExpo
64/114
How it all hangs together
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
65/114
SpatialData
Sets
PostGISKMLESRI
ShapefilesOracleSpatial
MySQLSpatial
Spatial
LogicComponents
spatial_adapter
GeoRubyyour awesomebiz logic here
Visualization
Map viewer (JS Library) + Awesome Imagery + Your Data = WOW
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
66/114
SpatialData
Sets
PostGISKMLESRI
ShapefilesOracleSpatial
MySQLSpatial
Spatial
LogicComponents
spatial_adapter
GeoRubyyour awesomebiz logic here
Visualization
Map viewer (JS Library) + Awesome Imagery + Your Data = WOW
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
67/114
SpatialData
Sets
PostGISKMLESRI
ShapefilesOracleSpatial
MySQLSpatial
Spatial
LogicComponents
spatial_adapter
GeoRubyyour awesomebiz logic here
Visualization
Map viewer (JS Library) + Awesome Imagery + Your Data = WOW
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
68/114
SpatialData
Sets
PostGISKMLESRI
ShapefilesOracleSpatial
MySQLSpatial
Spatial
LogicComponents
spatial_adapter
GeoRubyyour awesomebiz logic here
Visualization
Map viewer (JS Library) + Awesome Imagery + Your Data = WOW
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
69/114
SpatialData
Sets
PostGISKMLESRI
ShapefilesOracleSpatial
MySQLSpatial
Spatial
LogicComponents
spatial_adapter
GeoRubyyour awesomebiz logic here
Visualization
Map viewer (JS Library) + Awesome Imagery + Your Data = WOW
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
70/114
SpatialData
Sets
PostGISKMLESRI
ShapefilesOracleSpatial
MySQLSpatial
Spatial
LogicComponents
spatial_adapter
GeoRubyyour awesomebiz logic here
Visualization
Map viewer (JS Library) + Awesome Imagery + Your Data = WOW
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
71/114
SpatialData
Sets
PostGISKMLESRI
ShapefilesOracleSpatial
MySQLSpatial
Spatial
LogicComponents
spatial_adapter
GeoRubyyour awesomebiz logic here
Visualization
Map viewer (JS Library) + Awesome Imagery + Your Data = WOW
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
72/114
SpatialData
Sets
PostGISKMLESRI
ShapefilesOracleSpatial
MySQLSpatial
Spatial
LogicComponents
spatial_adapter
GeoRubyyour awesomebiz logic here
Visualization
Map viewer (JS Library) + Awesome Imagery + Your Data = WOW
Friday, July 8, 2011
http://msdn.microsoft.com/en-us/library/microsoft.sqlserver.types%28SQL.105%29.aspxhttp://msdn.microsoft.com/en-us/library/microsoft.sqlserver.types%28SQL.105%29.aspx -
8/6/2019 Location Matters - MADExpo
73/114
Getting Started
Decide how much Stack you want to host
Select tools appropriate to your environment
Develop the story youre trying to tell
Find Inspiration!
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
74/114
Getting Started
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
75/114
Getting Started
tar xvfz postgis-1.5.1.tar.gz
cd postgis-1.5.1./configuremakemake installcreatedb yourdatabasecreatelang plpgsql yourdatabasepsql -d yourdatabase -f postgis.sqlpsql -d yourdatabase -f postgis_comments.sqlpsql -d yourdatabase -f spatial_ref_sys.sql
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
76/114
Getting Started
$ gem install GeoRuby spatial_adapter
Successfully installed GeoRuby-1.3.4
Successfully installed spatial_adapter-1.1.2
Successfully installed activesupport-2.3.8
3 gems installed
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
77/114
Getting Started
Now fire up IRB any try this:
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
78/114
>> point = Point.new(4326, false, false)=> #
>> point.x = -33.56 # => -33.56>> point.y = 40.23 # => 40.23
>> point2 = Point.new>> point2.set_x_y_z(-35.65, 41.11, 0)
>> point.spherical_distance(point2)=> 201598.077888077
>> point.eudclidian_distance(point2)=> 2.26770809408971
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
79/114
Spatial Queries
More than just Dots on a map
We can answer really difficult, meaningful
questions.
42
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
80/114
Spatial Queries
42
Q: How many freshwater wells are located within
5 miles of a chemical plant?
A: (in Oracle Spatial)
SELECT c.chemical_plant_name
FROM well_table a, chemical_plants b
WHERE sdo_within_distance (b.geom,a.geom, 'distance=5 unit=mile') = TRUE
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
81/114
Using PostGIS, spatial_adapter, andGeoRuby, a Ruby on Rails app could do this:
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
82/114
class CreateWells< ActiveRecord::Migration
def self.up
create_table :wells do |t|t.references :customer
t.geometry :location # true
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
83/114
class Well < ActiveRecord::Base
def self.find_by_proximity(km)# This example uses Oracle syntax
find(:all, :joins => :chemical_plant,:conditions => [sdo_within_distance (chemical_plants.geom,
wells.geom, 'distance=? unit=km') = TRUE, km])end
end
class WellController < ApplicationController
def index@wells = Well.find_by_proximity(params[:buffer])
end
end
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
84/114
var map, layer;
function init(){map = new OpenLayers.Map('map', {maxResolution:'auto'});
map.addControl(new OpenLayers.Control.LayerSwitcher());
layer = new OpenLayers.Layer.WMS( "OpenLayers WMS","http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(layer);
map.setCenter(new OpenLayers.LonLat(0, 0), 0);var newl = new OpenLayers.Layer.Markers( 'POIs');map.addLayer(newl);
}
Adding the View
Friday, July 8, 2011
http://labs.metacarta.com/wms/vmap0http://labs.metacarta.com/wms/vmap0 -
8/6/2019 Location Matters - MADExpo
85/114
Inspiration
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
86/114
Inspiration
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
87/114
Inspiration
Find some interesting data
Use it to tell a compelling story
Visualize it creatively
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
88/114
Finding Data
Text
naturalearthdata.com
Raster Imagery
Vector Layers
Demographics
Boundaries
Waterways
Coastlines
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
89/114
Finding Data
Text
data.gov
Demographics
Census
Agency Research
Environmental Data
NASA
NOAA
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
90/114
Finding Data
Text
GeoCommons.com
Community-drivendatasets and maps
INSPIRATION!!
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
91/114
Inspiration
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
92/114
I i i
-
8/6/2019 Location Matters - MADExpo
93/114
Inspiration
Friday, July 8, 2011
I i i
-
8/6/2019 Location Matters - MADExpo
94/114
Inspiration
Friday, July 8, 2011
I i i
-
8/6/2019 Location Matters - MADExpo
95/114
InspirationHow do we finish the IRAQ Casualty Map story?
Friday, July 8, 2011
I i i
-
8/6/2019 Location Matters - MADExpo
96/114
InspirationHow do we finish the IRAQ Casualty Map story?
Overlay an Infrastructure Layer
Add news storiesAggregate the data into Hot Spots
Show Enemy Strongholds
Troop Positions And Operations
Correlate with Political Events
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
97/114
Integrating Real Time Data
Make your map more valuable by being timely.
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
98/114
Friday, July 8, 2011
I i ti
-
8/6/2019 Location Matters - MADExpo
99/114
Inspiration
Start Thinking Like A Geographer
Aggregate
Where do things overlap?
Tell a compelling story about People
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
100/114
The Oil Spill
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
101/114
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
102/114
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
103/114
Pakistan Floods
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
104/114
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
105/114
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
106/114
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
107/114
Friday, July 8, 2011
-
8/6/2019 Location Matters - MADExpo
108/114
Friday, July 8, 2011
Whats the Story?
-
8/6/2019 Location Matters - MADExpo
109/114
Whats the Story?
Is it infrastructure?
Is it politics?
Is it physical geography?
Friday, July 8, 2011
Inspiration
-
8/6/2019 Location Matters - MADExpo
110/114
Inspiration
Friday, July 8, 2011
Getting Started
-
8/6/2019 Location Matters - MADExpo
111/114
Getting Started
Decide how much Stack you want to host
Select tools appropriate to your environment
Develop the story youre trying to tell
Find Inspiration!
Friday, July 8, 2011
Agenda
-
8/6/2019 Location Matters - MADExpo
112/114
Agenda
What is Spatial Programming?
Important Spatial Terms
The Spatial Stack
How you get started!
61
Friday, July 8, 2011
I hope you learned alot
http://speakerrate.com/speakers/10122-peter-jackson -
8/6/2019 Location Matters - MADExpo
113/114
I hope you learned alot.
Please rate this talkhttp://spkr8.com/t/7907
http://speakerrate.com/speakers/10122-peter-jackson
Friday, July 8, 2011
License
http://speakerrate.com/speakers/10122-peter-jacksonhttp://speakerrate.com/speakers/10122-peter-jacksonhttp://speakerrate.com/speakers/10122-peter-jacksonhttp://speakerrate.com/speakers/10122-peter-jacksonhttp://spkr8.com/t/7907http://spkr8.com/t/7907 -
8/6/2019 Location Matters - MADExpo
114/114
You are free:
1. to Share to copy, distribute and transmit the work
2. to Remix to adapt the work
Attribution You must attribute this work to Peter Jackson (with link). If you want to remix or redistributethe work, including for your own personal or commercial use with no redistribution, please be sure that theprior sentence remains intact.
LicenseCreative Commons Attribution 3.0 Unported
THIS IS NOT A SHARE-ALIKE LICENSE. YOU MAY MAKE CHANGES TO THIS WORK AND KEEP
THEM FOR YOUR OWN USE, COMMERCIAL OR PERSONAL.
http://creativecommons.org/licenses/by/3.0/http://blog.peteonrails.com/http://blog.peteonrails.com/http://creativecommons.org/licenses/by/3.0/