-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.html
2244 lines (1894 loc) · 80.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Let's Talk About Your Geostack</title>
<meta name="description" content="A collection of open source tools for getting going with geo.">
<meta name="author" content="Eric Theise">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/moon.css" id="theme">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Customizations for Geostack deck -->
<link rel="stylesheet" href="css/custom.css">
<!-- If the query includes 'print-pdf', use the PDF print sheet -->
<script>
document.write( '<link rel="stylesheet" href="css/print/' + ( window.location.search.match( /print-pdf/gi ) ? 'pdf' : 'paper' ) + '.css" type="text/css" media="print">' );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-54393148-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section data-markdown>
<script type="text/template">
### Let's talk about your
# Geostack
<small>
A workshop presented by <a href="http://erictheise.com/">Eric Theise</a> / <a href="http://twitter.com/erictheise">@erictheise</a>
</small><br />
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="images/cc-by-nc-sa-80x15.png" /></a>
</script>
</section>
<section data-markdown>
<script type="text/template">
## You. The Audience and Presenter.
This deck is licensed for use by people studying on their own time, either individually,
or in a group where everyone has come together voluntarily to learn.
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="images/cc-by-nc-sa-88x31.png" /></a>
If you are being paid for your time as you lead people through this deck, _in any context_, you need to [
contact me](https://github.com/erictheise) about licensing.
If you come across any inaccuracies, or have other suggestions for improving this deck, please consider
[opening an issue](https://github.com/erictheise/geostack-deck/issues).
<p class="fragment">Let's begin.</p>
</script>
</section>
<section data-markdown>
<script type="text/template">
## Goals
Twofold.
<ol>
<li class="fragment">dirtying our hands with oft-mentioned geo tools.
<p class="fragment" style="text-align:center;padding:20px;">
(Familiarity breeds <em>content(ement)</em>?)
</p>
</li>
<li class="fragment">assembling a complete, yet lowest common denominator collection of tools,
a foundation upon which future workshops and demos can be constructed.
<p class="fragment" style="text-align:center;padding:20px;">
(A platform?)
</p>
</li>
</ol>
</script>
</section>
<section data-markdown>
<script type="text/template">
## Software components
We'll be installing tools that work<br />on common operating systems.
<p class="fragment">(Mac OS X, Ubuntu 14, & Windows 8.1.)</p>
</script>
</section>
<section data-markdown>
<script type="text/template">
## On the back end
<ul class="fragment fade-in">
<li><a href="http://python.org/">Python</a>: an open source programming language with a hefty collection
of well-tested libraries for numerical calculations,</li>
<li><a href="http://postgresql.org/">PostgreSQL</a>: an open source database that can be spatially
enabled with</li>
<li><a href="http://postgis.refractions.net/">PostGIS</a>: a PostgreSQL extension that adheres to the
[OpenGIS Simple Features Specification for SQL](https://en.wikipedia.org/wiki/Simple_Features), and</li>
<li><a href="http://nodejs.org/">Node.js</a>: a JavaScript platform for easily building network
applications.</li>
</ul>
</script>
</section>
<section data-markdown>
<script type="text/template">
## On the front end
<ul class="fragment fade-in">
<li><a href="http://leafletjs.com/">Leaflet</a>: an open-source JavaScript library for mobile-friendly
interactive maps.</li>
</ul>
</script>
</section>
<section data-markdown>
<script type="text/template">
## Desktop applications
<ul class="fragment fade-in">
<li>the <a href="http://www.postgresql.org/docs/9.3/static/app-psql.html">psql</a> interactive console
included with PostgreSQL,</li>
<li><a href="https://www.mapbox.com/tilemill/">TileMill</a>: MapBox's application for creating
tiles, and</li>
<li>a text editor or Integrated Development Environment (IDE) of your choice.</li>
</ul>
</script>
</section>
<section data-markdown>
<script type="text/template">
## Data sources
<ul class="fragment fade-in">
<li><a href="http://openstreetmap.org/">OpenStreetMap</a>: the long-running open map project built on
user-contributed data and, potentially,</li>
<li><a href="http://www.naturalearthdata.com/">Natural Earth</a>: a public domain map dataset
available at 1:10m, 1:50m, and 1:110 million scales. Even if we don't use it, you should know about it.</li>
</ul>
</script>
</section>
<section>
<section data-markdown>
## I. Before the workshop
Download & install the back end, front end, and application components. The right arrow will take you through
Mac OS X instructions. Use the down arrow once to access instructions for Ubuntu 14 instructions, twice to
access instructions for Windows 8.1.
</section>
<section data-markdown data-background="#5e2750">
<script type="text/template">
## Ubuntu 14
Two options for working with Ubuntu. You can run a Ubuntu virtual machine (VM) via
[VirtualBox](https://www.virtualbox.org/), or, if your machine already uses Ubuntu as its operating system,
you can install the components directly. Running a virtual machine adds one layer of complexity, but offers
flexibility and one layer of safety. So, a slide or six on VirtualBox.
ubuntu | [next](#/9/1)
</script>
</section>
<section data-markdown data-background="#00198f">
## Windows 8.1
Two options for working with Windows. You can run a Windows virtual machine (VM) via
[VirtualBox](https://www.virtualbox.org/), or, if your machine already uses Windows as its operating system,
you can install the components directly. Running a virtual machine adds one layer of complexity, but offers
flexibility and one layer of safety. In the case of Windows, it may violate your license. Still, a slide or
six on VirtualBox.
windows | [next](#/9/2)
</section>
</section>
<section>
<section>
<h2>Xcode</h2>
<p>
<a href="https://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12">Download and install Xcode</a> from the Mac App Store.
<img src="images/Xcode.png" width="768" height="528" alt="Xcode at the Apple App Store" />
</p>
</section>
<section data-background="#5e2750">
<h2>VirtualBox</h2>
<p>
<a href="https://www.virtualbox.org/wiki/Downloads">Download</a> and install a VirtualBox platform package.
<img src="images/VirtualBox-Download.png" width="768" height="528" alt="VirtualBox download" />
</p>
<a href="#/8/1"> prev</a> | ubuntu | <a href="#/10/1">next</a>
</section>
<section data-background="#00198f">
<h2>VirtualBox</h2>
<p>
<a href="https://www.virtualbox.org/wiki/Downloads">Download</a> and install a VirtualBox platform package.
<img src="images/VirtualBox-Download.png" width="768" height="528" alt="VirtualBox download" />
</p>
<a href="#/8/2"> prev</a> | windows | <a href="#/10/2">next</a>
</section>
</section>
<section>
<section>
<h2>Homebrew</h2>
<p>
Installing <a href="http://brew.sh/">this OS X package manager</a> is a one-liner.
</p>
<img src="images/Homebrew.png" width="768" height="528" alt="Homebrew home page" />
</section>
<section data-background="#5e2750">
<h2>A Ubuntu disk image</h2>
<p>
<a href="http://www.ubuntu.com/download/desktop">Download Ubuntu</a>.
<img src="images/Ubuntu-Download.png" width="768" height="528" alt="VirtualBox download" />
</p>
<a href="#/9/1"> prev</a> | ubuntu | <a href="#/11/1">next</a>
</section>
<section data-background="#00198f">
<h2>A Windows disk image</h2>
<p>
<a href="http://windows.microsoft.com/en-us/windows-8/create-reset-refresh-media">Download Windows</a>. You'll need your product key.
<img src="images/Windows-Download.png" width="768" height="528" alt="VirtualBox download" />
</p>
<a href="#/9/2"> prev</a> | windows | <a href="#/11/2">next</a>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
## Homebrew
Use your Terminal program.
```
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/...
/usr/local/share/man/man1/brew.1
Press ENTER to continue or any other key to abort
[lots of output]
==> Installation successful!
You should run `brew doctor` *before* you install anything.
Now type: brew help
Erics-MacBook-Pro:~ erictheise$ brew doctor
Your system is ready to brew.
```
See https://github.com/mxcl/homebrew/wiki/installation if you need additional information about installing Homebrew.
</script>
</section>
<section data-markdown data-background="#5e2750">
## Create the VM, 1/3
1. start the VirtualBox Application
2. choose `Machine`, `New`
3. give the machine a `Name`, e.g., `Geostack`
4. set the `Type` to `Linux`
5. set the `Version` to `Ubuntu (64 bit)`
6. set `Memory size`
7. `Create a virtual hard drive now` as a `VDI`, `Dynamically allocated`
[prev](#/10/1) | ubuntu | [next](#/12/1)
</section>
<section data-markdown data-background="#00198f">
## Create the VM, 1/3
Microsoft provides a thorough [guide to Using VirtualBox](http://msdn.microsoft.com/en-us/library/windows/apps/jj945425.aspx). You won't need to install Visual Studio.
1. start the VirtualBox Application
2. choose `Machine`, `New`
3. give the machine a `Name`, e.g., `Geostack`
4. set the `Type` to `Microsoft Windows`
5. set the `Version` to `Windows 8.1 (64 bit)`
6. set the `Memory size` to at least `2 GB (2048 MB)`, `4 GB (4096 MB)` if you can
7. `Create a virtual hard drive now` as a `VDI`, `Dynamically allocated`, `40 GB`
[prev](#/10/2) | windows | [next](#/12/2)
</section>
</section>
<section>
<section data-transition="zoom" data-background="images/beers.jpg">
<div class="overphoto">
<h2>Yay Homebrew!</h2>
<div><small>Image </small><img class="overphoto no-border" src="images/cc-by-80x15.png" width="80" height="15" alt="CC BY 2.0"><span><small> <a href="http://www.flickr.com/photos/brostad/">Bernt Rostad</a>, some rights reserved</small></span></div>
</div>
</section>
<section data-markdown data-background="#5e2750">
## Create the VM, 2/3
8. select your new VM and click `Settings`, `Storage`
9. click `Empty` below `Controller: IDE`
10. use `CD/DVD Drive` to navigate to the file you downloaded from the Ubuntu site, e.g. `ubuntu-14.0401-desktop-amd64.iso`
11. click `Start`
12. choose `Install Ubuntu`
13. choose `Erase disk and install Ubuntu`; no fear, you're erasing a virtual disk
14. proceed with installation; if it seems to hang after `Stopping early crypto disks`, choose `Machine`, `Reset (Host+R)`
[prev](#/11/1) | ubuntu | [next](#/13/1)
</section>
<section data-markdown data-background="#00198f">
## Create the VM, 2/3
8. select your new VM and click `Settings`, `Storage`
9. select `Controller: IDE`
10. use `Add CD/DVD Device` to navigate to the .ISO file you downloaded from the Windows site
11. click `Start`
12. proceed with installation
[prev](#/11/2) | windows | [next](#/13/2)
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
## Python
Use your Terminal program.
```
$ brew install python
[lots of output]
Setuptools and Pip have been installed. To update them
pip install --upgrade setuptools
pip install --upgrade pip
You can install Python packages with (the outdated easy_install or)
`pip install <your_favorite_package>`
They will install into the site-package directory
/usr/local/lib/python2.7/site-packages
See: https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
==> Summary
/usr/local/Cellar/python/2.7.5: 5200 files, 80M, built in 3.0 minutes
$
```
</script>
</section>
<section data-markdown data-background="#5e2750">
## Create the VM, 3/3
15. with the VM running, choose `Devices`, `Insert Guest Additions CD image`
16. navigate down the dock, select the CD/DVD icon, and `Run Software`
17. click the gear icon at top right, `Shut Down...`, and `Restart`
18. `Search your computer and online sources` for `Terminal`, drag `Terminal` to the dock
19. click on the `Terminal` icon to get started
[prev](#/12/1) | ubuntu | [next](#/14/1)
</section>
<section data-markdown data-background="#00198f">
## Create the VM, 3/3
13. with the VM running, choose `Devices`, `Insert Guest Additions CD image`
14. navigate to the CD Drive and run the `VirtualBox Guest Additions`
[prev](#/12/2) | windows | [next](#/14/2)
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
## NumPy
NumPy is the fundamental package<br />for scientific computing with Python.
Use your Terminal program.
```
$ pip install numpy
[thousands upon thousands of lines of output]
Successfully installed numpy
Cleaning up...
$
```
</script>
</section>
<section data-markdown data-background="#5e2750">
<script type="text/template">
## Ubuntu's Advanced Packaging Tool
Ubuntu includes the APT package manager. [apt-get](https://help.ubuntu.com/14.04/serverguide/apt-get.html)
will update your system and install the software needed for the workshop.
Use your Terminal program. Occasionally answer `Y` to continue.
```
$ sudo apt-get update
[lots of output]
$ sudo apt-get upgrade
[more output]
$ sudo apt-get install python-numpy
[you get the idea]
$ sudo apt-get install postgresql-9.3 postgresql-contrib-9.3
$ sudo apt-get install postgresql-9.3-postgis-2.1
$ sudo apt-get install osm2pgsql
$ sudo apt-get install nodejs
$ sudo apt-get install npm
```
[prev](#/13/1) | ubuntu | [next](#/15/1)
</script>
</section>
<section data-background="#00198f">
<h2>Python</h2>
<p>
<a href="https://www.python.org/downloads/">Download</a> and install Python 2.7.X.
<img src="images/Windows-Python.png" width="667" height="528" alt="Python download" />
</p>
<a href="#/13/2"> prev</a> | windows | <a href="#/15/2">next</a>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
## PostGIS
Use your Terminal program.
```
$ brew install postgis
[lots of output]
==> Summary
/usr/local/Cellar/postgis/2.1.0: 44 files, 7.6M, built in 86 seconds
$
```
Along the way, a number of important <em>Caveats</em><br />scrolled past in the output.
</script>
</section>
<section data-markdown data-background="#5e2750">
<script type="text/template">
## Your PostgreSQL role
Switch to the `postgres` administrator account and create a PostgreSQL role corresponding to your Ubuntu
account.
```
$ whoami
erictheise
$ sudo -i -u postgres
[sudo] password for erictheise:
$ whoami
postgres
$ createuser --interactive
Enter name of role to add: erictheise
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n
$ exit
logout
$ whoami
erictheise
$
```
[prev](#/14/1) | ubuntu | [next](#/16/1)
</script>
</section>
<section data-markdown data-background="#00198f">
## pip
pip is the contemporary way to install Python packages.
[Download it](https://bootstrap.pypa.io/get-pip.py), open a Windows PowerShell, execute it, then add the
Scripts directory to your path.
```
Windows PowerShell
Copyright (C) 2013 Microsoft Corporation. All rights reserved.
PS C:\Users\erictheise> python Downloads\get-pip.py
Downloading/unpacking pip
Downloading/unpacking setuptools
Installing collected packages: pip, setuptools
Successfully installed pip setuptools
Cleaning up...
PS C:\Users\erictheise> setx PATH "%PATH%;C:\Python27\Scripts"
```
[Official instructions](https://pip.pypa.io/en/latest/installing.html) are available.
[prev](#/14/2) | windows | [next](#/16/2)
</section>
</section>
<section>
<section data-markdown data-background="#ffd500">
<script type="text/template">
## Caveat 1: PostgreSQL
```
==> Caveats
initdb /usr/local/var/postgres -E utf8 # create a database cluster
postgres -D /usr/local/var/postgres # serve that database
PGDATA=/usr/local/var/postgres postgres # …alternatively
```
You need to run the first line, exactly as is, to initialize your PostgreSQL installation.
```
$ initdb /usr/local/var/postgres -E utf8
```
The other two lines are ways to start the PostgreSQL server. Consider two alternatives.
</script>
</section>
<section data-background="#5e2750">
<h2>TileMill</h2>
<p>
<a href="https://www.mapbox.com/tilemill/">Download</a> and install TileMill
from MapBox.
<img src="images/Ubuntu-TileMill.png" width="768" height="528" alt="TileMill download" />
</p>
<a href="#/15/1"> prev</a> | ubuntu | <a href="#/21/1">next</a>
</section>
<section data-background="#00198f">
<h2>NumPy</h2>
<p>
<a href="http://sourceforge.net/projects/numpy/files/NumPy/1.8.2/">Download the installer</a>.
The filenames are very long, so make sure you get a python2.7 version.
</p>
<p><img src="images/Windows-NumPy.png" width="667" height="528" alt="NumPy download"></p>
<a href="#/15/2"> prev</a> | windows | <a href="#/17/2">next</a>
</section>
</section>
<section>
<section data-markdown data-background="#ffd500">
<script type="text/template">
## Caveat 2: PostgreSQL
```
==> Caveats
To have launchd start postgresql at login:
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you do not want/need launchctl, you can just run:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
```
If you'd like your PostgreSQL server to start every time you boot up your machine, run
```
$ ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
```
Reboot your machine and use the ```ps``` command to verify that the PostgreSQL server is running.
```
$ ps ax | grep sql
254 ?? S 0:00.56 /usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres -r
/usr/local/var/postgres/server.log
49408 s004 R+ 0:00.00 grep sql
```
</script>
</section>
<section data-markdown data-background="#5e2750">
## This slide intentionally left blank.
[prev](#/16/1) | ubuntu | [next](#/21/1)
</section>
<section data-background="#00198f">
<h2>PostgreSQL</h2>
<p>
<a href="http://www.enterprisedb.com/products-services-training/pgdownload#windows">Download</a>
PostgreSQL 9.3.X.
<img src="images/Windows-PostgreSQL.png" width="667" height="528" alt="PostgreSQL download" />
</p>
<a href="#/16/2"> prev</a> | windows | <a href="#/18/2">next</a>
</section>
</section>
<section>
<section data-markdown data-background="#ffd500">
<script type="text/template">
Alternatively, if you want to manually start and stop your PostgreSQL server as needed, you'll run
the commands
```
$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
```
and
```
$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log stop
```
at the appropriate times.
</script>
</section>
<section data-markdown data-background="#5e2750">
## This slide intentionally left blank.
[prev](#/16/1) | ubuntu | [next](#/21/1)
</section>
<section data-background="#00198f">
<h2>PostgreSQL & PostGIS</h2>
<p>
Run the installer. When it completes, use Stack Builder to install PostGIS 2.1
</p>
<p><img src="images/Windows-Stack-Builder.png" width="667" height="528" alt="PostgreSQL download"></p>
<a href="#/17/2"> prev</a> | windows | <a href="#/19/2">next</a>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
## osm2pgsql
OSM data comes in two formats, XML and PBF (Protocolbuffer Binary Format). The OpenStreetMap Wiki [tells us](http://wiki.openstreetmap.org/wiki/PBF_Format):
> [PBF] is primarily intended as an alternative to the XML format. It is about half of the size of a gzipped planet and about 30% smaller than a bzipped planet. It is also about 5x faster to write than a gzipped planet and 6x faster to read than a gzipped planet. The format was designed to support future extensibility and flexibility.
We can get behind that.
</script>
</section>
<section data-markdown data-background="#5e2750">
## This slide intentionally left blank.
[prev](#/16/1) | ubuntu | [next](#/21/1)
</section>
<section data-background="#00198f">
<h2>node.js</h2>
<p>
<a href="http://nodejs.org/download/">Download</a> and install node.js.
</p>
<p><img src="images/Windows-node.png" width="667" height="528" alt="node.js download"></p>
<a href="#/18/2"> prev</a> | windows | <a href="#/21/2">next</a>
</section>
</section>
<section>
<section data-markdown>
<script type="text/template">
## osm2pgsql
Install the protobuf-c library and osm2pgsql via Homebrew. Use your Terminal program.
```
$ brew install protobuf-c
[...]
/usr/local/Cellar/protobuf-c/0.15: 12 files, 376K, built in 27 seconds
$ brew install osm2pgsql --with-protobuf-c=$HOMEBREW_PREFIX/opt/protobuf-c
[...]
/usr/local/Cellar/osm2pgsql/0.84.0: 9 files, 332K, built in 32 seconds
$
```
</script>
</section>
<section data-markdown data-background="#5e2750">
## This slide intentionally left blank.
[prev](#/16/1) | ubuntu | [next](#/21/1)
</section>
<section data-markdown data-background="#00198f">
## This slide intentionally left blank.
[prev](#/18/2) | windows | [next](#/21/2)
</section>
</section>
<section>
<section>
<h2>TileMill</h2>
<p>
<a href="https://www.mapbox.com/tilemill/">Download</a> and install TileMill
from MapBox.
<img src="images/TileMill-Download.png" width="768" height="528" alt="TileMill download" />
</p>
</section>
<section data-markdown data-background="#5e2750">
## This slide intentionally left blank.
[prev](#/16/1) | ubuntu | [next](#/22)
</section>
<section data-background="#00198f">
<h2>TileMill</h2>
<p>
<a href="https://www.mapbox.com/tilemill/">Download</a> and install TileMill
from MapBox.
<img src="images/Windows-TileMill.png" width="768" height="528" alt="TileMill download" />
</p>
<a href="#/19/2"> prev</a> | windows | <a href="#/22">next</a>
</section>
</section>
<section data-transition="zoom" data-background="images/Map-nik-cake-osm-7.png">
<div class="overphoto">
<h2>Okay, let's bake some tiles!</h2>
<div><small>Image </small><img class="overphoto no-border" src="images/cc-by-sa-80x15.png" width="80" height="15" alt="CC BY SA"><span><small> <a href="http://wiki.openstreetmap.org/w/images/b/b2/Map-nik-cake-osm-7.png">OpenStreetMap Wiki</a></small></span></div>
</div>
</section>
<section data-transition="zoom" data-markdown>
<script type="text/template">
# Let the workshop commence
</script>
</section>
<section data-markdown>
<script type="text/template">
# II. The back end
</script>
</section>
<section data-markdown>
<script type="text/template">
## OpenStreetMap data
You have several options for downloading<br />this [ever-evolving](http://osmlab.github.io/show-me-the-way/)
data set.
<ul>
<li class="fragment">
the whole planet from [Planet OSM](http://planet.osm.org/). Set aside a week or more to download and import.
</li>
<li class="fragment">
_metro extracts_
<ul>
<li>from [Mapzen](https://mapzen.com/metro-extracts/). These supersede those previously maintained by
[Michal Migurski](http://metro.teczno.com/). Updated weekly.</li>
<li>from [Geofabrick GmbH](http://download.geofabrik.de/). Updated daily.</li>
<li>from [BBBike.org](http://download.bbbike.org/osm/)</a>. Updated weekly.</li>
</ul>
</li>
<li class="fragment">
a customizable area export from [OpenStreetMap](http://www.openstreetmap.org/export).
</li>
</ul>
</script>
</section>
<section data-markdown>
<script type="text/template">
## Mapzen's metro extracts
Mapzen [offers hundreds of metro extracts](https://mapzen.com/metro-extracts/), and you<br /> can [easily
request that they add a new one](http://erictheise.com/blog/2014/08/30/mapzens-openstreetmap-metro-extracts).
Download the [_OSM PBF file_](https://s3.amazonaws.com/metro-extracts.mapzen.com/portland.osm.pbf) for
_Portland_ (Oregon).
<img src="images/Mapzen-Portland.png" width="768" height="528" alt="Mapzen Portland extract" />
</script>
</section>
<section data-markdown>
<script type="text/template">
## Creating a spatially-enabled database
<img src="images/PostGIScreate.png" width="768" height="480" alt="Creating spatially-enabled databases" />
PostGIS docs tell you how to spatially-enable one database.
\#ProTip: create a spatially-enabled <em>template</em>.
</script>
</section>
<section data-markdown>
<script type="text/template">
## Creating a spatially-enabled template
Use `psql` to create, connect to, & spatially-enable a template.
```
$ psql postgres
psql (9.3.5)
Type "help" for help.
postgres=> CREATE DATABASE template_postgis;
CREATE DATABASE
postgres=> \c template_postgis
template_postgis=# CREATE EXTENSION postgis;
CREATE EXTENSION
template_postgis=# CREATE EXTENSION postgis_topology;
CREATE EXTENSION
template_postgis=# CREATE EXTENSION hstore;
CREATE EXTENSION
template_postgis=# UPDATE pg_database SET datistemplate = true WHERE datname='template_postgis';
UPDATE 1
template_postgis=# UPDATE pg_database SET datallowconn = false WHERE datname='template_postgis';
UPDATE 1
template_postgis=#
```
</script>
</section>
<section data-markdown>
<script type="text/template">
## Creating a spatially-enabled database<br />from a template
Create a new database from your template called _portland_from_osm_.
```
template_postgis=# CREATE DATABASE portland_from_osm TEMPLATE template_postgis;
template_postgis=# \q
$
```
</script>
</section>
<section data-markdown>
<script type="text/template">
## osm2pgsql
Import the OSM PBF file into the database we just created.
```
$ osm2pgsql -H localhost --hstore-all -d portland_from_osm ~/Downloads/portland.osm.pbf
osm2pgsql SVN version 0.84.0 (64bit id space)
Using projection SRS 900913 (Spherical Mercator)
Setting up table: planet_osm_point
NOTICE: table "planet_osm_point" does not exist, skipping
NOTICE: table "planet_osm_point_tmp" does not exist, skipping
Setting up table: planet_osm_line
[...]
Creating indexes on planet_osm_line finished
All indexes on planet_osm_line created in 7s
Completed planet_osm_line
Osm2pgsql took 28s overall
$
```
</script>
</section>
<section data-markdown>
<script type="text/template">
## What'd we get? & How Much?
The tables starting with *planet\_osm\_* were created by the import. (The views and *spatial\_ref\_sys*
table come courtesy PostGIS.)
```
$ psql portland_from_osm
psql (9.3.5)
Type "help" for help.
portland_from_osm=# \d
List of relations
Schema | Name | Type | Owner
--------+--------------------+-------+------------
public | geography_columns | view | postgres
public | geometry_columns | view | postgres
public | planet_osm_line | table | erictheise
public | planet_osm_point | table | erictheise
public | planet_osm_polygon | table | erictheise
public | planet_osm_roads | table | erictheise
public | raster_columns | view | postgres
public | raster_overviews | view | postgres
public | spatial_ref_sys | table | postgres
(9 rows)
portland_FROM_osm=# SELECT COUNT(*) FROM planet_osm_point;
count
-------
47925
(1 row)
portland_FROM_osm=# SELECT COUNT(*) FROM planet_osm_line;
count
--------
136969
(1 row)
portland_FROM_osm=# SELECT COUNT(*) FROM planet_osm_polygon;
count
-------
27911
(1 row)
portland_FROM_osm=# SELECT COUNT(*) FROM planet_osm_roads;
count
-------
15418
(1 row)
```
</script>
</section>
<section>
<h2>OpenStreetMap schema</h2>
<p>
Four <a href="http://wiki.openstreetmap.org/wiki/Elements">elements</a> are central to OpenStreetMap's
data model:
<ul>
<li class="fragment"><em>nodes</em>: points. They may be actual points of interest or parts of ways.</li>
<li class="fragment"><em>ways</em>: linear features (roads, rivers) and area boundaries ("closed ways": forests,
buildings).</li>
<li class="fragment"><em>relations</em>: multi-purpose data structures that document relationships between two or
more elements.</li>
<li class="fragment">
<em>tags</em>: key/value pairs, ideally following community
<a href="http://wiki.openstreetmap.org/wiki/Map_Features">conventions</a>.
</li>
</ul>
</p>
<p>
<span class="fragment fade-in">
<code>osm2pgsql</code> massages these elements to<br />create tables suitable for rendering.
</span>
</p>
</section>
<section>
<h2>osm2pgsql schema</h2>
<p>
<ul>
<li><code>planet_osm_point</code>: contains all imported nodes with tags.</li>
<li><code>planet_osm_line</code>: contains all imported ways</li>
<li><code>planet_osm_polygon</code>: contains all imported polygons..</li>
<li>
<code>planet_osm_roads</code>: contains a subset of <code>planet_osm_line</code> suitable for rendering
at low zoom levels.
</li>
</ul>
</p>
<p class="fragment fade-in">
<a href="http://wiki.openstreetmap.org/wiki/Osm2pgsql/schema">More detail</a> is available.
</p>
<p class="fragment fade-in">
Let's try and make this data visible.
</p>
</section>
<section>
<h2>TileMill</h2>
<p>
Launch TileMill and create a New Project.
</p>
<img src="images/TileMill-NewProject.png" width="768" height="528" alt="TileMill - New Project" />
</section>
<section>
<h2>TileMill</h2>
<p>
Select the project, then pan and zoom to Portland. Add a PostGIS layer for lines. (Lines:
immediate gratification.)
</p>
<img src="images/TileMill-NewLayer-Line-Screen.png" width="768" height="528" alt="TileMill - Line Layer" />
</section>
<section>
<h2>Whoa. Interesting.</h2>
<img src="images/TileMill-NewLayer-Line-Result.png" width="768" height="528" alt="TileMill - Line Layer" />
<p class="fragment fade-in">
Can I get a close-up of that?
</p>
</section>
<section>
<h2>Not very discriminating.</h2>
<img src="images/TileMill-NewLayer-Line-Result-Zoom12.png" width="768" height="528" alt="TileMill - Line Layer" />
<p class="fragment fade-in">