SlideShare a Scribd company logo
Python for geo-people
www.helsinki.fi/yliopist
o
Automating GIS-processes
FEC 2017
Lecturers: Vuokko Heikinheimo & Henrikki Tenkanen
vuokko.heikinheimo@helsinki.fi
henrikki.tenkanen@helsinki.fi
6.3.2017
Materials: Henrikki Tenkanen, David Whipp, Vuokko Heikinheimo
www.helsinki.fi/yliopist
o
Python for geo-people
Goals of the course
There are basically four goals in this intensive course
1. Introduce the Python programming language
2. Develop basic programming skills
3. Discuss essential (good) programming practices needed by
young scientists
4. Introduce automatization of different GIS tasks in Python
www.helsinki.fi/yliopist
o
Python for geo-people
Goals of this lecture
• Provide an overview of basic computing practices, and
why you should learn them
• Define computers and programming languages, and how
they operate
• Look at the components of a computer program and a
strategy for writing your own code
www.helsinki.fi/yliopist
o
Python for geo-people
Learning to program
• A significant part of this course will be development of
basic programming skills that will help you write and use
simple numerical models
• I know you’re not computer scientists - I’m not either
• Our goal is take small steps to learn together
• Do you really need to know how to program? Yes.
• You might not be a superstar, but learning to write
simple codes can be very useful
www.helsinki.fi/yliopist
o
Python for geo-people
Why learn to program?
• Rather than being restricted to using existing software,
you will have the ability to develop your own solutions
when solutions do not exist or are inefficient
• Many software packages offer the ability to extend
their capabilities by adding your own short programs
(e.g., ArcGIS, ParaView, Google Earth, etc.)
www.helsinki.fi/yliopist
o
Python for geo-people
Python can be called directly from ArcGIS
www.helsinki.fi/yliopist
o
Python for geo-people
Why learn to program?
• Believe it or not, programming is fun! It
involves
• Breaking complex problems down
into simpler pieces
• Developing a strategy for solving the
problem
• Testing your solution
• All of this can be exciting and rewarding
(when the code works…)
www.helsinki.fi/yliopist
o
Python for geo-people
The scientific method…
…and how programming can make you a better
scientist
1. Define a question
2. Gather information and resources (observe)
3. Form an explanatory hypothesis
4. Test the hypothesis by performing an experiment and
collecting data in a reproducible manner
5. Analyze the data
6. Interpret the data and draw conclusions that serve as a
starting point for new hypothesis
7. Publish results
8. Retest (frequently done by other scientists)
www.helsinki.fi/yliopist
o
Python for geo-people
Learning to program can help us…
1. Define a question
2. Gather information and resources (observe)
3. Form an explanatory hypothesis
4. Test the hypothesis by performing an experiment and
collecting data in a reproducible manner
5. Analyze the data
6. Interpret the data and draw conclusions that serve as a
starting point for new hypothesis
7. Publish results
8. Retest (frequently done by other scientists)
www.helsinki.fi/yliopist
o
Python for geo-people
Good programming practices can help
us…
1. Define a question
2. Gather information and resources (observe)
3. Form an explanatory hypothesis
4. Test the hypothesis by performing an experiment and
collecting data in a reproducible manner
5. Analyze the data
6. Interpret the data and draw conclusions that serve as a
starting point for new hypothesis
7. Publish results
8. Retest (frequently done by other scientists)
Python for geo-people
www.helsinki.fi/yliopist
o
Programming
“Computer programming (often shortened to programming) is a process
that leads from an original formulation of a computing problem to
executable computer programs. Programming involves activities such as
analysis, developing understanding, generating algorithms, verification of
requirements of algorithms including their correctness and resources
consumption, and implementation (commonly referred to as coding) of
algorithms in a target programming language.”
-Wikipedia (2015)
“A program is like a recipe. It contains a list of ingredients (called
variables) and a list of directions (called statements) that tell the
computer what to do with the variables.”
- Webopedia (2015)
www.helsinki.fi/yliopist
o
Python for geo-people
What is a program?
• A program is a detailed
list of step-by-step
instructions telling the
computer exactly what to
do
• The program can be
changed to alter what the
computer will do when
the code is executed
• Software is another name
for a program
# Define plot variables
misfit = NA_data[:,0]
var1 = NA_data[:,1]
var2 = NA_data[:,2]
var3 = NA_data[:,3]
clrmin = round(min(misfit),3)
clrmax = round(min(misfit),2)
trans = 0.75
ptsize = 40
Fortran punchcard
Python source code
www.helsinki.fi/yliopist
o
Python for geo-people
What is a programming language?
• A computer language is what we use to ‘talk’ to a
computer
• Unfortunately, computers don’t yet understand our
native languages
• A programming language is like a code of instructions for
the computer to follow
• It is exact and unambiguous
• Every structure has a precise form (syntax) and a
precise meaning (semantics)
• Python is just one of many programming languages
Python for geo-people
www.helsinki.fi/yliopist
o
High level
programming
Low level
programming
Less code
More code
Slower
Faster
Various different programming languages exist
• Python
• Perl
• Ruby
• JavaScript
• Java
• C++
• C
• Fortran
+ Many others
Programming languages remind our spoken languages!
• There are different ways to express the same meaning
• Some languages are more similar to each other than others
• After learning one language it is easier to learn other ones!
Programming
Moikka, Hello, Hej, Hallo, Hola
echo ”Moikka”, print(”Hello”), console.log(”Hej”),
puts(”Hallo”), System.out.println(”Hola”)
Spoken languages Programming languages
Python for geo-people
www.helsinki.fi/yliopist
o
Python is:
• General purpose
• High level
• Cross-platform
• Open source
• Multi-paradigm: Object oriented / imperative / functional / procedural / reflective
• Uses dynamic type-checking
Why to learn / use Python?
• Easy to learn (a good programming language for the beginners)
• Easy to read and understand – elegant code
• Powerful enough – used in scientific programming
• Countless ready-made modules / libraries to use (also GIS stuff)
• Supportive, large and helpful user community
• Widely supported in different GIS-softwares
- ArcGIS, QGIS, Erdas Imagine, IDRISI, uDig, ILWIS, PostGIS …
• Extremely useful for automating GIS processes
Programming
www.helsinki.fi/yliopist
o
Python for geo-people
Developing a program
• Coming up with a specific list of instructions for the
computer to follow in order to accomplish a desired task
is not easy
• The following list will serve us as a general software
development strategy
1. Analyze the problem
2. Determine specifications
3. Create a design
4. Implement the design
5. Test/debug the program
6. Maintain the program (if necessary)
www.helsinki.fi/yliopist
o
Python for geo-people
Let’s consider an example
• As an American, David was raised in a country that uses
Fahrenheit for temperatures
• 70°F is lovely
• 90°F is hot
• Water freezes at 32°F
• The problem here in Finland is that he doesn’t always
know what he should wear to work when he finds
weather reports with temperatures in degrees Celsius
• A simple program could help
www.helsinki.fi/yliopist
o
Python for geo-people
Developing a program
1. Analyze the problem
• Before you can solve a problem, you must figure out
exactly what should be solved
2. Determine specifications
• Describe exactly what the program will do
• Don’t worry about how it will work. Determine the
input and output values and how they should
interact in the program
www.helsinki.fi/yliopist
o
Python for geo-people
Developing a program
1. Analyze the problem
• Before you can solve a problem, you must figure out
exactly what should be solved
2. Determine specifications
• Describe exactly what the program will do
• Don’t worry about how it will work. Determine the
input and output values and how they should
interact in the program
www.helsinki.fi/yliopist
o
Python for geo-people
Developing a program
3. Create a design
• What is the overall structure of the program? How will
it work?
• It is often helpful to write out the code operation in
pseudocode, precise English (or Finnish) describing
the program. Be specific!
4. Implement the design
• If you’ve done a good job with the previous steps, this
should be fairly straightforward. Take your
pseudocode and ‘translate’ it into Python
www.helsinki.fi/yliopist
o
Python for geo-people
Developing a program
3. Create a design
• What is the overall structure of the program? How will
it work?
• It is often helpful to write out the code operation in
pseudocode, precise English (or Finnish) describing
the program. Be specific!
4. Implement the design
• If you’ve done a good job with the previous steps, this
should be fairly straightforward. Take your
pseudocode and ‘translate’ it into Python
www.helsinki.fi/yliopist
o
Python for geo-people
Developing a program
5. Test/debug the program
• Now you can put your new Python code to the test
(literally) by running it to see whether it reproduces the
expected values
• For any test, you should know the correct values in
advance of running your code. How else can you
confirm it works???
6. Maintain the program
• If you’ve written something that will be shared by other
users, a helpful programmer will continue to add
features that are requested by the users
www.helsinki.fi/yliopist
o
Python for geo-people
Developing a program
5. Test/debug the program
• Now you can put your new Python code to the test
(literally) by running it to see whether it reproduces the
expected values
• For any test, you should know the correct values in
advance of running your code. How else can you
confirm it works???
6. Maintain the program
• If you’ve written something that will be shared by other
users, a helpful programmer will continue to add
features that are requested by the users
www.helsinki.fi/yliopist
o
Python for geo-people
References
Zelle, J. M. (2010). Python programming: an introduction to computer science (2nd ed.). Franklin,
Beedle & Associates, Inc.

