Sunteți pe pagina 1din 50

5SSG2059 GEOCOMPUTATION

DR JAMES MILLINGTON
DR JON READES

TERM 1 2017/18

School of Social Science & Public Policy


Department of Geography
WHERE WE ARE

Section 1: Thinking about this module

Section 2: Rethinking Geography

Section 3: Thinking Computationally


TODAYS OUTCOMES

By the end of today you should:


Understand the structure of the module
Begin to think about new data and computational
approaches in Geography
Have an initial understanding of how to think
computationally
GSA PATHWAY OVERVIEW

Three module progression:


Geocomputation: foundations of programming, thinking
with data & making maps.
Spatial analysis: why geography matters, interpolation &
modelling with spatial data.
Applied GSA: advanced concepts & their practical
applications (crime, demographics, transport, etc.)
You can take as few or many modules as you want, but you
must complete all three modules to obtain BA/BSc (with
Geocomputation & Spatial Analysis) on your degree.
MODULE SYLLABUS

Module Aims
to build competence in the use of computational techniques for
cleaning, exploring, visualising and performing reproducible
analysis on data.

Learning Outcomes
understand commonly-used computational techniques and be
able to employ them appropriately
MODULE SYLLABUS

Lectures with Discussion: Mondays 16:00-18:00, S0.13


Practicals with Coding: Tuesdays 15:00-18:00, K-1.027/28

Homework and Preparation is Important!


Reading and Watching
To learn coding and think about broader issues
See online reading list: https://kcl.rl.talis.com/index.html
Exercises
Will require active problem solving & online research
Peer-to-Peer learning
STUDY AIDS

KEATS
MODULE SYLLABUS

The module takes the following schedule:

1: Thinking like a Computer [JM with JR briefly]


2: Functions and Packages [JR] [Quiz 1 opens end of practical]
3: Introducing Pandas [JM]
4: EDA & The Visual Display of Quantitative Information [JR]
5: Making Sense of Data [JR] [Assessed code during practical]
MODULE SYLLABUS

The module takes the following schedule:

6: Manipulating Data [JM]


7: Transforms and Standardisation [JR]
8: Making Maps! [JR] [Quiz 2 opens at end of practical]
9: Correlation [JM]
10: Bringing it all together [JM]
[Formative Code Notebook due end of week 10]
ASSESSMENT

Two Online Quizzes (10% each, in term)


Understanding of coding & data analysis concepts
One Assessed Executable Code Assessment (15% week 5)
Technical comprehension of computational techniques
One Formative Executable Code (0% week 10)
One Final Report (65%, 16 January 2018)
Present data analysis using module techniques, incl.
justification and assessment of methods and data
Demonstrate understanding and application in a practical
context
WHERE WE ARE

Section 1: Thinking about this module

Section 2: Thinking Computationally

Section 3: Rethinking Geography


WHAT IS A COMPUTER?

A device for performing computations

A programmable device for performing


computations
Program: Sequence of operations
GEOGRAPHICAL REVOLUTIONS

1960s The (first) Quantitative Revolution


Need to carve out professional and scientific niche for
Geographers
Aim was to move beyond mere description towards
analysis and prediction
Greater emphasis on numbers and empirical measurement
Building on new computing technology
QUANTITATIVE MODELS

Haggett and Chorley: New Models in Geography


These new models were statistical using computers to fit
lines through data (order of 100s of data points)
CRITICISMS

There is a clear disparity between the sophisticated theoretical and


methodological framework which we are using and our ability to say
anything really meaningful about events as they unfold around us.
There are too many anomalies between what we purport to explain
and manipulate and what actually happens. There is an ecological
problem, an urban problem, an international trade problem, and yet
we seem incapable of saying anything of any depth or profundity
about any of them. When we do say something it appears trite and
rather ludicrous.
Harvey (1972, p.6)
CONTINUING DIVIDES

Physical Human

Computation
GEOCOMPUTATION TO BRIDGE THE GAP?

A computational human geographic (CHG)


framework or more generally a geocomputational
paradigm would seem to offer a logical focus for a
new type of human geography that would seek to
develop linkages between soft geographic theory,
developments in high-performance computing, Al
toolkits, and GIS.
Openshaw (1998, p.326)
Towards a more computationally minded scientific human geography,
Environment and Planning A, 30(2), pp. 317332. doi: 10.1068/a300317
DATA SCIENCE

Geography

Conway (2013)
A NEW QUANT. REVOLUTION

Wyly (2014): A simultaneous acceleration of


a) Digital data interactions between individuals and
institutions (i.e. social media, digital communication)
b) Digital data representing humans in motion (GPS, geo-
located devices)

Add to this advances in data collection about the physical


world:
a) UAVs (drones) and new EO satellites
b) Cheap environmental sensors Wyly, E. (2014). The new quantitative
revolution. Dialogues in Human
Geography, 4(1), 26-38.
A NEW QUANT. REVOLUTION
GEOCOMPUTATION RESEARCH

How does computational


thinking change how we
approach geographical
research?
GEOCOMPUTATION RESEARCH

Google Earth Engine TB of EO data + cloud computing


BUT

Does Big Data = All Data?

Does what and who can be counted matter?


(How representative are these data streams?)

What are the ethical and moral concerns about


individual level data?

Who controls (and sees) these flows of data?


