GEOG 376 Study Guide - Final Guide: Spatial Database, Gvsig, Proprietary Software

72 views5 pages
GEOG 376 Final Review
I. Inputs and Outputs
A. Text Files
They are often used as an interchange format for exchanging data between systems.
They are easy to work with in python (You open the file first, then use Python’s
functions to read/write from the file, and then close it)
1. Working with files in Python
Format: open(name[, mode[ , buffering]])
File.write() is used to write content to a file. Unlike the read() method, the write
function requires a parameter
Command
Definition
Placement
R (read)
It reads through the file that is
opened
Within the open function
w
Creates a new file for writing,
but if there is already an
existing file, it will be
overwritten
Within the open function
a (append)
Content is added at the end of
the file using the write
method [file.append]
Within the open function
File.read
Read all the content from a
file into a single variable as
one block of text
Below the open function
File.readlines
Read each line of the file
separately into a list (great
when combined with a loop
Below the open function
File.readline
Read each line of the file
separately (often in a loop)
Below the open function
A + sign might be added for the r, w, or a commands when opening a file, which would
do a little more
If you want to add content to the beginning or the middle of the file the seek method is
used in place of append
B. Reading from the Web
Programming today involves working with content from the web. The ‘urllib’
module allows us to access content from the web and bring in on to our own
computer (or server) and manipulate it, combine it with other data, etc.
When content from the web is returned using urllib, it does not look like the actual
content of the website when using Chrome or Firefox. It is written in HTML
(Hypertext Markup Language), the language used to create websites
Some web platforms offer well structured content. For example Weather
Underground (wunderground.com) offers an Application Programming Interface
(API) that allows us to access weather data in comma delimited format.
II. Classes and Objects
A. Python as an Object-Oriented Programming Language
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-2 of the document.
Unlock all 5 pages and 3 million more documents.

Already have an account? Log in
Object-oriented programming (OOP) focuses on creating reusable patterns of code.
Procedural Programming focuses on explicit sequenced instuctions.
B. Classes
A class is a blueprint for an object created by a programmer, which defines a set of
attributes that will characterize any object that is instantiated from this class.
Class variables are defined within the class construction and are shared by all
instances since they are owned by the class itself. They are placed right below the
class header
C. Objects
Objects are instances of classes and have property over instance variables
The instance variables are different for each object and are defined within methods
Self-parameter: The self parameter ensures that the methods have a way of referring
to object attributes. When the methods are called, however, nothing is passed inside
the parentheses, the object is being automatically passed with the dot operator.
Constructor: this method is used to initialize data automatically when a new object is
created (known as the __init__ method). When used as a function, we do not need to
explicitly call it, only pass the arguments in the parentheses following the class
name when we create a new instance of the class. Any parameters added outside are
passed on to the ___init__ method.
D. Inheritance
Definition: when a class uses code constructed within another class. It is a way that
object-oriented programming achieves recyclable code
The parent class creates a pattern that the child classes are based on, which allows us
to create them via inheritance without writing the same code repeatedly
Child classes/subclasses inherit from the parent class, mainly the variables and the
methods so they can make use of them. We can choose to add more methods,
override existing parent methods, or simply accept the default parent methods with
the pass keyword
III. GDAL and OSGeo Modules
A. Open Source Software
Open Source Software denotes any software for which the original source code is
made freely available and may be redistributed and modified to meet your wn
specifications in your own programs, unlike Proprietary Software, which is non-
free computer software for which the software’s publisher or another person retains
intellectual property rightsusually copyright of the source code.
Most open source GIS tools (QGIS, gvSIG, GRASS) are built using Python, and
can do just about anything that can be done in ArcGIS along with extra features
that are usually not available.
B. GDAL and OGR
GDAL (Geospatial Data Abstraction Library) is a translator library for raster and
vector geospatial data formats that is released under an Open Source license by the
Open Source Geospatial Foundation.
As a library, it presents a single raster abstract data model and single vector
abstract data model to the calling application for all supported formats. (GDAL
takes care of the raster data while OGR [OpenGIS Simple Features Reference
Implementation] designs the vector segments for simple features)
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-2 of the document.
Unlock all 5 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents

Related Questions