More Related Content

What's hot

Python – The Fastest Growing Programming Language
Python – The Fastest Growing Programming LanguagePython – The Fastest Growing Programming Language
Python – The Fastest Growing Programming Language
IRJET Journal
 
Open & reproducible research - What can we do in practice?
Open & reproducible research - What can we do in practice?Open & reproducible research - What can we do in practice?
Open & reproducible research - What can we do in practice?
Felix Z. Hoffmann
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming
KrishnaMildain
 
Python programming
Python programmingPython programming
Python programming
Megha V
 
Python, the Language of Science and Engineering for Engineers
Python, the Language of Science and Engineering for EngineersPython, the Language of Science and Engineering for Engineers
Python, the Language of Science and Engineering for Engineers
Boey Pak Cheong
 
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Edureka!
 
11 Unit1 Chapter 1 Getting Started With Python
11   Unit1 Chapter 1 Getting Started With Python11   Unit1 Chapter 1 Getting Started With Python
11 Unit1 Chapter 1 Getting Started With Python
Praveen M Jigajinni
 
IPython: A Modern Vision of Interactive Computing (PyData SV 2013)
IPython: A Modern Vision of Interactive Computing (PyData SV 2013)IPython: A Modern Vision of Interactive Computing (PyData SV 2013)
IPython: A Modern Vision of Interactive Computing (PyData SV 2013)
PyData
 