WHERE WE ARE

Section 1: Thinking about this module

Section 2: Rethinking Geography

Section 3: Thinking Computationally


ALGORITHM: FIND THE AVERAGE

147642
What ways could we find the average (mean) of these
numbers?
ALGORITHM: FIND THE AVERAGE

Create a list of numbers


Create a variable called total [the sum of the numbers]
Create a variable called count [the count of numbers]
For each number in the list of numbers:
add the number to the total
add 1 to the count of numbers
Calculate the Average [total divided by count]
Report the Average
COMMANDING THE COMPUTER

We need to tell the computer


what algorithm to execute

One way to think of algorithms is


as flow charts

We cant give the computer flow


charts so we either:
Use a GUI
Write code
INTERACTING WITH COMPUTERS

Code vs GUI
CODE: FIND THE AVERAGE
COMPUTERS: GOOD OR BAD?

What are computers good at?


Doing the same thing over and over
Doing EXACTLY what they are told

What are computers bad at?


Generating knowledge thats what humans do
Creativity they do EXACTLY what you tell them
BENEFITS OF CODING?

Flexibility

Reproducibility

Scalability
COMPUTER LANGUAGES

Code is in a given language with all the things


that come with that
vocabulary (reserved words)
grammar (syntax)

In this module we will use the


Python programming language
RESERVED WORDS

You cannot use any of Pythons reserved


words as a name for a variable
NAMING VARIABLES

Other rules for variable names:


They cannot start with a number (e.g. 3items is invalid)
White space and symbols (e.g. $ + etc) not allowed
_ (underscore) is allowed (e.g. my_variable is fine)
Case matters: myVar is different from myvar and MYVAR
Tip: start variables names with lowercase (many coders do this)
Variable names can be arbitrarily long
Tip: keep variables short but readable (max_DBH not
maximum_Diameter_at_Breast_Height_of_Trees)
COMPUTER LANGUAGES

Calculating
the mean
in R

Calculating
the mean
in Python
VARIABLES

Name Value Type

Hello
message string
Python!

n 42 integer

pi 3.14159 float
THINKING LOGICALLY

What if the user had entered a negative value?

Conditional Execution:
Only execute code in given conditions
CONDITIONAL EXECUTION

Conditional
Reserved word Operator colon

if hours > 0:
print(Hours were worked)

indentation

If condition on line 1 is met


Then execute line 2 (indented)
BOOLEAN EXPRESSIONS

An expression which is either True or False

if hours > 0:
print(Hours were worked)

True and False are special values


belonging to type bool
COMPARISON OPERATORS

x == y # x is equal to y
x != y # x is not equal to y
x > y # x is greater than y
x < y # x is less than y
x >= y # x is greater than or equal to y
x <= y # x is less than or equal to y
x is y # x is the same as y
x is not y # x is not the same as y

NB: = is for assignment, == is for comparison


LOGICAL OPERATORS

and or not

Expression only True if x


x > 0 and x < 10
satisfies BOTH conditions
Expression True if y
y == 5 or y == 10
satisfies EITHER condition

Expression True if condition


not (x > y)
within parentheses is False
ALTERNATIVE EXECUTION

if hours > 0:
print(Hours were worked)
else:
print(No hours worked)

If condition on line 1 is met


Then execute line 2 (indented)
Else execute line 4 (indented)
FLOW [CHART] CONTROL

if hours > 0:
print(Hours were worked)
else:
print(No hours worked)
hours > 0
False
True
print(Hours were print(Hours were
worked) worked)
CHAINED CONDITIONAL

if hours > 0:
print(Hours were worked)
elif hours == 0:
print(No hours worked)
else:
print(invalid input)

elif is an abbreviation of else if.

Even if more than one condition is true, only the first


true condition executes
CHAINED CONDITIONAL

print(Hours were
hours > 0
worked) Yes
No

print(No hours hours == 0


worked) Yes
No
if hours > 0:
print(Hours were worked)
elif hours == 0: print(invalid input)
print(No hours worked)
else:
print(invalid input)
COMPARING TYPES

Warning: comparing floats with == or != is unsafe

Because of the way the computer stores float values they may
not be actually exactly as they appear
Example: 2.51 cannot be represented by a float and is represented by a
number very close to it

Advice:
Only use == or != to compare int or string types
Use only < or > to compare floats

For more detail than you can handle read this or watch this
INDENTING AND COLONS

This is a part of the syntax will lead to syntax errors!


if hours > 0:
print(Hours were worked)
Correct else:
print(No hours worked)

if hours > 0:
print(Hours were worked)
Incorrect
else
print(No hours worked)

Beware logic errors!


QUIZ 1

Ensure you understand content of Code Camp notebooks 2,


3 & 4 ready for Quiz 1
- Python Basics
- Conditionals

To help you with this:


- Complete all Tasks & Exercises in Practical 1 notebook
- Ask questions
- Review Chapters 2 & 3 of Severance (2014)
Python for Informatics http://pythonlearn.com/book.php
PYTHON WITH JUPYTER NOTEBOOKS
RECALL: THE KEY IDEAS
1. This module will require problem solving
Proactively find solutions and seek help

2. We are amidst a new quantitative revolution


Consider the benefits and dangers

3. Computers are fast but stupid


We need to think like them to use them well

S-ar putea să vă placă și