P. 1
Spatial SQL: Who Needs a Traditional GIS?

Spatial SQL: Who Needs a Traditional GIS?

Views: 873|Likes:
Published by Best Tech Videos
The presentation will discuss the loading and indexing of spatial data, but will concentrate on the spatial functions available for further analysis in MySQL. Specific business cases will be used to illustrate these functions, such as the real-time monitoring of boats in offshore windfarm construction. A Java front-end will be used to support the claim that Java plus Mysql equals traditional GIS
The presentation will discuss the loading and indexing of spatial data, but will concentrate on the spatial functions available for further analysis in MySQL. Specific business cases will be used to illustrate these functions, such as the real-time monitoring of boats in offshore windfarm construction. A Java front-end will be used to support the claim that Java plus Mysql equals traditional GIS

More info:

Published by: Best Tech Videos on Apr 25, 2009
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as ODP, PDF, TXT or read online from Scribd
See more
See less





Spatial SQL: who

needs a traditional
John Powell
What is GIS?
Traditionally narrow/specialist area involving expensive
and proprietary software, even though 80% concerned
with “just” drawing a map
ocation !ased services, google earth, virtual earth
changing traditional narrow focus
"patial data!ases, open source geometry li!raries and
powerful graphics pac#ages ma#ing $%" much more
accessi!le and inexpensive
The prolem with !eo!raphic data
$& 'geographic mar#up langauge, an xml dialect( is
vendor independent and standards compliant
!ut staggeringly ver!ose ) geographic data tends to !e
voluminous anyway
and cum!ersome to parse
"#ample !ml
*osg!+Topographic-rea fid./osg!0000000123045403/,
Gml e#ample contin$ed
*gml+@olygon srsAame./osg!+BA$/,*gml+outerBoundary%s,*gml+inear?ing,*gml+coordinates,
1091;9<910,3020;0<520 1091;9<900,3020;0<400 1091;9<180,3020;0<090 1091;9<190,3020;0<030 1091;9<190,3020;0<880 1091;9<120,3020;0<100 1091;9<950,3020;0<430
1091;9<920,3020;0<080 1091;9<800,3020;0<0;0 1091;9<850,3020;0<000 1091;9<200,302042<880 1091;9<280,302042<910 1091;8<010,302042<1;0 1091;8<0;0,302042<540
1091;8<340,302042<;30 1091;8<440,302042<430 1091;8<;40,302042<340 1091;8<5;0,302042<0;0 1091;8<150,302042<010 1091;8<990,302048<280 1091;8<820,302048<200
1091;2<050,302048<920 1091;2<380,302048<9;0 1091;2<;30,302048<120 1091;2<550,302048<110 1091;2<120,302048<130 1091;2<840,302048<100 1091;2<280,302048<580
109150<030,302048<590 109150<;00,302048<590 109150<5;0,302048<580 109150<180,302048<100 109150<210,302048<110 109150<020,302048<900 109150<330,302048<950
109150<4;0,302048<800 109150<;90,302048<890 109150<520,302048<2;0 109150<900,302042<030 109150<800,302042<000 109150<200,302042<300 10915;<330,302042<010
109110<130,302049<040 109190<080,30204;<430 109192<4;0,302040<250 109182<900,302038<850 109900<;20,302035<110 109903<400,302034<;50 109901<890,302033<2;0
109909<0;0,302033<230 109909<300,302033<230 109909<480,302033<240 109909<5;0,302033<2;0 109909<900,302033<290 109909<890,302034<000 109908<020,302034<000
109908<450,302034<010 109908<500,302034<340 109908<800,302034<420 109908<2;0,302034<;80 109902<080,302034<580 109902<300,302034<180 109902<4;0,302034<920
109902<580,30203;<040 109902<120,30203;<050 109902<920,30203;<320 109902<820,30203;<;30 109902<280,30203;<510 109930<010,30203;<900 109930<300,302035<000
109930<400,302035<440 109930<4;0,302035<;20 109930<490,302035<110 109930<490,302035<900 109930<420,302035<890 109930<420,302031<300 109930<490,302031<410
109930<450,302031<540 109930<390,302031<850 109930<330,302039<000 109930<010,302039<010 109930<020,302039<400 109930<000,302039<;10 109902<240,302039<100
109902<8;0,302039<9;0 109902<9;0,302039<880 109902<1;0,302038<000 109902<540,302038<0;0 109902<320,302038<480 109902<010,302038<;20 109902<040,302038<520
109908<950,302038<920 109908<100,302038<890 109908<;10,302038<250 109908<400,302032<030 109908<010,302032<080 109908<000,302032<0;0 109909<180,302032<330
109904<290,302040<0;0 109904<200,302043<2;0 109123<090,302041<000 109180<530,302049<200 109190<230,3020;0<020 109150<;;0,3020;3<8;0 1091;8<420,3020;3<120
1091;8<320,3020;3<520 1091;8<300,3020;3<;80 1091;8<000,3020;3<410 1091;9<290,3020;3<030 1091;9<200,3020;0<220 1091;9<850,3020;0<810 1091;9<800,3020;0<930
1091;9<910,3020;0<520 */gml+coordinates,*/gml+inear?ing,*/gml+outerBoundary%s,
109154<410,3020;0<430 109154<420,3020;0<420 109154<;80,3020;0<550 109154<530,3020;0<100 109154<140,3020;0<930 109154<120,3020;0<990 109154<200,3020;0<820
109154<290,3020;0<200 10915;<050,3020;0<2;0 10915;<040,3020;0<250 10915;<300,3020;0<290 10915;<410,3020;0<290 10915;<500,3020;0<250 10915;<520,3020;0<240
10915;<940,3020;0<890 109151<500,3020;0<350 109152<910,302042<230 10911;<820,302048<930 109112<410,302048<000 10919;<3;0,302041<800 109199<9;0,302045<940
109908<020,302038<830 109903<;90,302039<550 109903<5;0,302039<130 109903<520,302039<110 109903<150,302039<120 109903<930,302039<930 109903<980,302039<9;0
109903<230,302039<910 109904<040,302039<950 109904<4;0,302039<120 109904<;00,302039<110 109904<;90,302039<130 109904<5;0,302039<580 109904<150,302039<;20
109904<900,302039<;;0 109904<800,302039<4;0 109904<850,302039<380 109904<200,302039<010 109904<2;0,302039<020 109904<290,302031<210 109904<210,302031<950
109904<2;0,302031<180 109904<230,302031<1;0 109904<820,302031<590 109904<910,302031<;00 109904<150,302031<400 109904<580,302031<390 109904<530,302031<340
109904<;50,302031<300 109904<3;0,302031<0;0 109904<010,302031<040 109904<030,302031<040 109903<890,302031<050 109903<940,302031<020 109903<190,302031<330
109903<550,302031<400 109903<;20,302031<450 10990;<940,302032<000 109180<;50,30204;<8;0 109195<400,302045<990 109115<410,302049<;80 109155<300,302042<980
109155<010,302042<150 109155<030,302042<520 109155<0;0,302042<;20 10915;<220,302042<;50 10915;<240,302042<;00 10915;<800,302042<450 10915;<9;0,302042<440
10915;<100,302042<400 10915;<400,302042<430 10915;<0;0,302042<410 10915;<090,302042<480 109154<220,302042<;00 109154<850,302042<;90 109154<980,302042<500
109154<110,302042<520 109154<100,302042<1;0 109154<500,302042<9;0 109154<;30,302042<810 109154<420,302042<230 109154<450,3020;0<0;0 109154<4;0,3020;0<080
The sol$tion: spatial dataases
?8tree indexing massively speeds retrieval
$eometric representation of real8world o!jects
Aumerous standards compliant functions that test spatial
relations or operate on single geometries
-llows analysis to !e moved to the d!
%&tree inde#
Loadin! data
oad data infile statement ) common for point data as x,y then
update ta!le using set
geom.geomfromtext'concat'/@C%AT'/,x,/ /,y,/(/((D
6an use !lac#hole ta!le with trigger to create geom column,
saving the unnecessary storage of the intermediate x, y
Cr load string representation of geometry into !lo!/largetext and
update geom column in ta!le with geomfromtext
oad directly using programming language
%f data in $%"/6-7 format, can load using 4rd8party software
such as >&E
'lac(hole loadin! e#ample
create ta!le !lac#Finsert 'x real, y real, G real( engine . B-6H=CED
create ta!le points 'geom @C%AT not null, G real, spatial index 'geom((
7elimiter //
create trigger trgFgeom BE>C?E %A"E?T on !lac#Finsert
for each row
insert into points set geom . geomfromtext'concat'/@C%AT'/,AEJ<x,/ /, AEJ<y, /(/((,
7elimiter D
load data infile /points<txt/ into ta!le !lac#Finsert fields terminated !y /,/D
Kuery CH, ;000000 rows affected, 0 warning '1 min 35<33 sec(
?ecords+ ;000000 7eleted+ 0 "#ipped+ 0 Jarnings+ 0
)ew M*SQL spatial +$nctions
Cpen geospatial consortium defines spatial standards
Lntil last year, &y"K spatial functionality limited to
minimum !ounding rectangle calculations
Than#s to &y"K developer =olyfoot, we now have
proper polygonal functions
"ee http+//forge<mysMl<com/wi#i/$%"F>unctions
GIS e#ample , conto$rs
%ndex on 3<1 !illion points with height as attri!ute
select G from heights where m!rintersects'geom,Ngeom( order
!y O'geom(, I'geom(
@roduces an ordered array of G values that can !e sent to a
contouring algorithm to produce contour overlay in real time
Importance o+ inde#es
-s ?8tree index loo#up is !ased on &B?s, for point data the index
will !e !igger than the data
=owever, without it, on any non8trivial dataset, performance will !e
very poor
Jith polygonal data, index siGe to data siGe !ecomes a 'small(
fraction rather than a multiple of data siGe
Cnly &y%"-& supports spatial index
6ould use %nnod! master 'insert( and &y%"-& slave 'select(, if
concurrency less important than data integrity
Spatial data t*pes
"patial data types+ point, line, polygon, multipoint, multilinestring,
multipolygon, geometry, geometrycollection
$eometry column can contain any of the other types
$eometrycollection can hold a com!ination, eg, set
Ng./$EC&ET?I6CE6T%CA'@C%AT'0 0(,@CI$CA''0 0,
00 0, 00 00, 0 00, 0 0(((/D
@olygon cannot have any intersecting lines, must !e closed, may
have any num!er of inner rings, which can only touch outer
ring at a single point
Spatial +$nctions +or plottin!
java<awt<geom<-rea which implements java<awt<"hape interface
allows the su!traction of one geometry from another
6an !e used for plotting polygons with inner rings
Cr can cheat, !y sorting on area of outer ring, ensuring polygons
drawn in correct order< Kuic#er
"et N!!ox.geomfromtext'/@CI$CA''tlx tly, !rx tly, !rx !ry, tlx !ry, tlx
select intersection'N!!ox, g<geom( from geomta!le g where
intersects'N!!ox, g<geom( and geometrytype'g<geom(
./@CI$CA/ order !y
Spatial +$nctions , ho$ses with +lood ris(
select geom into Npcode from code@oint<polygons where
@C"T6C7E./6C5 9K/D
select Pos address toidP from addresslayer<addresslayerFgeom
al,'select intersection'fl<geom,Npcode( as geom from
ea<floodGoneFcom!ined fl where intersects'fl<geom,Npcode(( as fl
where intersects'al<geom,fl<geom( and
-lways chec# index use with explain
"patial joins different to the more usual B8tree join
Beware of derived ta!les as index will not !e used,
resulting in horrific performance
Spatial +$nctions , land co-era!e
"how percentage of different land coverage types within
a !uffer Gone
"et N!uff.!uffer'geomfromtext'/@C%AT'530000, 085000(,500(D
select round'sum'area'intersection'a<geom,N!uff(((/0000000,4( as
#mFsM, a<descriptivegroup from attri!utes a where
intersects'a<geom,N!uff( and geometrytype'a<geom( ./@CI$CA/
group !y a<descriptivegroup order !y #mFsM descD
Introd$cin! time
%ncreasingly spatial data!ases have a temporal component )
epidemiology, crime analysis, climate change, location !ased
services, land use change, etc
@artitioning can improve performance considera!ly
But<<< can/t partition on ta!le with geometry columns
'oats ser-icin! wind+arms
Boats use a system called automatic identification
system '-%"(
Lses a form of !ase 1; to encode info, eg,
This contains the !oats position, course, speed and other
dynamic varia!les
- second message contains static information, such as
ship name, destination, length, call sign
'oats tails
$et !oat trails ) position of all !oats going !ac# two hours, !ut
only those seen in last 40 seconds to avoid orphaned trails
select a<mmsi, a<lat, a<lng,cast'a<time as decimal'0;(( from ais a
right join 'select mmsi from ais where time*Ndt and
time,dateFsu!'Ndt, interval 40 second( group !y mmsi( as ast
on a<mmsi.ast<mmsi where a<time,dateFsu!'Ndt, interval 3
hour( and a<time*Ndt and extract'minute from time( mod 3.0
order !y a<mmsiD
'oats contd.
6urrent !oat position plus static information involves join
on derived ta!le and spatial position< 6an/t partition
with spatial data
"olution ) partition using toFdays function on month with
datetime, ship%7 and %7 'autoFinc( as #eys
6reate 3
ta!le with lat/lng as point< -dd spatial index
with %7 'autoFinc( as #ey
Then can do spatio8temporal Muery with efficient index
.istri$ted GIS
Je! or we!8initiated front end 'eg, java we! start(
S $raphics li!raries and threading
S &y"K spatial !ac#end with partioning, replication,
S Cpen source math/geometry li!aries
. ow cost, powerful distri!uted $%"
/$t$re direction
Aon8projected coordinate systems ) currently distance function
only accurate for projected data
Extra geometry functions, eg, translate, rotate, generaliGe
47 types/indexing
@artitioning on time !ut with spatial datatypes
Cutput to H&/$&
@resenter finishes 008year plan and finally learns 6SS

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->