Software Carpentry for the Geophysical Sciences
Software Carpentry for the Geophysical SciencesSoftware Carpentry for the Geophysical Sciences
Software Carpentry for the Geophysical Sciences
Aron Ahmadia
 
Seminar report On Python
Seminar report On PythonSeminar report On Python
Seminar report On Python
Shivam Gupta
 
python for linguists
python for linguistspython for linguists
python for linguists
shukaihsieh
 
First python project
First python projectFirst python project
First python project
Neetu Jain
 
Python
PythonPython
Embracing Diversity: Searching over Multiple Languages - Suneel Marthi, Red H...
Embracing Diversity: Searching over Multiple Languages - Suneel Marthi, Red H...Embracing Diversity: Searching over Multiple Languages - Suneel Marthi, Red H...
Embracing Diversity: Searching over Multiple Languages - Suneel Marthi, Red H...
Lucidworks
 
Python | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python TutorialPython | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python Tutorial
QA TrainingHub
 
Lets learn Python !
Lets learn Python !Lets learn Python !
Lets learn Python !
Kiran Gangadharan
 
Python - the basics
Python - the basicsPython - the basics
Python - the basics
University of Technology
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on python
Shubham Yadav
 

What's hot (18)

Python – The Fastest Growing Programming Language
Python – The Fastest Growing Programming LanguagePython – The Fastest Growing Programming Language
Python – The Fastest Growing Programming Language
 
Open & reproducible research - What can we do in practice?
Open & reproducible research - What can we do in practice?Open & reproducible research - What can we do in practice?
Open & reproducible research - What can we do in practice?
 
Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming Python programming | Fundamentals of Python programming
Python programming | Fundamentals of Python programming
 
Python programming
Python programmingPython programming
Python programming
 
Python, the Language of Science and Engineering for Engineers
Python, the Language of Science and Engineering for EngineersPython, the Language of Science and Engineering for Engineers
Python, the Language of Science and Engineering for Engineers
 
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
 
11 Unit1 Chapter 1 Getting Started With Python
11   Unit1 Chapter 1 Getting Started With Python11   Unit1 Chapter 1 Getting Started With Python
11 Unit1 Chapter 1 Getting Started With Python
 
IPython: A Modern Vision of Interactive Computing (PyData SV 2013)
IPython: A Modern Vision of Interactive Computing (PyData SV 2013)IPython: A Modern Vision of Interactive Computing (PyData SV 2013)
IPython: A Modern Vision of Interactive Computing (PyData SV 2013)
 
Software Carpentry for the Geophysical Sciences
Software Carpentry for the Geophysical SciencesSoftware Carpentry for the Geophysical Sciences
Software Carpentry for the Geophysical Sciences
 
Seminar report On Python
Seminar report On PythonSeminar report On Python
Seminar report On Python
 
python for linguists
python for linguistspython for linguists
python for linguists
 
First python project
First python projectFirst python project
First python project
 
Python
PythonPython
Python
 
Embracing Diversity: Searching over Multiple Languages - Suneel Marthi, Red H...
Embracing Diversity: Searching over Multiple Languages - Suneel Marthi, Red H...Embracing Diversity: Searching over Multiple Languages - Suneel Marthi, Red H...
Embracing Diversity: Searching over Multiple Languages - Suneel Marthi, Red H...
 
Python | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python TutorialPython | What is Python | History of Python | Python Tutorial
Python | What is Python | History of Python | Python Tutorial
 
Lets learn Python !
Lets learn Python !Lets learn Python !
Lets learn Python !
 
Python - the basics
Python - the basicsPython - the basics
Python - the basics
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on python
 

Viewers also liked

How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
Leslie Samuel
 
Generations of Programming Languages
Generations of Programming LanguagesGenerations of Programming Languages
Generations of Programming Languages
Tarun Sharma
 
assembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUassembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YU
Education
 
Fuel Up JavaScript with Functional Programming
Fuel Up JavaScript with Functional ProgrammingFuel Up JavaScript with Functional Programming
Fuel Up JavaScript with Functional Programming
Shine Xavier
 
BTCONCEPT.BIZ MAKE MONEY WITH BITCOIN
BTCONCEPT.BIZ MAKE MONEY WITH BITCOIN  BTCONCEPT.BIZ MAKE MONEY WITH BITCOIN
BTCONCEPT.BIZ MAKE MONEY WITH BITCOIN
Anang Komentator
 
Bitcoin, The New Great Opportunity for Entrepreneurs on the Internet
Bitcoin, The New Great Opportunity for Entrepreneurs on the InternetBitcoin, The New Great Opportunity for Entrepreneurs on the Internet
Bitcoin, The New Great Opportunity for Entrepreneurs on the Internet
Alejandro Sewrjugin
 
