Introduction to Programming

What is programming for GIS?

What is GIS?

“Maps are both the raw material and the product of geographic information systems (GIS).”

— Xi Liu, Penn State University

“Everything is related to everything else, but near things are more related than distant things.”

—The First Law of Geography by Waldo Tobler

“GIS is like the machinery that transforms data
into the commodity information
that is needed to solve problems or create opportunities.”

—David DiBiase, Director of Education, Industry Solutions, Esri

Welcome to the (GIS) Machine

The Purpose of Tools

Simple Task: Adding First 2 Numbers

\(0 + 1 =\) \(1\)

Simple Task: Adding First 3 Numbers

\(0 + 1 + 2 =\) \(3\)

Simple Task: Adding First 5 Numbers

\(0 + 1 + 2 + 3 + 4 =\) \(10\)

Simple Task: Adding First 10 Numbers

\(0+1+2+3+4+5+6+7+8+9 =\) \(45\)

Simple Task: Adding First 25 Numbers

\(0+1+2+3+4+5+\ldots +23+24 =\) \(300\)

Okay, adding sequences is just …

\(0+1+2+3+4+5+\ldots +23+24 =\) \(\frac{n\;\left(n+1\right)}{2}\)

Examples in GIS

Calculating Distance

  • Euclidean
  • Manhattan
  • Geodesic

GIS: a tool for spatial analysis

“It is difficult to dig a ditch without a shovel,
but it is easier if you have a backhoe.”

 

 

 

 

  • High-level language
  • Object-oriented programming
  • Third-party packages
    (namely ArcGIS and QGIS)

Language & interpreter

We need both.

Semantics & syntax

It’s a language after all.

syntax
the set of symbols and rules that define terms used collectively to form a correctly structured document
semantics
the meaning (intent or purpose) behind the syntax

Examples

English Python
Write the word “Hello” >>> print("Hello")
Hello
Add 0+1+2+3+4 >>> sum(range(0,5))
10
My computer’s home directory is … >>> import os
>>> print(os.path.expanduser("~"))
C:\Users\twdavis
What version of Python am I using? >>> import sys
>>> print(sys.version_info.major)
3

Exercises

Shared on our AGOL Group.

  • Exercise 1 - Python Fundamentals
  • Exercise 2 - More Fundamentals

Additional Readings