Monday, May 28, 2018

Module 2: Python Fundamentals Part 1

This week we were exposed to some of Python's different data types (strings, numbers, and lists), performed basic math operations in Python, identified the basic functions of variables, strings, and lists, distinguished between Python statements (an instruction that tells the computer to do something) and expressions (a value), Python functions and Python methods.  Python functions (like length, type or range) are typically formatted function(parameters or arguments) and returns a value.  Python methods (similar to python functions only closely coupled with an object) are generally formatted object.method(arguments).

In lab this week we practiced some of the basic, fundamental features of Python scripting. We learned to assign different types of variables, such as strings, lists, integers, and floating-point numbers. We manipulated those variables, or creating interaction between them,

The lab assignment, to write the following script: started with assigning a variable to my name as a string,  then to split the string for my last name, print my last name, find the length of my last name, and multiply the length by 3.   After writing the script to run the script (seen above).

Friday, May 18, 2018

GIS Programing:


So here we go... Week 1 GIS Programming.  The focus this class will be Python programming language, as this became the preferred programming language for use in ESRI's ArcGIS in 2010 with version 10.0.  "Pseudocode is a language very close to English that allows us to represent a program concisely" per Agarwal reading.  Pseudocode can be represented in the format of Start-Input-Goal- Tasks-End (review/evaluate/repeat) or could be flowchart format. 

IDE stands for integrated development environment and is used as a script editor. There are several IDE that work with Python.  This week I accessed three.  IDLE is what ships with some Python 2.7 version.  When launched (start button- ArcGIS-Python 2.7-IDLE) The interactive window Python Shell opens.  When you type a line of code and press ENTER, that line is interpreted and run immediately.  PythonWin is another script editor (one way to launch PythonWin start button-ArcGIS-Python-PythonWin).  The interactive window opens by default.  Code can be written and run in this environment but not saved.  Typically the interactive window is used as a tool, kept open, while write script in a script window, that allows you to save.  To open a script window on the pythonwin menu bar click file-new, in the dialog box highlight python script and click ok.  With the script window activated the script can be saved (file-save as-name.py) In the script window you can write code but it does not automatically run when you hit enter.  This allows you to write multiple lines and when you decide to run the script you can either click the run button, or file-run from the menu bar, or CTRL+R.  This brings the run script dialog box.  A third access to python is in ArcGIS (starting with version 10) python window button on the tool bar.  The python window button opens a window with a python interpreter on the left and help on the right. 

I work on windows 10 at home (new this year to me).  When I access the GIS desktop from Argoapps and click on the start button there is not a complete list of my programs, there is also not an all programs option.  This was new to me since, when I am not in this environment, the start button from my laptop does provide a list of programs and an all programs option.  I called the UWF help desk and when the technician remoted in he noticed at once that this is normal for Windows 10.  Once you click the start button you start typing the program you are looking for and it pulls it up.  So for this lab once I started typing “pyth” I was able to see the options for PythonWin and Python IDLE.

This week I accessed python 3 ways.  I experimented writing the same line of code:  print "Hello World" in each environment.  I ran a script provided in the lab that set up the folders in my student drive that I would be using this semester for this class.  The picture above is of those folders created by the provided script.  Week 1, check!

Saturday, May 5, 2018

Final Project Computer Cartography

This was the most coordination of principles yet.  The assignment was to either take information provided to map academic test scores or to create your own project.  I chose to create my own project and answer my brother n law's question from March "which state Kansas or Missouri has more wheat".  It was challenging to find data on my own (usually provided or hints to locations of data).  The state and county shape files were downloaded from the US Census web site.  The was later projected to Albers Continental US to maintain area in the projection.  The wheat data was obtained from US Department of Agriculture Statistical Service.  I first limited the state shapefiles in the attribute table to the states I was mapping.  The intersected the limited layers with the county file.  I created a choropleth map from the harvest data from 2007 and a dot density layer for the planting for the same year.  I changed the dot to a diamond shape as it resembled the top of wheat.  I did an insert map to show the location of Kansas and Missouri in relation to the continental US.  The choropleth for the Missouri side was limited to 5 classifications where the Kansas layer matched Missouri's 5 and added 3 to show the significant abundance of wheat in Kansas.  A simple table was inserted to show the value of wheat from 2012 to 2017.  I elected to reproduce the wheat data in a separate spreadsheet as the downloaded data seemed to contain some links that caused issues (limited data showing back up later) in ArcMap.  The Kansas data contained planting data for all counties that provided harvest data.  However Missouri data had more counties that had harvest data than counties that provided planting data.  The missing planting data seemed to be conglomerated under an "other" category.  The "other" planting was calculated out to the missing counties based on a percentage of those counties harvest data.  The harvest data was standardized by area before mapping.

Just to get to this stage of the project took much longer than I anticipated.  Data had to be down loaded multiple times due to to technical glitches (layers took a long time to down load, would finally be available in the file explorer on my computer but would not show up in the file explorer in ArcGIS through argoaps for a day (apparently more for the water files I tried to download), and then if the download was corrupt it would not load the file in ArcMap.  I would get into mapping and run across another issue and have to back up to find a solution (choropleth symbolization when applied would make the counties in the state shatter all over the work space, I had to back up and project the layers to stop the problem, or the wheat data that I had limited by deleting what I did not need would all of a sudden have all the rows I had deleted back in the attribute table - finally my solution was to reproduce the data in a new spreadsheet).  Each step taking more work and more research to figure out what I forgot or what I had done incorrectly.

Once I transfered from ArcMap to Adobe Illustrator to add citations and finalize layout I realized it would have been good to have a surface water layer, maybe main streets and possibly a background for the main data frame that had the state outlines for them to be labeled for additional orientation.  I again backed up to try to find these layers to add.  I still have not been successful getting any of the water layers that I have downloaded to load in ArcMap.  I discontinued looking for the roads layer as I felt that that layer would block some of the data and not be all that helpful.  The state background layer I already had but to get it to transfer at the same scale as what I already had in Adobe Illustrator proved too time consuming .  Had I started with all of these layers already in ArcMap before moving to Adobe Illustrator I would have had more luck.

Over all I am pleased with all the information that I was able to obtain and coordinate together, while learning lots of lessons about timing and data correlation and transition from one program to another.