Understanding bitcoin
Understanding bitcoinUnderstanding bitcoin
Understanding bitcoin
Shuo Yang
 
Bitcoin: the future money, or a scam?
Bitcoin: the future money, or a scam?Bitcoin: the future money, or a scam?
Bitcoin: the future money, or a scam?
Ignaz Wanders
 
Programmable Money - Visual Guide to Bitcoin as a Technology
Programmable Money - Visual Guide to Bitcoin as a TechnologyProgrammable Money - Visual Guide to Bitcoin as a Technology
Programmable Money - Visual Guide to Bitcoin as a Technology
Mark Smalley
 
Bitcoin Startup Malaysia
Bitcoin Startup MalaysiaBitcoin Startup Malaysia
Bitcoin Startup Malaysia
Arsyan Ismail
 
Intro to bitcoin march 2013
Intro to bitcoin march 2013Intro to bitcoin march 2013
Intro to bitcoin march 2013
Ron Gross
 
C programming-apurbo datta
C programming-apurbo dattaC programming-apurbo datta
C programming-apurbo datta
Apurbo Datta
 
Bitcoin
BitcoinBitcoin
Bitcoin
mahdi ataeyan
 
Plc programming with fbd
Plc programming with fbdPlc programming with fbd
Plc programming with fbd
dodikyuniar
 
Programmable logic controllers
Programmable logic controllersProgrammable logic controllers
Programmable logic controllers
photoshop
 
Why Bitcoin's Rate of Adoption is Only Going to Increase
Why Bitcoin's Rate of Adoption is Only Going to IncreaseWhy Bitcoin's Rate of Adoption is Only Going to Increase
Why Bitcoin's Rate of Adoption is Only Going to Increase
MecklerMedia
 
Eee3420 lecture01 rev2011
Eee3420 lecture01 rev2011Eee3420 lecture01 rev2011
Eee3420 lecture01 rev2011
benson215
 
Eee3420 lecture03 rev2011
Eee3420 lecture03 rev2011Eee3420 lecture03 rev2011
Eee3420 lecture03 rev2011
benson215
 
Programming logic controllers (plc)
Programming  logic controllers (plc)Programming  logic controllers (plc)
Programming logic controllers (plc)
Sudhir Reddy
 
Automationcontrol7
Automationcontrol7Automationcontrol7
Automationcontrol7
liyanagek
 

Viewers also liked (20)

How to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your NicheHow to Become a Thought Leader in Your Niche
How to Become a Thought Leader in Your Niche
 
Generations of Programming Languages
Generations of Programming LanguagesGenerations of Programming Languages
Generations of Programming Languages
 
assembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUassembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YU
 
Fuel Up JavaScript with Functional Programming
Fuel Up JavaScript with Functional ProgrammingFuel Up JavaScript with Functional Programming
Fuel Up JavaScript with Functional Programming
 
BTCONCEPT.BIZ MAKE MONEY WITH BITCOIN
BTCONCEPT.BIZ MAKE MONEY WITH BITCOIN  BTCONCEPT.BIZ MAKE MONEY WITH BITCOIN
BTCONCEPT.BIZ MAKE MONEY WITH BITCOIN
 
Bitcoin, The New Great Opportunity for Entrepreneurs on the Internet
Bitcoin, The New Great Opportunity for Entrepreneurs on the InternetBitcoin, The New Great Opportunity for Entrepreneurs on the Internet
Bitcoin, The New Great Opportunity for Entrepreneurs on the Internet
 
Understanding bitcoin
Understanding bitcoinUnderstanding bitcoin
Understanding bitcoin
 
Bitcoin: the future money, or a scam?
Bitcoin: the future money, or a scam?Bitcoin: the future money, or a scam?
Bitcoin: the future money, or a scam?
 
Programmable Money - Visual Guide to Bitcoin as a Technology
Programmable Money - Visual Guide to Bitcoin as a TechnologyProgrammable Money - Visual Guide to Bitcoin as a Technology
Programmable Money - Visual Guide to Bitcoin as a Technology
 
Bitcoin Startup Malaysia
Bitcoin Startup MalaysiaBitcoin Startup Malaysia
Bitcoin Startup Malaysia
 
Intro to bitcoin march 2013
Intro to bitcoin march 2013Intro to bitcoin march 2013
Intro to bitcoin march 2013
 
C programming-apurbo datta
C programming-apurbo dattaC programming-apurbo datta
C programming-apurbo datta
 
Bitcoin
BitcoinBitcoin
Bitcoin
 
Plc programming with fbd
Plc programming with fbdPlc programming with fbd
Plc programming with fbd
 
Programmable logic controllers
Programmable logic controllersProgrammable logic controllers
Programmable logic controllers
 
Why Bitcoin's Rate of Adoption is Only Going to Increase
Why Bitcoin's Rate of Adoption is Only Going to IncreaseWhy Bitcoin's Rate of Adoption is Only Going to Increase
Why Bitcoin's Rate of Adoption is Only Going to Increase
 
Eee3420 lecture01 rev2011
Eee3420 lecture01 rev2011Eee3420 lecture01 rev2011
Eee3420 lecture01 rev2011
 
