-
Notifications
You must be signed in to change notification settings - Fork 104
/
01_geospatial_computational_environment.html
1367 lines (1278 loc) · 72 KB
/
01_geospatial_computational_environment.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>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Geospatial Computational Environment — Geographic Data Science with Python</title>
<link rel="stylesheet" href="../_static/css/index.f658d18f9b420779cfdf24aa0a7e2d77.css">
<link rel="stylesheet"
href="../_static/vendor/fontawesome/5.13.0/css/all.min.css">
<link rel="preload" as="font" type="font/woff2" crossorigin
href="../_static/vendor/fontawesome/5.13.0/webfonts/fa-solid-900.woff2">
<link rel="preload" as="font" type="font/woff2" crossorigin
href="../_static/vendor/fontawesome/5.13.0/webfonts/fa-brands-400.woff2">
<link rel="stylesheet"
href="../_static/vendor/open-sans_all/1.44.1/index.css">
<link rel="stylesheet"
href="../_static/vendor/lato_latin-ext/1.44.1/index.css">
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/sphinx-book-theme.e7340bb3dbd8dde6db86f25597f54a1b.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../_static/togglebutton.css" />
<link rel="stylesheet" type="text/css" href="../_static/copybutton.css" />
<link rel="stylesheet" type="text/css" href="../_static/mystnb.css" />
<link rel="stylesheet" type="text/css" href="../_static/sphinx-thebe.css" />
<link rel="stylesheet" type="text/css" href="../_static/custom.css" />
<link rel="stylesheet" type="text/css" href="../_static/panels-main.c949a650a448cc0ae9fd3441c0e17fb0.css" />
<link rel="stylesheet" type="text/css" href="../_static/panels-variables.06eb56fa6e07937060861dad626602ad.css" />
<link rel="preload" as="script" href="../_static/js/index.d3f166471bb80abb5163.js">
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/togglebutton.js"></script>
<script src="../_static/clipboard.min.js"></script>
<script src="../_static/copybutton.js"></script>
<script >var togglebuttonSelector = '.toggle, .admonition.dropdown, .tag_hide_input div.cell_input, .tag_hide-input div.cell_input, .tag_hide_output div.cell_output, .tag_hide-output div.cell_output, .tag_hide_cell.cell, .tag_hide-cell.cell';</script>
<script src="../_static/sphinx-book-theme.7d483ff0a819d6edff12ce0b1ead3928.js"></script>
<script async="async" src="https://unpkg.com/thebelab@latest/lib/index.js"></script>
<script >
const thebe_selector = ".thebe"
const thebe_selector_input = "pre"
const thebe_selector_output = ".output"
</script>
<script async="async" src="../_static/sphinx-thebe.js"></script>
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/x-mathjax-config">MathJax.Hub.Config({"tex2jax": {"inlineMath": [["\\(", "\\)"]], "displayMath": [["\\[", "\\]"]], "processRefs": false, "processEnvironments": false}})</script>
<link rel="canonical" href="https://geographicdata.science/book/notebooks/01_geospatial_computational_environment.html" />
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Geographic thinking for data scientists" href="02_geo_thinking.html" />
<link rel="prev" title="Overview" href="../intro_part_i.html" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="docsearch:language" content="en" />
<!-- Opengraph tags -->
<meta property="og:url" content="https://geographicdata.science/book/notebooks/01_geospatial_computational_environment.html" />
<meta property="og:type" content="article" />
<meta property="og:title" content="Geospatial Computational Environment" />
<meta property="og:description" content="Geospatial Computational Environment Computational Tools for Geographic Data Science from IPython.display import Image This chapter provides an overview of t" />
<meta property="og:image" content="https://geographicdata.science/book/_static/logo.png" />
<meta name="twitter:card" content="summary" />
</head>
<body data-spy="scroll" data-target="#bd-toc-nav" data-offset="80">
<div class="container-xl">
<div class="row">
<div class="col-12 col-md-3 bd-sidebar site-navigation show" id="site-navigation">
<div class="navbar-brand-box">
<a class="navbar-brand text-wrap" href="../index.html">
<img src="../_static/logo.png" class="logo" alt="logo">
<h1 class="site-logo" id="site-title">Geographic Data Science with Python</h1>
</a>
</div><form class="bd-search d-flex align-items-center" action="../search.html" method="get">
<i class="icon fas fa-search"></i>
<input type="search" class="form-control" name="q" id="search-input" placeholder="Search this book..." aria-label="Search this book..." autocomplete="off" >
</form>
<nav class="bd-links" id="bd-docs-nav" aria-label="Main navigation">
<ul class="nav sidenav_l1">
<li class="toctree-l1">
<a class="reference internal" href="../intro.html">
Home
</a>
</li>
</ul>
<p class="caption collapsible-parent">
<span class="caption-text">
Preface
</span>
</p>
<ul class="nav sidenav_l1">
<li class="toctree-l1">
<a class="reference internal" href="00_toc.html">
Table of Contents
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="references.html">
References
</a>
</li>
</ul>
<p class="caption collapsible-parent">
<span class="caption-text">
Part I - Building Blocks
</span>
</p>
<ul class="current nav sidenav_l1">
<li class="toctree-l1">
<a class="reference internal" href="../intro_part_i.html">
Overview
</a>
</li>
<li class="toctree-l1 current active">
<a class="current reference internal" href="#">
Geospatial Computational Environment
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="02_geo_thinking.html">
Geographic thinking for data scientists
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="03_spatial_data.html">
Spatial Data
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="04_spatial_weights.html">
Spatial Weights
</a>
</li>
</ul>
<p class="caption collapsible-parent">
<span class="caption-text">
Part II - Spatial Data Analysis
</span>
</p>
<ul class="nav sidenav_l1">
<li class="toctree-l1">
<a class="reference internal" href="../intro_part_ii.html">
Overview
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="05_choropleth.html">
Choropleth Mapping
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="06_spatial_autocorrelation.html">
Global Spatial Autocorrelation
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="07_local_autocorrelation.html">
Local Spatial Autocorrelation
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="08_point_pattern_analysis.html">
Point Pattern Analysis
</a>
</li>
</ul>
<p class="caption collapsible-parent">
<span class="caption-text">
Part III - Advanced Topics
</span>
</p>
<ul class="nav sidenav_l1">
<li class="toctree-l1">
<a class="reference internal" href="../intro_part_ii.html">
Overview
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="09_spatial_inequality.html">
Spatial Inequality
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="10_clustering_and_regionalization.html">
Clustering & Regionalization
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="11_regression.html">
Spatial Regression
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="12_feature_engineering.html">
Spatial Feature Engineering
</a>
</li>
</ul>
<p class="caption collapsible-parent">
<span class="caption-text">
Datasets
</span>
</p>
<ul class="nav sidenav_l1">
<li class="toctree-l1">
<a class="reference internal" href="../data/README.html">
Overview
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../data/airbnb/regression_cleaning.html">
AirBnb
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../data/airports/airports_cleaning.html">
Airports
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../data/brexit/brexit_cleaning.html">
Brexit
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../data/countries/countries_cleaning.html">
Countries
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../data/h3_grid/build_sd_h3_grid.html">
H3 Grid
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../data/mexico/README.html">
Mexico
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../data/nasadem/build_nasadem_sd.html">
NASA DEM
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../data/sandiego/sandiego_tracts_cleaning.html">
San Diego Tracts
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../data/texas/README.html">
Texas
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../data/tokyo/tokyo_cleaning.html">
Tokyo Photographs
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="../data/us_county_income/README.html">
US County Income 1969-2017
</a>
</li>
</ul>
</nav> <!-- To handle the deprecated key -->
<div class="navbar_extra_footer">
Powered by <a href="https://jupyterbook.org">Jupyter Book</a>
</div>
</div>
<main class="col py-md-3 pl-md-4 bd-content overflow-auto" role="main">
<div class="topbar container-xl fixed-top">
<div class="topbar-contents row">
<div class="col-12 col-md-3 bd-topbar-whitespace site-navigation show"></div>
<div class="col pl-md-4 topbar-main">
<button id="navbar-toggler" class="navbar-toggler ml-0" type="button" data-toggle="collapse"
data-toggle="tooltip" data-placement="bottom" data-target=".site-navigation" aria-controls="navbar-menu"
aria-expanded="true" aria-label="Toggle navigation" aria-controls="site-navigation"
title="Toggle navigation" data-toggle="tooltip" data-placement="left">
<i class="fas fa-bars"></i>
<i class="fas fa-arrow-left"></i>
<i class="fas fa-arrow-up"></i>
</button>
<div class="dropdown-buttons-trigger">
<button id="dropdown-buttons-trigger" class="btn btn-secondary topbarbtn" aria-label="Download this page"><i
class="fas fa-download"></i></button>
<div class="dropdown-buttons">
<!-- ipynb file if we had a myst markdown file -->
<!-- Download raw file -->
<a class="dropdown-buttons" href="../_sources/notebooks/01_geospatial_computational_environment.ipynb"><button type="button"
class="btn btn-secondary topbarbtn" title="Download source file" data-toggle="tooltip"
data-placement="left">.ipynb</button></a>
<!-- Download PDF via print -->
<button type="button" id="download-print" class="btn btn-secondary topbarbtn" title="Print to PDF"
onClick="window.print()" data-toggle="tooltip" data-placement="left">.pdf</button>
</div>
</div>
<!-- Source interaction buttons -->
<!-- Full screen (wrap in <a> to have style consistency -->
<a class="full-screen-button"><button type="button" class="btn btn-secondary topbarbtn" data-toggle="tooltip"
data-placement="bottom" onclick="toggleFullScreen()" aria-label="Fullscreen mode"
title="Fullscreen mode"><i
class="fas fa-expand"></i></button></a>
<!-- Launch buttons -->
<div class="dropdown-buttons-trigger">
<button id="dropdown-buttons-trigger" class="btn btn-secondary topbarbtn"
aria-label="Launch interactive content"><i class="fas fa-rocket"></i></button>
<div class="dropdown-buttons">
<a class="binder-button" href="https://mybinder.org/v2/gh/gdsbook/book/master?urlpath=lab/tree/notebooks/01_geospatial_computational_environment.ipynb"><button type="button"
class="btn btn-secondary topbarbtn" title="Launch Binder" data-toggle="tooltip"
data-placement="left"><img class="binder-button-logo"
src="../_static/images/logo_binder.svg"
alt="Interact on binder">Binder</button></a>
<a class="colab-button" href="https://colab.research.google.com/github/gdsbook/book/blob/master/notebooks/01_geospatial_computational_environment.ipynb"><button type="button" class="btn btn-secondary topbarbtn"
title="Launch Colab" data-toggle="tooltip" data-placement="left"><img class="colab-button-logo"
src="../_static/images/logo_colab.png"
alt="Interact on Colab">Colab</button></a>
</div>
</div>
</div>
<!-- Table of contents -->
<div class="d-none d-md-block col-md-2 bd-toc show">
<div class="tocsection onthispage pt-5 pb-3">
<i class="fas fa-list"></i>
Contents
</div>
<nav id="bd-toc-nav">
<ul class="nav section-nav flex-column">
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#computational-tools-for-geographic-data-science">
Computational Tools for Geographic Data Science
</a>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#open-science">
Open Science
</a>
<ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry">
<a class="reference internal nav-link" href="#computational-notebooks">
Computational notebooks
</a>
</li>
<li class="toc-h3 nav-item toc-entry">
<a class="reference internal nav-link" href="#open-source-packages">
Open source packages
</a>
</li>
<li class="toc-h3 nav-item toc-entry">
<a class="reference internal nav-link" href="#reproducible-platforms">
Reproducible platforms
</a>
</li>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry">
<a class="reference internal nav-link" href="#the-computational-building-blocks-of-this-book">
The (computational) building blocks of this book
</a>
<ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry">
<a class="reference internal nav-link" href="#jupyter-notebooks-and-jupyterlab">
Jupyter Notebooks and JupyterLab
</a>
<ul class="nav section-nav flex-column">
<li class="toc-h4 nav-item toc-entry">
<a class="reference internal nav-link" href="#notebooks">
Notebooks
</a>
</li>
<li class="toc-h4 nav-item toc-entry">
<a class="reference internal nav-link" href="#cells">
Cells
</a>
</li>
<li class="toc-h4 nav-item toc-entry">
<a class="reference internal nav-link" href="#rich-content">
Rich Content
</a>
</li>
<li class="toc-h4 nav-item toc-entry">
<a class="reference internal nav-link" href="#jupyter-lab">
Jupyter Lab
</a>
</li>
</ul>
</li>
<li class="toc-h3 nav-item toc-entry">
<a class="reference internal nav-link" href="#python-and-open-source-packages">
Python and Open Source Packages
</a>
<ul class="nav section-nav flex-column">
<li class="toc-h4 nav-item toc-entry">
<a class="reference internal nav-link" href="#python">
Python
</a>
</li>
<li class="toc-h4 nav-item toc-entry">
<a class="reference internal nav-link" href="#id13">
Open Source Packages
</a>
</li>
</ul>
</li>
<li class="toc-h3 nav-item toc-entry">
<a class="reference internal nav-link" href="#containerised-platform">
Containerised platform
</a>
<ul class="nav section-nav flex-column">
<li class="toc-h4 nav-item toc-entry">
<a class="reference internal nav-link" href="#run-the-book-s-container">
Run the book’s container
</a>
</li>
<li class="toc-h4 nav-item toc-entry">
<a class="reference internal nav-link" href="#troubleshooting">
Troubleshooting
</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div id="main-content" class="row">
<div class="col-12 col-md-9 pl-md-3 pr-md-0">
<div>
<div class="section" id="geospatial-computational-environment">
<h1>Geospatial Computational Environment<a class="headerlink" href="#geospatial-computational-environment" title="Permalink to this headline">¶</a></h1>
<div class="section" id="computational-tools-for-geographic-data-science">
<h2>Computational Tools for Geographic Data Science<a class="headerlink" href="#computational-tools-for-geographic-data-science" title="Permalink to this headline">¶</a></h2>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">IPython.display</span> <span class="kn">import</span> <span class="n">Image</span>
</pre></div>
</div>
</div>
</div>
<p>This chapter provides an overview of the scientific and computational context
in which the book is framed. First, we will explore debates around Open
Science, its origins, and how the computational community is responding to
these. In particular, we will discuss computational notebooks, open-source
packages, and reproducible platforms. Having covered the conceptual
background, we will turn to a practical introduction of the key infrastructure
that makes up this book: Jupyter Notebooks and JupyterLab, Python packages,
and a containerised platform to run the book.</p>
</div>
<div class="section" id="open-science">
<h2>Open Science<a class="headerlink" href="#open-science" title="Permalink to this headline">¶</a></h2>
<p>The term Open Science has grown in popularity in recent years. Although it is
used in a variety of contexts with slightly different meanings, a general
sense of the intuition behind Open Science is the understanding that the
scientific process, at its core, is meant to be transparent and accessible.
In this context, the focus on openess is not to be seen as an “add-on” that
changes the general approach only cosmetically, but as a key component of what
makes science Science. Indeed the scientific process, understood as one where
we “build on the shoulders of Giants” and progress through dialectic, can only
work properly is there is enough transparency and accessibility that the
community can access and study both results <em>and</em> the process that created
them.</p>
<p>To better understand the argument behind modern Open Science, it is useful
to take a historical perspective. The idea of openness was engrained at the
core of early scientists. In fact that was one of the key differentials with
their contemporary “alchemists” which, in many respects, were working on
similar topics albeit in a much more opaque way <a href="#id1"><span class="problematic" id="id2">:cite:`Nielsen_2020`</span></a>. Scientists
would record the field or lab experiments on paper notebooks or diaries,
providing enough detail to, first, remember what they had done and how they
had arrived at their results, but also to ensure other members of the
scientific community could study, understand, and replicate their findings.
One of the most famous of these annotations are Galileo’s drawings of Jupiter (<a class="reference external" href="https://commons.wikimedia.org/wiki/File:Medicean_Stars.png">source</a>) and the Medicean stars:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">url</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"https://upload.wikimedia.org/wikipedia/"</span>\
<span class="s2">"commons/c/ca/Medicean_Stars.png"</span><span class="p">)</span>
<span class="n">Image</span><span class="p">(</span><span class="n">url</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="../_images/01_geospatial_computational_environment_4_0.png" src="../_images/01_geospatial_computational_environment_4_0.png" />
</div>
</div>
<p>There is a growing perception that much of the original ethos of Science to
operate through transparency and accessibility has been lost. A series of
recent big profile scandals have even prompted some to call it a state of
crisis <a href="#id3"><span class="problematic" id="id4">:cite:`Ioannidis_2007`</span></a>. This “crisis” arises because the analyses that scientists conduct
are difficult to repeat, let alone understand. Both article length and publication
volume has grown immensely since the early days of science, and this has
affected our ability to understand our literature as a whole.</p>
<p>Why is there a sense that Science is no longer open and
transparent in the way Galileo’s diaries were? Although certinaly not the only
or even the most important one, technology plays a role. The process and workflow
of original scientists relied on a set of “analog” technologies for which an
“analog” parallel set of tools was developed to keep track and document
progress. Hence the paper notebooks where biologists drew species, or chemists
painstakingly detailed each step they took in the lab. In the case of social
sciences, this was probably easier in the sense that quantitative data was not
abundant and much of the analysis relied either on math or small datasets
which could be directly documented in the original publications.</p>
<p>However Science has evolved a great deal since then, and much of the
experimental workflow is dominated by a variety of machinery, most
prominently by computers. Most of the Science done today, at some
point in the process, takes the form of operations mediated through software
programs. In this context, the traditional approach of writing down in a paper
notebook every step followed becomes dislocated from the medium in which most of
the scientific work takes place.</p>
<p>The current state of Science in terms of transparency and openness is prompting
for action <a href="#id5"><span class="problematic" id="id6">:cite:`Rey_2009`</span></a>. On the back of these debates, the term
“reproducibility” is also gaining traction. Again, this is a rather general
term but, in one variant or another, its definition alludes to the need of
scientific results to be accompanied by enough information and detail so they
could be repeated by a third party. Since much of modern science is mediated
through computers, reproducibility thus poses important challenges for the
tools and practices the scientific community builds and relies on. Although
there is a variety of approaches, in this book we focus on what we see as the
emerging consensus. This framework enables to record and express entire
workflows in a way that is both transparent and that fosters efficiency and
collaboration.</p>
<p>We structure our approach to reproducibility in three main layers that build on
each other. At the top of this “stack” are <em>computational notebooks</em>; supporting
the code written in notebooks are <em>open source packages</em>; and making possible to
transfer computations across different hardware devices and/or architectures
are what we term <em>reproducible platforms</em>. Let us delve into each of them with
a bit more detail before we practically show how this book is built on this
infrastructure (and how you too can reproduce it at home!).</p>
<div class="section" id="computational-notebooks">
<h3>Computational notebooks<a class="headerlink" href="#computational-notebooks" title="Permalink to this headline">¶</a></h3>
<p>Computational notebooks are the XXIst Century sibling of Galileo’s notebooks.
Like their predecessors, they allow researchers, (data) scientists, and
computational practitioners to record their practices and steps taken as they
are going about their work; unlike the pen and paper approach, computational
notebooks are fully integrated in the technological paradigm in which research
and computation takes place today. For these reasons, they are rapidly becoming the
modern-day version of the traditional academic paper, the main vehicle on
which (computational) knowledge is created, shared, and consumed.
Computational notebooks (or notebooks, from now on) are also spreading their
reach into industry practices, being used, for example, in reports.</p>
<p>All implementations of notebooks share a series of
core features. First, a notebook comprises a single file that stores narrative text,
computer code, and the output produced by code. Storing both
narrative and computational work in a <em>single file</em> means that the entire
workflow can be recorded and documented in the same place, without having to
resort to ancillary devices (like a paper notebook). A second feature of
notebooks is that they allow for <em>interactive work</em>. Modern computational work
benefits from the ability to try, fail, tinker, and iterate quickly until a
working solution is found. Notebooks embody this quality and enable the user
to work interactively. Whether the computation takes place on a laptop or
on a data center, notebooks provide the same interface for interactive
computing, lowering the cognitive load require to scale up. Third, notebooks
have <em>interoperability</em> built in. The notebook format is designed for
recording and sharing computational work, but not necessarily for other stages
of the research cycle. To widen the range of possibilities and
applications, notebooks are designed to be easily convertible into other
formats. For example, while a specific application is required to open and edit
most notebook file formats, no additional software is required to convert them
into pdf files that can be read, printed, and annotated without the need of technical
software.</p>
<p>Notebooks represent the top layer on the reproducibility stack. They can capture
in detailed and reproducible ways work that is specific about a given project:
what data is used, how it is read, cleaned, and transformed; what algorithms are used, how they
are combined; how each figure in the project is generated, etc. Guidance on how
to write notebooks in efficient ways is also emerging (e.g. <a href="#id7"><span class="problematic" id="id8">:cite:`Rule_2019`</span></a>).</p>
</div>
<div class="section" id="open-source-packages">
<h3>Open source packages<a class="headerlink" href="#open-source-packages" title="Permalink to this headline">¶</a></h3>
<p>To make notebooks an efficient medium to communicate computational work, it is
important that they are concise and streamlined. One way to achieve this goal is
to only include the parts of the work that are unique to the application being
recorded in the notebook, and to avoid duplication. From this it follows that
if a piece of code is used several times across the notebook, or even across
several notebooks, that functionality should probably be taken out of the
notebook and into a centralised place where it can be accessed whenever
needed. In other words, such functionality should be turned into a package.</p>
<p>Packages are modular, flexible and repurposable compilations of code. Unlike
notebooks, they do not capture specific applications but abstractions of
functionality that can be used in a variety of contexts. Their function is to
avoid duplication “downstream” by encapsulating functionality in a way that
can be accessed and used in a variety of contexts without having to re-write
code every time it is needed. In doing so, packages (or libraries, an
interchangeable term in this context) embody the famous hacker moto of D.R.Y.:
“don’t repeat yourself”.</p>
<p>Open source packages are packages whose code is available to inspect, modify
and redistribute. They fulfill the same functions as any package in terms of
modularising code, but they also enable transparency as any user can
access the exposed functionality <em>and</em> the underlying code that
generates it. For this reason, for code packages to serve Open Science and
reproducibility, they need to be open source.</p>
</div>
<div class="section" id="reproducible-platforms">
<h3>Reproducible platforms<a class="headerlink" href="#reproducible-platforms" title="Permalink to this headline">¶</a></h3>
<p>For computational work to be fully reproducible and open, it needs to be
possible to replicate in a different (computational) environment than where it
was originally created. This means that it is not sufficient to specify in a
notebook the code that creates the final outputs, and to rely on open source
packages for more general functionality; the environment specified by those
two components needs to be reproducible too. This statement, which might seem
obvious and straightforward, is not always so due to the scale and complexity
of modern computational workflows and infrastructures. The old saying of “if
it works on my laptop, what’s the problem?” is not enough any more, it needs
to work on “any laptop” (or computer).</p>
<p>Reproducible platforms encompass the more general aspects
that enable open source packages and notebooks to be reproducible. A
reproducible platform thus specifies the infrastructure required to ensure a
notebook that uses certain open source packages can be successfully executed.
Infrastructure, in this context, relates to lower-level aspects of the
software stack, such as the operating system, and even some hardware
requirements, such as the use of specific chips such as graphics processing
units (GPU). Additionally, a reproducible platform will also specify the
versions of packages that are required to recreate the results presented in a
notebook.</p>
<p>Unlike open source packages, the notion of reproducible platforms is not as
widespread and generally agreed upon. Its necessity has only become apparent more
recently, and work on providing them in standardised ways is less developed
than in the case of notebook technology or code packaging and distribution.
Nevertheless, some inroads are being made. One area which has experienced
significant progress in recent years and holds great promise in this context is
container technology. Containers are a lightweight version of a virtual
machine, which is a program that enables an entire operating system to run
compartimentalised on top of another operating system. Containers allow to
encapsulate an entire environment (or platform) in a format that is easy to
transfer and reproduce in a variety of computational contexts. The most
popular technology for containers nowadays is Docker, and the opportunities
that it provides to build transparent and transferrable infrastructure for
data science are starting to be explored <a href="#id9"><span class="problematic" id="id10">:cite:`Cook_2017`</span></a>.</p>
</div>
</div>
<div class="section" id="the-computational-building-blocks-of-this-book">
<h2>The (computational) building blocks of this book<a class="headerlink" href="#the-computational-building-blocks-of-this-book" title="Permalink to this headline">¶</a></h2>
<div class="section" id="jupyter-notebooks-and-jupyterlab">
<h3>Jupyter Notebooks and JupyterLab<a class="headerlink" href="#jupyter-notebooks-and-jupyterlab" title="Permalink to this headline">¶</a></h3>
<div class="section" id="notebooks">
<h4>Notebooks<a class="headerlink" href="#notebooks" title="Permalink to this headline">¶</a></h4>
<p>This book uses notebooks as the main format in which its content is created and
distributed. Each chapter is written as a separate notebook and can
be run interactively. At the same time, we collect all chapters and convert
them into different formats for “static consumption” (ie. read only), either
in HTML format for the web, or PDF to be printed in a physical copy.
This section will present the specific format of notebooks we use, and
illustrate its building blocks in a way that allows you to then follow the
rest of the book interactively.</p>
<p>Our choice of notebook is Jupyter <a href="#id11"><span class="problematic" id="id12">:cite:`Kluyver2016jupyter`</span></a>. A Jupyter notebook is a plain
text file with the <code class="docutils literal notranslate"><span class="pre">.ipynb</span></code> extension, which means that it is an easy file to
move around, sync, and track over time. Internally, it is structured as a plain-text document containing
JavaScript Object Notation that records the state of the notebook, so they
also integrate well with a host of modern web technologies.
The atomic element that makes up a notebook is called a <em>cell</em>. Cells are
consistent chunks of content that contain either text or code. In fact, a
notebook can be thought of as an ordered collection of cells. Cells can be of
two types: <em>text</em> and <em>code</em>.</p>
</div>
<div class="section" id="cells">
<h4>Cells<a class="headerlink" href="#cells" title="Permalink to this headline">¶</a></h4>
<p>Text cells contain text written in the Markdown markup language. Markdown is a
popular set of rules to create rich content (e.g. headers, lists, links) from
flat, plain text files without being as complex and sophisticated as other
typesetting approaches. The notebook will then render markdown
automatically. For more demanding or specific tasks, text cells can further
integrate <span class="math notranslate nohighlight">\(\LaTeX\)</span> notation. This means we can write most forms of narrative
relying on markdown, which is more straightforward, and rely on <span class="math notranslate nohighlight">\(\LaTeX\)</span> for
more sophisticated parts, such as equations. Covering Markdown rules in detail
is beyond the scope of this chapter, but the interested reader can inspect the
<a class="reference external" href="https://help.github.com/en/github/writing-on-github/basic-writing-and-formatting-syntax">official Github specification</a>
of the so-called Github-flavored markdown, the one adopted by the notebook.</p>
<p>Code cells are text boxes that contain computer code. In the case of this
book, all code will be Python, but Jupyter notebooks are flexible enough to
work with other languages (see the offical list of Jupyter-supported kernels
<a class="reference external" href="https://github.com/jupyter/jupyter/wiki/Jupyter-kernels">here</a>).
Aesthetically, code cells look as follows:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># This is a code cell</span>
</pre></div>
</div>
</div>
</div>
<p>A code cell can be run to execute the code it contains. If such code produces
an output (e.g. a table or a figure), this will be printed as a cell output.
Every time a cell is run, its counter will go up once.</p>
</div>
<div class="section" id="rich-content">
<h4>Rich Content<a class="headerlink" href="#rich-content" title="Permalink to this headline">¶</a></h4>
<p>Code cells in a notebook also enable the embedding of rich (web) content. The
<code class="docutils literal notranslate"><span class="pre">IPython</span></code> package provides methods to access as series of media and bring them
directly to the notebook environment. Let us see how this can be done
practically. To be able to demonstrate it, we will need to <em>import</em> the
<code class="docutils literal notranslate"><span class="pre">display</span></code> module (skip to the next section if you want to learn more about
importing packages):</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">IPython.display</span> <span class="k">as</span> <span class="nn">display</span>
</pre></div>
</div>
</div>
</div>
<p>This makes available additional functionality that allows us to embed rich
content. For example, we can include a YouTube clip by passing the video ID:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">display</span><span class="o">.</span><span class="n">YouTubeVideo</span><span class="p">(</span><span class="s1">'iinQDhsdE9s'</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_html">
<iframe
width="400"
height="300"
src="https://www.youtube.com/embed/iinQDhsdE9s"
frameborder="0"
allowfullscreen
></iframe>
</div></div>
</div>
<p>Or we can pass standard HTML code:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">display</span><span class="o">.</span><span class="n">HTML</span><span class="p">(</span><span class="s2">"""<table></span>
<span class="s2"><tr></span>
<span class="s2"><th>Header 1</th></span>
<span class="s2"><th>Header 2</th></span>
<span class="s2"></tr></span>
<span class="s2"><tr></span>
<span class="s2"><td>row 1, cell 1</td></span>
<span class="s2"><td>row 1, cell 2</td></span>
<span class="s2"></tr></span>
<span class="s2"><tr></span>
<span class="s2"><td>row 2, cell 1</td></span>
<span class="s2"><td>row 2, cell 2</td></span>
<span class="s2"></tr></span>
<span class="s2"></table>"""</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_html"><table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table></div></div>
</div>
<p>Note that this opens the door for including a large number of elements from the
web, since an <code class="docutils literal notranslate"><span class="pre">iframe</span></code> of any other website can also be included. Of more relevance
for this book, for example, we can embed interactive maps with an <code class="docutils literal notranslate"><span class="pre">iframe</span></code>:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">osm</span> <span class="o">=</span> <span class="s2">"""</span>
<span class="s2"><iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.openstreetmap.org/export/embed.html?bbox=-2.9662737250328064%2C53.400500637844594%2C-2.964626848697662%2C53.402550738394034&amp;layer=mapnik" style="border: 1px solid black"></iframe><br/><small><a href="http://www.openstreetmap.org/#map=19/53.40153/-2.96545">View Larger Map</a></small></span>
<span class="s2">"""</span>
<span class="n">display</span><span class="o">.</span><span class="n">HTML</span><span class="p">(</span><span class="n">osm</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_html">
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://www.openstreetmap.org/export/embed.html?bbox=-2.9662737250328064%2C53.400500637844594%2C-2.964626848697662%2C53.402550738394034&layer=mapnik" style="border: 1px solid black"></iframe><br/><small><a href="http://www.openstreetmap.org/#map=19/53.40153/-2.96545">View Larger Map</a></small>
</div></div>
</div>
<p>Finally, using a similar approach, we can also load and display local
images, which we will so throughout the book. For that, we use the <code class="docutils literal notranslate"><span class="pre">Image</span></code>
method:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"../infrastructure/logo/"</span>\
<span class="s2">"logo_transparent-bg.png"</span><span class="p">)</span>
<span class="n">display</span><span class="o">.</span><span class="n">Image</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="../_images/01_geospatial_computational_environment_16_0.png" src="../_images/01_geospatial_computational_environment_16_0.png" />
</div>
</div>
</div>
<div class="section" id="jupyter-lab">
<h4>Jupyter Lab<a class="headerlink" href="#jupyter-lab" title="Permalink to this headline">¶</a></h4>
<p>Our recommended way to interact with Jupyter notebooks is through Jupyter Lab.
Jupyter Lab is an interface to the Jupyter ecosystem that brings together
several tools for data science into a consistent interface that enables the user
to accomplish most of her workflows. It is built as a web app following a
client-server architechture. This means the computation is decoupled from the
interface. This decoupling allows each to be hosted in the most convenient and
efficient solution. For example, you might be following this book
interactively in your laptop. In this case, it is likely both the server that
runs all the Python computations you specify in code cells (what we call the
<em>kernel</em>) is running locally, and you are interacting with it through your
browser of preference. But the same technology could power a situation where
your kernel is running in a cloud data center, and you interact with Jupyter
Lab from a tablet.</p>
<p>Jupyter Lab’ interface has three main areas:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="n">path</span> <span class="o">=</span> <span class="p">(</span><span class="s2">"../figures/jupyter_lab.png"</span><span class="p">)</span>
<span class="n">display</span><span class="o">.</span><span class="n">Image</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<img alt="../_images/01_geospatial_computational_environment_18_0.png" src="../_images/01_geospatial_computational_environment_18_0.png" />
</div>
</div>
<p>At the top we find a menu bar (red box in the figure) that allows us to open,
create and interact with files, as well as to modify the appearance and
behaviour of Jupyter Lab. The largest real estate is occupied by the main
pane (blue box). By default, there is an option to create a new notebook, open
a console, a terminal session, a (markdown) text file, and a window for
contextual help. Jupyter Lab provides a flexible workspace in that the user
can open as many windows as needed and rearrange them as desired by dragging
and dropping. Finally, on the left of the main pane we find the side pane
(green box),
which has several tabs that toggle on and off different auxilliary information.
By default, we find a file browser based on the folder from where the session
has been launched. But we can also switch to a pane that lists all the
currently open kernels and terminal sessions, a list of all the commands in the
menu (the command <em>palette</em>), and a list of all the open windows inside the
lab.</p>
</div>
</div>
<div class="section" id="python-and-open-source-packages">
<h3>Python and Open Source Packages<a class="headerlink" href="#python-and-open-source-packages" title="Permalink to this headline">¶</a></h3>
<div class="section" id="python">
<h4>Python<a class="headerlink" href="#python" title="Permalink to this headline">¶</a></h4>
<p>The main component of this book relies on the <a class="reference external" href="https://www.python.org/">Python</a>
programming language. Python is a <a class="reference external" href="https://en.wikipedia.org/wiki/High-level_programming_language">high-
level</a>
programming language used widely in data science. To give a couple of examples of its
relevance, it powers <a class="reference external" href="https://www.quora.com/How-does-dropbox-use-python-What-features-are-implemented-in-it-any-tangentially-related-material?share=1">most of the company Dropbox’s main product</a>, and is also heavily
<a class="reference external" href="https://www.python.org/about/success/usa/">used</a> to control satellites at NASA.
A great deal of Science is also done in Python, from <a class="reference external" href="https://www.youtube.com/watch?v=mLuIB8aW2KA">research in
astronomy</a> at UC Berkley, to
<a class="reference external" href="https://lectures.quantecon.org/py/">courses in economics</a> by Nobel Prize-winning professors.</p>
<p>This book uses Python because it is a good language for beginners and
high performance science alike. For this reason, it has emerged as one of the main
and most solid options for Data Science. Python is widely used for data
processing and analysis both in academia and in industry. There is a vibrant and
growing scientific community (through the <a class="reference external" href="http://scipy.org/">Scientific Python</a>
library and the <a class="reference external" href="http://pydata.org/">PyData</a> organization), working in
both universities and companies, to support and enhance the Python’s capabilities.
New methods and usability improvements of existing packages (also known as libraries)
are continuously being released. In geocomputation, Python is also very widely
adopted: it is the language used for scripting in both the main proprietary enterprise
geographic information system,
<a class="reference external" href="http://www.esri.com/software/arcgis">ArcGIS</a>,
and the leading open geographic information system, <a class="reference external" href="http://qgis.org">QGIS</a>. All
of this means that, whether you are thinking of continuing in Higher Education
or trying to find a job in industry, Python will be an important asset, valuable to
employers and scientists alike.</p>
<p>Python code is “dynamically interpreted”, which means it is run on-the-fly without
needing to be compiled. This is in contrast to other kinds of programming
languages, which require an additional non-interactive step where a program is
converted into a binary file, which is then run directly. With Python, one does
not need to worry about this non-interactive compilation step. Instead, we can
simply write code, run code, fix any issues directly, and then re-run the code in a
quick cycle. This makes Python a very productive tool for science, since you can
prototype code quickly and directly.</p>
</div>
<div class="section" id="id13">
<h4>Open Source Packages<a class="headerlink" href="#id13" title="Permalink to this headline">¶</a></h4>
<p>The standard Python language includes some data structures (such as lists and
dictionaries) and allows many basic mathematical operations (e.g. sums, differences,
products). For example, right out of the box, and without any further
action needed, you can use Python as a calculator:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="mi">3</span> <span class="o">+</span> <span class="mi">5</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>8
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="mi">2</span> <span class="o">/</span> <span class="mi">3</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.6666666666666666
</pre></div>
</div>
</div>
</div>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="p">(</span><span class="mi">3</span> <span class="o">+</span> <span class="mi">5</span><span class="p">)</span> <span class="o">*</span> <span class="mi">2</span> <span class="o">/</span> <span class="mi">3</span>
</pre></div>
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>5.333333333333333
</pre></div>
</div>
</div>
</div>
<p>However, the strength of Python as a data analysis tool comes from additional
packages, software that adds functionality to the language itself.
In this book, we will introduce and use many of the core libraries of the “PyData stack”,
a set of heavily-used libraries that make Python a fully-fledged
system for (Geographic) Data Science. We will introduce each package as we use them
throughout the chapters. For now, we will show how an installed package can be
loaded into a session so its functionality can be accessed. This loading of
a package, in Python, is called <em>importing</em>. We will use the library <code class="docutils literal notranslate"><span class="pre">geopandas</span></code> as
an example. The simplest way to import a library is by typing the following:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">geopandas</span>
</pre></div>
</div>
</div>
</div>
<p>We now have access to the entire library of methods and clases, which we
can call by prepending <code class="docutils literal notranslate"><span class="pre">geopandas.</span></code> to the name of the function we want.
Sometimes, however, we will want to shorten the name to save keystrokes. This
approach, called <em>aliasing</em>, can be done as follows:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">geopandas</span> <span class="k">as</span> <span class="nn">gpd</span>
</pre></div>
</div>
</div>
</div>
<p>Now, every time we want to access a function from <code class="docutils literal notranslate"><span class="pre">geopandas</span></code>, all we need to
type before the function’s name is <code class="docutils literal notranslate"><span class="pre">gpd.</span></code>. However sometimes we rather import
only parts of a library. For example, we might only want to use one function.
In this case, it might be cleaner and more efficient to bring the function
itself only:</p>
<div class="cell docutils container">
<div class="cell_input docutils container">