space filling curves - bowdoin collegeltoma/teaching/cs3225-gis/fall16/lectures/gis_z… · spatial...
TRANSCRIPT
![Page 1: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/1.jpg)
Space Filling Curves
Algorithms for GIS
Laura Toma
Bowdoin College
![Page 2: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/2.jpg)
![Page 3: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/3.jpg)
Space filling curves
A map from an interval to a square
![Page 4: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/4.jpg)
https://mathsbyagirl.wordpress.com/tag/curve/
Space filling curves
A map from an interval to a square
![Page 5: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/5.jpg)
Z-order space filling curves
• Assume 2D points with integer coordinates on k bits
p = (x1x2x3…xk, y1y2y3…yk)
• Define the Z-index of a point
Z_index : {0,..,2k-1} x {0,..,2k-1}—> {0,..,22k-1}
Z_index(p) = x1y1x2y2…xkyk
![Page 6: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/6.jpg)
k=1 bit
x
y
(0,0)
(0,1)
(1,0)
(1,1)
p Z_index(p)
(0,0) 0
(0,1) 1
(1,0) 2
(1,1) 3
![Page 7: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/7.jpg)
y
x0
1
2
3
p Z_index(p)
(0,0) 0
(0,1) 1
(1,0) 2
(1,1) 3
k=1 bit
![Page 8: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/8.jpg)
y
x0 2
1 3
p Z_index(p)
(0,0) 0
(0,1) 1
(1,0) 2
(1,1) 3
k=1 bit
![Page 9: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/9.jpg)
x
y
p Z_index(p)
(00,00) 0000=0(00,01) 0001=1(00,10) 0100=4(00,11) 0101=5(01,00)(01,01)(01,10)(01,11)(10,00)(10,01)(10,10)(10,11)(11,00)(11,01)(11,10)(11,11)
Find the Z-order!
k=2 bits
![Page 10: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/10.jpg)
x
y
k=2 bits
![Page 11: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/11.jpg)
Find the Z-order!
x
y
k=3 bits
![Page 12: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/12.jpg)
Computing the Z-index
x
y
• Consider an x-coordinate x1x2x3 in the square [0,…8) • x1=0 means the point will reside in the first half • x1=1 means the point will reside in the second half
x=0** x=1**
![Page 13: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/13.jpg)
Computing the Z-index
x
y
• Consider an y-coordinate y1y2y3 in the square [0,…8) • y1=0 means the point will reside in the first half • y1=1 means the point will reside in the second half
y=0**
y=1**
![Page 14: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/14.jpg)
Computing the Z-index
x
y
• Consider an y-coordinate y1y2y3 in the square [0,…8) • y1=0 means the point will reside in the first half • y1=1 means the point will reside in the second half
x=0** y=0**
x=0** y=1**
x=1** y=1**
x=1** y=0**
![Page 15: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/15.jpg)
Computing the Z-index
• Consider an y-coordinate y1y2y3 in the square [0,…8) • y1=0 means the point will reside in the first half • y1=1 means the point will reside in the second half
x
y
x=0** y=0**
x=0** y=1**
x=1** y=1**
x=1** y=0**
x
y
Z=00**
Z=01**
Z=10**
Z=11**
![Page 16: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/16.jpg)
Computing the Z-index
• Consider an y-coordinate y1y2y3 in the square [0,…8) • y1=0 means the point will reside in the first half • y1=1 means the point will reside in the second half
x
y
x
y
Z=00**
Z=01**
Z=10**
Z=11**
![Page 17: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/17.jpg)
Computing the Z-index
• Consider an y-coordinate y1y2y3 in the square [0,…8) • y1=0 means the point will reside in the first half • y1=1 means the point will reside in the second half
x
y
x
y
Z=00**
Z=01**
Z=10**
Z=11**
![Page 18: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/18.jpg)
Computing the Z-index
• Consider an y-coordinate y1y2y3 in the square [0,…8) • y1=0 means the point will reside in the first half • y1=1 means the point will reside in the second half
x
y
x
y
Z=00**
Z=01**
Z=10**
Z=11**
![Page 19: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/19.jpg)
Computing the Z-index
• Consider an y-coordinate y1y2y3 in the square [0,…8) • y1=0 means the point will reside in the first half • y1=1 means the point will reside in the second half
x
y
x
y
Z=00**
Z=01**
Z=10**
Z=11**
![Page 20: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/20.jpg)
Computing the Z-index
• Consider an y-coordinate y1y2y3 in the square [0,…8) • y1=0 means the point will reside in the first half • y1=1 means the point will reside in the second half
x
y
x
y
Z=00**
Z=01**
Z=10**
Z=11**
![Page 21: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/21.jpg)
• Other Z-orders can be obtained similarly
y
x
y
• Can be extended to work with decimal numbers in [0,1) • make values positive (add smallest value) • divide all values by max value • ==> now we got values in [0,1)p=(.1100, .0101)
Z-order space filling curves
![Page 22: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/22.jpg)
Z-order and quadtrees
visit quadrants recursively in this order: NW, NE, SW, SE
![Page 23: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/23.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
Z-order and quadtrees
![Page 24: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/24.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
Z-order and quadtrees
![Page 25: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/25.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
Z-order and quadtrees
![Page 26: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/26.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
• At the limit, it will reach all points in the square ==> space filling curve
Z-order and quadtrees
![Page 27: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/27.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
• At the limit, it will reach all points in the square ==> space filling curve
Where is the very first point visited?
Z-order and quadtrees
![Page 28: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/28.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
first point in this order
last point in this order
• At the limit, it will reach all points in the square ==> space filling curve
Z-order and quadtrees
![Page 29: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/29.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
first point in this order
last point in this order
• At the limit, it will reach all points in the square ==> space filling curve
Z-order and quadtrees
![Page 30: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/30.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
first point in this order
last point in this order
• Every point in the square will be visited by this curve • 2D ==> 1D
Z-order and quadtrees
![Page 31: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/31.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
first point in this order
last point in this order
• We visit quadrant 1 before we visit quadrant 2:
==> All points in quadrant 1 comes before all points in quadrant 2
Z-order and quadtrees
![Page 32: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/32.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
first point in this order
last point in this order
• We visit quadrant 1 before we visit quadrant 2:
==> All points in quadrant 1 comes before all points in quadrant 2
Z-order and quadtrees
![Page 33: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/33.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
first point in this order
last point in this order
Z-order and quadtrees
![Page 34: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/34.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
first point in this order
last point in this order
Z-order and quadtrees
![Page 35: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/35.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
first point in this order
last point in this order
Z-order and quadtrees
![Page 36: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/36.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
first point in this order
last point in this order
• and so on…..
Z-order and quadtrees
![Page 37: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/37.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
first point in this order
last point in this order
• and so on…..
Z-order and quadtrees
![Page 38: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/38.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
first point in this order
last point in this order
• Every canonical square corresponds to an interval of the z-order curve
Z-order and quadtrees
![Page 39: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/39.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
first point in this order
last point in this order
• Two canonical squares are non-intersecting, or one included in the other
Z-order and quadtrees
![Page 40: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/40.jpg)
visit quadrants recursively in this order: NW, NE, SW, SE
• If Zindex(a) < Zindex(b), we say that a < b • Any two points a,b can be compared
a
b
Zindex(a) Zindex(b)
Z-order and quadtrees
![Page 41: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/41.jpg)
Z_index : R2 —> R For simplicity assume points with integer coordinates on k bits
• What is the largest integer representable on k bits?
Z-index(p)
Computing the Z-index
![Page 42: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/42.jpg)
Peano curve
Space-filling curves
• Z-order curves are a special type of space-filling curves • First SFC were described by Peano and Hilbert
![Page 43: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/43.jpg)
Hilbert curve
![Page 44: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/44.jpg)
![Page 45: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/45.jpg)
Spatial locality
• Big-Oh analysis does not have the final word • Two algorithms that have the same big-Oh can differ a lot in performance
depending on their cache efficiency • To analyze and fine tune the algorithm we need to look at the performance
across all levels of the memory hierarchy
![Page 46: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/46.jpg)
http://classconnection.s3.amazonaws.com/149/flashcards/3088149/png/memory_hierarchy1367201501848.png
![Page 47: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/47.jpg)
http://users.informatik.uni-halle.de/~jopsi/dinf104/memory_hierarchy.gif
![Page 48: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/48.jpg)
• At all levels, data is organized and moved in blocks/pages • Each level acts as a “cache” for the next level: stores most recently used
blocks • Applications that access data that’s stored in a “recent” block will find it in
cache • 1ns vs 100ns <—- SIGNIFICANT!
![Page 49: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/49.jpg)
Spatial locality
Spatial applications usually have spatial locality in their access to data, i.e. they are likely to access together points that are close to each other in space
We would like points “close” in 2D to be stored “close” to each other in the data structure
![Page 50: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/50.jpg)
Spatial locality
Spatial applications usually have spatial locality in their access to data, i.e. they are likely to access together points that are close to each other in space
We would like points “close” in 2D to be stored “close” to each other in the data structure
![Page 51: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/51.jpg)
Spatial locality
Spatial applications usually have spatial locality in their access to data, i.e. they are likely to access together points that are close to each other in space
We would like points “close” in 2D to be stored “close” to each other in the data structure
![Page 52: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/52.jpg)
Spatial locality
Spatial applications usually have spatial locality in their access to data, i.e. they are likely to access together points that are close to each other in space
We would like points “close” in 2D to be stored “close” to each other in the data structure
![Page 53: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/53.jpg)
Spatial locality
Spatial applications usually have spatial locality in their access to data, i.e. they are likely to access together points that are close to each other in space
We would like points “close” in 2D to be stored “close” to each other in the data structure
![Page 54: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/54.jpg)
…
Grid default layout: row-major order
![Page 55: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/55.jpg)
• Does this layout have good spatial locality?
• How far are these points in the array?
…
Grid default layout: row-major order
![Page 56: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/56.jpg)
• Does this layout have good spatial locality?
• How far are these points in the array?
…
Grid default layout: row-major order
![Page 57: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/57.jpg)
grid in default row-major order
…grid stored in Z-order
…
Spatial locality
![Page 58: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/58.jpg)
grid in default row-major order
…grid stored in Z-order
…
Spatial locality
![Page 59: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/59.jpg)
grid in default row-major order
…grid stored in Z-order
…
Spatial locality
![Page 60: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/60.jpg)
grid in default row-major order
…grid stored in Z-order
…
Spatial locality
![Page 61: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/61.jpg)
grid in default row-major order
…grid stored in Z-order
…
Spatial locality
![Page 62: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/62.jpg)
grid in default row-major order
…grid stored in Z-order
…
Spatial locality
![Page 63: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/63.jpg)
grid in default row-major order
…grid stored in Z-order
…
Spatial locality
![Page 64: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/64.jpg)
grid in default row-major order
…grid stored in Z-order
…
Spatial locality
![Page 65: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/65.jpg)
grid in default row-major order
…grid stored in Z-order
…
Spatial locality
Arranging data in order of a space-filling curve improves spatial locality • points that are close together in space, will be stored close to each other
![Page 66: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/66.jpg)
Spatial locality
• Arranging data in order of a space-filling curve improves spatial locality • points that are close together in space, will be stored close to each
other • data will be in the same blocks as previous data • data will be found in cache • improvements at all levels of the memory hierarchy
• Hilbert curve has better locality than z-order, but slower to compute • Z-order used with Strassen’s algorithm —> speedups (2002)
![Page 67: Space Filling Curves - Bowdoin Collegeltoma/teaching/cs3225-GIS/fall16/Lectures/gis_z… · Spatial locality • Arranging data in order of a space-filling curve improves spatial](https://reader035.vdocument.in/reader035/viewer/2022063000/5f0d123f7e708231d4388930/html5/thumbnails/67.jpg)
SFC in art
Don Relyea, artist futurist and tehnologist • http://www.donrelyea.com/site2015/space-filling-curve-art-2004-2014-wide-format/