Eee3420 lecture03 rev2011
Eee3420 lecture03 rev2011Eee3420 lecture03 rev2011
Eee3420 lecture03 rev2011
 
Programming logic controllers (plc)
Programming  logic controllers (plc)Programming  logic controllers (plc)
Programming logic controllers (plc)
 
Automationcontrol7
Automationcontrol7Automationcontrol7
Automationcontrol7
 

Similar to FEC2017-Introduction-to-programming

An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()
Blue Elephant Consulting
 
Programming for data science in python
Programming for data science in pythonProgramming for data science in python
Programming for data science in python
UmmeSalmaM1
 
Python as Web Development
Python as Web Development Python as Web Development
Python as Web Development
SamWas1
 
Introduction to Python Programming Basics
Introduction  to  Python  Programming BasicsIntroduction  to  Python  Programming Basics
Introduction to Python Programming Basics
Dhana malar
 
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
Prof. Wim Van Criekinge
 
python Certification Training in marthahalli
python Certification Training in marthahallipython Certification Training in marthahalli
python Certification Training in marthahalli
MUDDUKRISHNA14
 
Python
PythonPython
Python
GAnkitgupta
 
Exploratory Analytics in Python provided by EY.pdf
Exploratory Analytics in Python provided by EY.pdfExploratory Analytics in Python provided by EY.pdf
Exploratory Analytics in Python provided by EY.pdf
totondak
 
Learning Python
Learning PythonLearning Python
Learning Python
Mindy McAdams
 
introduction to Python (for beginners)
introduction to Python (for beginners)introduction to Python (for beginners)
introduction to Python (for beginners)
guobichrng
 
Python with dataScience
Python with dataSciencePython with dataScience
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
Akhil Kaushik
 
Why Python in required in Civil Engineering
Why Python in required in Civil EngineeringWhy Python in required in Civil Engineering
Why Python in required in Civil Engineering
Rushikesh Kolhe
 
python classes in thane
python classes in thanepython classes in thane
python classes in thane
faizrashid1995
 
A Whirlwind Tour Of Python
A Whirlwind Tour Of PythonA Whirlwind Tour Of Python
A Whirlwind Tour Of Python
Asia Smith
 
Introduction to Agile Software Development & Python
Introduction to Agile Software Development & PythonIntroduction to Agile Software Development & Python
Introduction to Agile Software Development & Python
Tharindu Weerasinghe
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
AnirudhaGaikwad4
 
Python programming ppt.pptx
Python programming ppt.pptxPython programming ppt.pptx
Python programming ppt.pptx
nagendrasai12
 
PYTHON UNIT 1
PYTHON UNIT 1PYTHON UNIT 1
PYTHON UNIT 1
nagendrasai12
 
Agile Languages for Rapid Prototyping
Agile Languages for Rapid PrototypingAgile Languages for Rapid Prototyping
Agile Languages for Rapid Prototyping
Tharindu Weerasinghe
 

Similar to FEC2017-Introduction-to-programming (20)

An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()
 
Programming for data science in python
Programming for data science in pythonProgramming for data science in python
Programming for data science in python
 
Python as Web Development
Python as Web Development Python as Web Development
Python as Web Development
 
Introduction to Python Programming Basics
Introduction  to  Python  Programming BasicsIntroduction  to  Python  Programming Basics
Introduction to Python Programming Basics
 
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
2015 bioinformatics python_introduction_wim_vancriekinge_vfinal
 
python Certification Training in marthahalli
python Certification Training in marthahallipython Certification Training in marthahalli
python Certification Training in marthahalli
 
Python
PythonPython
Python
 
Exploratory Analytics in Python provided by EY.pdf
Exploratory Analytics in Python provided by EY.pdfExploratory Analytics in Python provided by EY.pdf
Exploratory Analytics in Python provided by EY.pdf
 
Learning Python
Learning PythonLearning Python
Learning Python
 
introduction to Python (for beginners)
introduction to Python (for beginners)introduction to Python (for beginners)
introduction to Python (for beginners)
 
Python with dataScience
Python with dataSciencePython with dataScience
Python with dataScience
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
 
Why Python in required in Civil Engineering
Why Python in required in Civil EngineeringWhy Python in required in Civil Engineering
Why Python in required in Civil Engineering
 
python classes in thane
python classes in thanepython classes in thane
python classes in thane
 
A Whirlwind Tour Of Python
A Whirlwind Tour Of PythonA Whirlwind Tour Of Python
A Whirlwind Tour Of Python
 
Introduction to Agile Software Development & Python
Introduction to Agile Software Development & PythonIntroduction to Agile Software Development & Python
Introduction to Agile Software Development & Python
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Python programming ppt.pptx
Python programming ppt.pptxPython programming ppt.pptx
Python programming ppt.pptx
 
PYTHON UNIT 1
PYTHON UNIT 1PYTHON UNIT 1
PYTHON UNIT 1
 
Agile Languages for Rapid Prototyping
Agile Languages for Rapid PrototypingAgile Languages for Rapid Prototyping
Agile Languages for Rapid Prototyping
 

Recently uploaded

