Sunday, May 31, 2015

Python is #1

I have had some minor exposure to Python while I was taking a course on Drupal, an Open Source Configuration Management System (CMS) used to build websites ( here’s a site I built for my wife:

But, by no means would I claim to be experienced with this language.  So, that is why I chose an article about Python for this Participation Exercise. The title of the article is, “Python is Now the Most Popular Introductory Teaching Language at Top U.S. Universities.” 

According to this article,Top-ranked CS departments at MIT and UC Berkeley recently switched their introductory courses to Python.” This tells me we are in great company as we endeavor to learn Python and apply what we learn to GIS. Though there were some comments about Python hiding too much, that is, the code is “built-in”, and the user does not have to create code from scratch, most of the article was very positive towards Python. Personally, I like the “Built-in” tools and features that do not require you to develop code because it saves time and troubleshooting. Additionally, there are numerous examples of code for various applications that you can copy and use without having to develop them completely on your own. As we progress through this course I am positive we will develop more code and find endless uses for Python in our GIS endeavors. 

Thursday, May 28, 2015

Natural Hazards: Lahars and Module 2

It has started again. I can feel my pulse trying to jump out of my body. I have not had so much excitement in a while. Module 2 for GIS Applications was an exercise in learning about Natural Disasters, such as Meteor strikes, Hurricanes, Floods, and, my map of the day: Lahars. The lab consisted of using several new tools including:

-  Hydrology toolset.
-  Mosaic to New Raster (Data Management)
-  Fill tool
-  Flow Direction
-  Flow Accumulation
-  Conditional Evaluation of Rasters
-  Raster to Feature
-  Using Raster Math >  Math > Int
- And using  Spatial Analyst Toolbox > Hydrology > Stream to Feature

The objective was to determine where Lahars or streams would flow in the event that Mt Hood erupted. "Lahars, or volcanic debris flows, are water-saturated mixtures of soil and rock fragments that can travel very long distances (over 60 miles) and as fast as 50 miles per hour in steep channels close to a volcano." (Oregon Geology Fact Sheet)

I also had to take two DEMs and combine them to make one mosaic to then compute the flow by changing the cells to integers from floating points. I used the Spatial Analyst Toolbox and executed the Math > Int tool. This converted the floating point raster to an integer raster-- this was way cool!
After this step I could use other tools such as the Con Tool to control the output value for each cell. Ultimately, I wanted to arrive where I could determine the flow or streams the Lahars would follow and what schools, cities and the amount of population that would be at risk. The below map shows that, in the event that Mt Hood erupts, a number of schools and cities would be in danger. Also a large population, 58, 260 people, would also be in the path or near enough the Lahars to be at risk.

Sunday, May 24, 2015

Python Fundamentals

In this Module for GIS 5103 (GIS Programming) we began to learn the fundamentals of Python. I learned about using Functions, many that are built into Python (e.g. dir(__builtins__)  - this gives you a list of builtin Python functions). For this lab, I used the functions:

                                                        len: This function counts the length of a string
                                                        *  : This is the multiplication function

And I used the Method, Split: This splits apart a string as in, lastNameList.split(" "). Where, lastNameList is the Object; split is the Method and (" ") is the argument.
Here is a brief description of what I did for this lab:
1.       In order to calculate the length of my last name, I had to define my last name:
o   listName=stringName.split and then, print listName[-1] (this will print the last name).
2.       Then, I had to determine which function I should use to count the length of my last name.
3.       I researched the available functions online and found “len.”
o   len(object) -> integer
Return the number of items of a sequence or mapping.
4.       I followed the syntax of: function(object).

5.       My code for this process was: len(lastNameLen)  

Monday, May 18, 2015

Python Adventure - GIS5103 Programming

I am happy to begin GIS5103 Programming, so I can learn more about Python, scripting and coding. In Module 1 we are just beginning to learn about the various Editors available for Python. We will be using PythonWin, but I have used Notepad and other Editors previously. Our first exercise was to Create Module Folders using a Python script. The main steps I took to Run this script were:

1.      After opening Pyhthon 2.7, Start > All Programs > ArcGIS > Python 2.7 > PythonWin
I pinned the PythonWin icon to the Taskbar
2.      I copied the from the R-drive, then saved it to my S-drive under My Documents
3.      Using PythonWin, I selected File > New >  Python Script
4.      Then, I opened the in the Script window
   5.      Ensuring that my cursor was in the script window on the script, I selected the “Run” symbol, and executed the script. 

Below is what this script produced:

In this Module I learned the method we will use this semester to study Python and I became more familiar with ArcGIS and Python 2.7.