GEOG 378

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/69

flashcard set

Earn XP

Description and Tags

Introduction to Geocomputing

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

70 Terms

1
New cards

Well-known Text (WKT)

a text markup language for representing vector geometry objects on a map, spatial reference systems of spatial objects and transformations between spatial reference system

2
New cards

Well-known Binary (WKB)

used to transfer and store the same information on databases

3
New cards

Points/Lines/Polygons

an area consists of lines, which consist of points, which consist of coordinates

4
New cards

.shp

shapefiles are storing vector-based geometric informtion of geographic features

5
New cards

.prj

a file containing coordinate system information to provide spatial referencing of data in ArcGIS

6
New cards

.shx

the index file that stores the index feature geometry

7
New cards

.dbf

the dBASE table that stores the attribute information of features

8
New cards

Topology Matters

allows many GIS operations to be done without accessing the point files (efficiency)

Incorrect calculations (perimeter, area, attributes)

Avoid data analysis nightmares

9
New cards

Raster data is best for:

Continuous data- things that change smoothly across space

Examples: elevation, temperature, rainfall, satellite images or aerial photos

10
New cards

Vector data is best for:

Discrete data- things that have clear boundaries or locations

Examples: raods, rivers, city boundaries, land parcels, utility lines

11
New cards

Interpreter

a program that executes computer code (source code →interpreter→ output)

12
New cards

Compiler

translates the program into low-level machine instructions (source code→compiler→object code→executor→output)

13
New cards

Syntax Errors

refer to the structure of a program and the rules about syntax

14
New cards

Runtime Errors

error does not appear until you run the program; also called exceptions

15
New cards

Semantic/Logic Errors

codes can run succesfully but it will give out the wrong result

16
New cards

long (data type in python)

used for huge integers that are outside the range of int

17
New cards

complex (python data type)

representing numbers with a fractional part

18
New cards

type()

displays the python type for any value

type(3) → int

type(True) → bool

19
New cards

Logical Operators

<,>,==,!=,>=,<=, and, or, not

20
New cards

Membership Operators

in, not in

21
New cards

float(), str(), int()

converts the value inside to whatever type it will be (type conversion)

22
New cards

id() function

takes a value or a variable and returns an integer that acts as a unique identifer which is guaranteed to be unique and constant for this object during its lifetime

23
New cards

dot notation

specify the module and then the function followed by a dot (e.g. math.log(x))

24
New cards

Modularity

breaking a system or program into smaller, independart parts that can be developed, tested, and reused separtely

25
New cards

if__name==”__main__”:

to make sure certain code only runs when the file is executed directly, not when it is imported as a module into another program

26
New cards

for loop

picks each element out of the sequence and sets the loop variable equal to that item (perform a block of code for a number of times)

a sequence is:

  1. a string of characters: “Python”

  2. a list ex: [1,2,3], [‘a’,’b’,’c’]

  3. a tuple (“geog”, 378, “intro to geocomputing”)

27
New cards

range(start,stop,step)

range(5) → [0,1,2,3,4]

range(7,3,-1) → [7,6,5,4]

28
New cards

break

end (or break out of) a loop

29
New cards

continue

skip the rest of the loop body statements, but do not end the loop

30
New cards

while loops

causes a block statement to be repeated as long as iteration condition is true

ex:

count = 10

while count > 0

     print count

     count -=1

print(“Blastoff”)

31
New cards

try/except statements

let you “try” a piece of code that might cause an error, and then “handle” that error if it happens instead of stopping your whole program

example:

try:

     #code that might cause an error

except:

     #code that runs if there is an error

32
New cards

5 Types of Containers

lists, strings, typles, dictionaires, and sets

33
New cards

Lists

values that make up lists are elements [0,1,2,3]

34
New cards

list()

use this when converting another iterable/copying

35
New cards

Slicing Lists

a[1:3] → 1,2

a[2:] → 2, 3,4,5…

[:] → the whole list

36
New cards

Lists are…

mutable (we can change elements)

37
New cards

del

removes an element from a list

ex: del a[1]

38
New cards

len()

returns the length of a list

39
New cards

list.append(x)

append an item x to the end of a list

40
New cards

list.sort()

order items in ascending orders

41
New cards

list.sort(reverse = True)

order items in descending order

42
New cards

Give a sequence of numbers, how to find the largest? (8,15,45,23,88,68,75)

numbers = [8,15,45,23,88,68,75]

largests = numbers[0]

for n in numbers:

if n > largest:

largest = n

print(largest)

43
New cards

dictionary {}

key value pairs

  • keys must be immutable (cannot be change)

  • keys must be unique - no dulpicates

    • repeated values are okay

44
New cards

Access to Dict

dictName[Key] = value

45
New cards

Strings

  • can slice strings

  • strings are immutable, can’t change an existing strings

  • to get the last letter do:

    • last[length-1]

46
New cards

String Transversal

processing a string one character at a time

47
New cards

How to count the frequency of a character in a string? Define a function in Python

Find the frequency of ‘a’ in “banana”

fruit = “banana”

count = 0

for char in fruit:

      if char == ‘a’:

         count = count + 1

print count

48
New cards

Tuples

like list, elements can be any type and variable from element to element

also immutable (cannot be change)

49
New cards

Set

an unordered collection of unique elements

used for checking duplicates or generating unquie collections

50
New cards

open a file

f = open(filename, mode, buffering)

  • mode/buffering optional

51
New cards

Read and/or Write a file

f.write(…)

52
New cards

Close a File

f.closed

53
New cards

Open File Modes

rt", "rb", "wt"
read text, read binary, write text

54
New cards

Methods for Reading a File

  • use a for loop to read every line

  • use a while loop to read every line until the end of the line

55
New cards

Good practice to use the with keyword when dealing with files

  • PRO: file is closed properly close after it is suite finishes, even if exception is raised on the way

with open (filename, ‘r’) as f:

read_data = f.readlines()

print(f.closed) #TRUE

56
New cards

How to list all files in a directory, and then print all files names with the .csv extensions?

import os

files = os.list.dir(‘.’)

for f in files:

     if f.endwith(‘csv’):

print(f)

57
New cards

Class

describes what something is and what it can do

(concept of lake)

58
New cards

Object

a thing (something you can imagine or describe)

  • attribute: detailes or characteristics (what it has)

  • behaviors: actions (what it can do)

    • Ex: a paticular lake

59
New cards

Syntax for generating an instance of a class

classInstance = ClassName()

60
New cards

Data Attribute Assignment

data attributes, like methods, are accessed by using dot notation

ex: pt1 = Point()

pt1.latitude = 34.05

pt1. longitude = -118.24

61
New cards

Protected Attributes

Prefixed with a single underscore
Can still be accessed outside of the class

62
New cards

Private Attributes

Prefixing with a double underscore
Can be access but cannot be changed

63
New cards

Class Methods

like functions but are defined within the class and are therefore part of the class

class ClassName:

     def method1(self, parm1, parm2,…):

            statement 1 

            statement2

64
New cards

dir() function

returns a list of strings containing all the names of valid attributes and methods for the object

65
New cards

init_:

initialize object attributes automatically when created

66
New cards

str:

defines how the object prints as text

67
New cards

dict or vars(obj)

shows all attributes of an object

68
New cards

Inheritance

lets a new class (child) reuse and exten code from another parent

the child inherits all parent method but can override them

69
New cards

How to represent cities in GIS using the classes and objects in Python?

create a class with several attributes, such as name, latitude, longitude and so one

70
New cards

Class Composition

classes can be nested like functions