Immersive Learning That Works: Research Grounding and Paths Forward
Immersive Learning That Works: Research Grounding and Paths ForwardImmersive Learning That Works: Research Grounding and Paths Forward
Immersive Learning That Works: Research Grounding and Paths Forward
Leonel Morgado
 
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
yqqaatn0
 
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
vluwdy49
 
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
University of Maribor
 
Oedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptxOedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptx
muralinath2
 
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
yqqaatn0
 
Thornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdfThornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdf
European Sustainable Phosphorus Platform
 
Topic: SICKLE CELL DISEASE IN CHILDREN-3.pdf
Topic: SICKLE CELL DISEASE IN CHILDREN-3.pdfTopic: SICKLE CELL DISEASE IN CHILDREN-3.pdf
Topic: SICKLE CELL DISEASE IN CHILDREN-3.pdf
TinyAnderson
 
The binding of cosmological structures by massless topological defects
The binding of cosmological structures by massless topological defectsThe binding of cosmological structures by massless topological defects
The binding of cosmological structures by massless topological defects
Sérgio Sacani
 
Sharlene Leurig - Enabling Onsite Water Use with Net Zero Water
Sharlene Leurig - Enabling Onsite Water Use with Net Zero WaterSharlene Leurig - Enabling Onsite Water Use with Net Zero Water
Sharlene Leurig - Enabling Onsite Water Use with Net Zero Water
Texas Alliance of Groundwater Districts
 
SAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdfSAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdf
KrushnaDarade1
 
Medical Orthopedic PowerPoint Templates.pptx
Medical Orthopedic PowerPoint Templates.pptxMedical Orthopedic PowerPoint Templates.pptx
Medical Orthopedic PowerPoint Templates.pptx
terusbelajar5
 
Shallowest Oil Discovery of Turkiye.pptx
Shallowest Oil Discovery of Turkiye.pptxShallowest Oil Discovery of Turkiye.pptx
Shallowest Oil Discovery of Turkiye.pptx
Gokturk Mehmet Dilci
 
Phenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvementPhenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvement
IshaGoswami9
 
Basics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different formsBasics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different forms
MaheshaNanjegowda
 
bordetella pertussis.................................ppt
bordetella pertussis.................................pptbordetella pertussis.................................ppt
bordetella pertussis.................................ppt
kejapriya1
 
NuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyerNuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyer
pablovgd
 
Micronuclei test.M.sc.zoology.fisheries.
Micronuclei test.M.sc.zoology.fisheries.Micronuclei test.M.sc.zoology.fisheries.
Micronuclei test.M.sc.zoology.fisheries.
Aditi Bajpai
 
20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx
Sharon Liu
 
Bob Reedy - Nitrate in Texas Groundwater.pdf
Bob Reedy - Nitrate in Texas Groundwater.pdfBob Reedy - Nitrate in Texas Groundwater.pdf
Bob Reedy - Nitrate in Texas Groundwater.pdf
Texas Alliance of Groundwater Districts
 

Recently uploaded (20)

Immersive Learning That Works: Research Grounding and Paths Forward
Immersive Learning That Works: Research Grounding and Paths ForwardImmersive Learning That Works: Research Grounding and Paths Forward
Immersive Learning That Works: Research Grounding and Paths Forward
 
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
原版制作(carleton毕业证书)卡尔顿大学毕业证硕士文凭原版一模一样
 
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
在线办理(salfor毕业证书)索尔福德大学毕业证毕业完成信一模一样
 
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
Remote Sensing and Computational, Evolutionary, Supercomputing, and Intellige...
 
Oedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptxOedema_types_causes_pathophysiology.pptx
Oedema_types_causes_pathophysiology.pptx
 
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
如何办理(uvic毕业证书)维多利亚大学毕业证本科学位证书原版一模一样
 
Thornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdfThornton ESPP slides UK WW Network 4_6_24.pdf
Thornton ESPP slides UK WW Network 4_6_24.pdf
 
Topic: SICKLE CELL DISEASE IN CHILDREN-3.pdf
Topic: SICKLE CELL DISEASE IN CHILDREN-3.pdfTopic: SICKLE CELL DISEASE IN CHILDREN-3.pdf
Topic: SICKLE CELL DISEASE IN CHILDREN-3.pdf
 
The binding of cosmological structures by massless topological defects
The binding of cosmological structures by massless topological defectsThe binding of cosmological structures by massless topological defects
The binding of cosmological structures by massless topological defects
 
Sharlene Leurig - Enabling Onsite Water Use with Net Zero Water
Sharlene Leurig - Enabling Onsite Water Use with Net Zero WaterSharlene Leurig - Enabling Onsite Water Use with Net Zero Water
Sharlene Leurig - Enabling Onsite Water Use with Net Zero Water
 
SAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdfSAR of Medicinal Chemistry 1st by dk.pdf
SAR of Medicinal Chemistry 1st by dk.pdf
 
Medical Orthopedic PowerPoint Templates.pptx
Medical Orthopedic PowerPoint Templates.pptxMedical Orthopedic PowerPoint Templates.pptx
Medical Orthopedic PowerPoint Templates.pptx
 
Shallowest Oil Discovery of Turkiye.pptx
Shallowest Oil Discovery of Turkiye.pptxShallowest Oil Discovery of Turkiye.pptx
Shallowest Oil Discovery of Turkiye.pptx
 
Phenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvementPhenomics assisted breeding in crop improvement
Phenomics assisted breeding in crop improvement
 
Basics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different formsBasics of crystallography, crystal systems, classes and different forms
Basics of crystallography, crystal systems, classes and different forms
 
bordetella pertussis.................................ppt
bordetella pertussis.................................pptbordetella pertussis.................................ppt
bordetella pertussis.................................ppt
 
NuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyerNuGOweek 2024 Ghent programme overview flyer
NuGOweek 2024 Ghent programme overview flyer
 
Micronuclei test.M.sc.zoology.fisheries.
Micronuclei test.M.sc.zoology.fisheries.Micronuclei test.M.sc.zoology.fisheries.
Micronuclei test.M.sc.zoology.fisheries.
 
20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx20240520 Planning a Circuit Simulator in JavaScript.pptx
20240520 Planning a Circuit Simulator in JavaScript.pptx
 
Bob Reedy - Nitrate in Texas Groundwater.pdf
Bob Reedy - Nitrate in Texas Groundwater.pdfBob Reedy - Nitrate in Texas Groundwater.pdf
Bob Reedy - Nitrate in Texas Groundwater.pdf
 

FEC2017-Introduction-to-programming

  • 1. Python for geo-people www.helsinki.fi/yliopist o Automating GIS-processes FEC 2017 Lecturers: Vuokko Heikinheimo & Henrikki Tenkanen vuokko.heikinheimo@helsinki.fi henrikki.tenkanen@helsinki.fi 6.3.2017 Materials: Henrikki Tenkanen, David Whipp, Vuokko Heikinheimo
  • 2. www.helsinki.fi/yliopist o Python for geo-people Goals of the course There are basically four goals in this intensive course 1. Introduce the Python programming language 2. Develop basic programming skills 3. Discuss essential (good) programming practices needed by young scientists 4. Introduce automatization of different GIS tasks in Python
  • 3. www.helsinki.fi/yliopist o Python for geo-people Goals of this lecture • Provide an overview of basic computing practices, and why you should learn them • Define computers and programming languages, and how they operate • Look at the components of a computer program and a strategy for writing your own code
  • 4. www.helsinki.fi/yliopist o Python for geo-people Learning to program • A significant part of this course will be development of basic programming skills that will help you write and use simple numerical models • I know you’re not computer scientists - I’m not either • Our goal is take small steps to learn together • Do you really need to know how to program? Yes. • You might not be a superstar, but learning to write simple codes can be very useful
  • 5. www.helsinki.fi/yliopist o Python for geo-people Why learn to program? • Rather than being restricted to using existing software, you will have the ability to develop your own solutions when solutions do not exist or are inefficient • Many software packages offer the ability to extend their capabilities by adding your own short programs (e.g., ArcGIS, ParaView, Google Earth, etc.)
  • 6. www.helsinki.fi/yliopist o Python for geo-people Python can be called directly from ArcGIS
  • 7. www.helsinki.fi/yliopist o Python for geo-people Why learn to program? • Believe it or not, programming is fun! It involves • Breaking complex problems down into simpler pieces • Developing a strategy for solving the problem • Testing your solution • All of this can be exciting and rewarding (when the code works…)
  • 8. www.helsinki.fi/yliopist o Python for geo-people The scientific method… …and how programming can make you a better scientist 1. Define a question 2. Gather information and resources (observe) 3. Form an explanatory hypothesis 4. Test the hypothesis by performing an experiment and collecting data in a reproducible manner 5. Analyze the data 6. Interpret the data and draw conclusions that serve as a starting point for new hypothesis 7. Publish results 8. Retest (frequently done by other scientists)
  • 9. www.helsinki.fi/yliopist o Python for geo-people Learning to program can help us… 1. Define a question 2. Gather information and resources (observe) 3. Form an explanatory hypothesis 4. Test the hypothesis by performing an experiment and collecting data in a reproducible manner 5. Analyze the data 6. Interpret the data and draw conclusions that serve as a starting point for new hypothesis 7. Publish results 8. Retest (frequently done by other scientists)
  • 10. www.helsinki.fi/yliopist o Python for geo-people Good programming practices can help us… 1. Define a question 2. Gather information and resources (observe) 3. Form an explanatory hypothesis 4. Test the hypothesis by performing an experiment and collecting data in a reproducible manner 5. Analyze the data 6. Interpret the data and draw conclusions that serve as a starting point for new hypothesis 7. Publish results 8. Retest (frequently done by other scientists)
  • 11. Python for geo-people www.helsinki.fi/yliopist o Programming “Computer programming (often shortened to programming) is a process that leads from an original formulation of a computing problem to executable computer programs. Programming involves activities such as analysis, developing understanding, generating algorithms, verification of requirements of algorithms including their correctness and resources consumption, and implementation (commonly referred to as coding) of algorithms in a target programming language.” -Wikipedia (2015) “A program is like a recipe. It contains a list of ingredients (called variables) and a list of directions (called statements) that tell the computer what to do with the variables.” - Webopedia (2015)
  • 12. www.helsinki.fi/yliopist o Python for geo-people What is a program? • A program is a detailed list of step-by-step instructions telling the computer exactly what to do • The program can be changed to alter what the computer will do when the code is executed • Software is another name for a program # Define plot variables misfit = NA_data[:,0] var1 = NA_data[:,1] var2 = NA_data[:,2] var3 = NA_data[:,3] clrmin = round(min(misfit),3) clrmax = round(min(misfit),2) trans = 0.75 ptsize = 40 Fortran punchcard Python source code
  • 13. www.helsinki.fi/yliopist o Python for geo-people What is a programming language? • A computer language is what we use to ‘talk’ to a computer • Unfortunately, computers don’t yet understand our native languages • A programming language is like a code of instructions for the computer to follow • It is exact and unambiguous • Every structure has a precise form (syntax) and a precise meaning (semantics) • Python is just one of many programming languages
  • 14. Python for geo-people www.helsinki.fi/yliopist o High level programming Low level programming Less code More code Slower Faster Various different programming languages exist • Python • Perl • Ruby • JavaScript • Java • C++ • C • Fortran + Many others Programming languages remind our spoken languages! • There are different ways to express the same meaning • Some languages are more similar to each other than others • After learning one language it is easier to learn other ones! Programming Moikka, Hello, Hej, Hallo, Hola echo ”Moikka”, print(”Hello”), console.log(”Hej”), puts(”Hallo”), System.out.println(”Hola”) Spoken languages Programming languages
  • 15. Python for geo-people www.helsinki.fi/yliopist o Python is: • General purpose • High level • Cross-platform • Open source • Multi-paradigm: Object oriented / imperative / functional / procedural / reflective • Uses dynamic type-checking Why to learn / use Python? • Easy to learn (a good programming language for the beginners) • Easy to read and understand – elegant code • Powerful enough – used in scientific programming • Countless ready-made modules / libraries to use (also GIS stuff) • Supportive, large and helpful user community • Widely supported in different GIS-softwares - ArcGIS, QGIS, Erdas Imagine, IDRISI, uDig, ILWIS, PostGIS … • Extremely useful for automating GIS processes Programming
  • 16. www.helsinki.fi/yliopist o Python for geo-people Developing a program • Coming up with a specific list of instructions for the computer to follow in order to accomplish a desired task is not easy • The following list will serve us as a general software development strategy 1. Analyze the problem 2. Determine specifications 3. Create a design 4. Implement the design 5. Test/debug the program 6. Maintain the program (if necessary)
  • 17. www.helsinki.fi/yliopist o Python for geo-people Let’s consider an example • As an American, David was raised in a country that uses Fahrenheit for temperatures • 70°F is lovely • 90°F is hot • Water freezes at 32°F • The problem here in Finland is that he doesn’t always know what he should wear to work when he finds weather reports with temperatures in degrees Celsius • A simple program could help
  • 18. www.helsinki.fi/yliopist o Python for geo-people Developing a program 1. Analyze the problem • Before you can solve a problem, you must figure out exactly what should be solved 2. Determine specifications • Describe exactly what the program will do • Don’t worry about how it will work. Determine the input and output values and how they should interact in the program
  • 19. www.helsinki.fi/yliopist o Python for geo-people Developing a program 1. Analyze the problem • Before you can solve a problem, you must figure out exactly what should be solved 2. Determine specifications • Describe exactly what the program will do • Don’t worry about how it will work. Determine the input and output values and how they should interact in the program
  • 20. www.helsinki.fi/yliopist o Python for geo-people Developing a program 3. Create a design • What is the overall structure of the program? How will it work? • It is often helpful to write out the code operation in pseudocode, precise English (or Finnish) describing the program. Be specific! 4. Implement the design • If you’ve done a good job with the previous steps, this should be fairly straightforward. Take your pseudocode and ‘translate’ it into Python
  • 21. www.helsinki.fi/yliopist o Python for geo-people Developing a program 3. Create a design • What is the overall structure of the program? How will it work? • It is often helpful to write out the code operation in pseudocode, precise English (or Finnish) describing the program. Be specific! 4. Implement the design • If you’ve done a good job with the previous steps, this should be fairly straightforward. Take your pseudocode and ‘translate’ it into Python
  • 22. www.helsinki.fi/yliopist o Python for geo-people Developing a program 5. Test/debug the program • Now you can put your new Python code to the test (literally) by running it to see whether it reproduces the expected values • For any test, you should know the correct values in advance of running your code. How else can you confirm it works??? 6. Maintain the program • If you’ve written something that will be shared by other users, a helpful programmer will continue to add features that are requested by the users
  • 23. www.helsinki.fi/yliopist o Python for geo-people Developing a program 5. Test/debug the program • Now you can put your new Python code to the test (literally) by running it to see whether it reproduces the expected values • For any test, you should know the correct values in advance of running your code. How else can you confirm it works??? 6. Maintain the program • If you’ve written something that will be shared by other users, a helpful programmer will continue to add features that are requested by the users
  • 24. www.helsinki.fi/yliopist o Python for geo-people References Zelle, J. M. (2010). Python programming: an introduction to computer science (2nd ed.). Franklin, Beedle & Associates, Inc.