Saturday, August 5, 2017

Module 11: Sharing Tools


Programming was completely new to me when I started this course. As a whole, python programming is a very challenging subject and it still takes me awhile to grasp some of the concepts of programming.  I feel that after this course that I will need a lot more practice and I will most likely take other programming courses, if needed for my future career, in order to better myself in this subject. I enjoyed learning what each code’s purpose was in the script and I always enjoyed seeing the final product of every module. 

Below are a few topics I learned this semester:
·       Worked with variables, strings, lists, functions, methods

·       How to write conditional statements

·       Use loop structures (If/Then, While)

·       Correct script errors

·       How to implement debugging procedures

·       Create a new toolbox and model

·       Geo-processing with Python

·       Work with Search Cursors
 Even though I struggled a lot in this course I am still content with the fact that I made it through and completed all of the assignments to the best of my ability.



Module 11 involves preparing files for sharing tools and creating the tool documentation.
I completed this module by completing the following steps:
1) Downloading and renaming my toolbox, script tool, and Python script.
2) Examining the script tool's properties and dialog window.
      -Making sure the proper sys.argv[] number value is correct based on the parameters in the dialog window.
3) Opening the tool and setting the instructed parameters.
4) Editing the tool after successful run through the Item Description and adding Dialog Explanation
5) Importing Script
6) Creating a password to protect script


I input information for the following parameters: Input boundary feature, Number of sample sites, Minimum distance between points, Buffer distance, Distance units, and Output file location. Below is the screenshot of my tool dialog window in ArcMap and the window showing it's successful completion.



By setting the parameters shown in the image above, I successfully gained the final result for this module. Below is the screenshot of the output features in ArcMap.



Monday, July 31, 2017

Module 10: Creating Custom Tools

Module 10 focused on creating custom tools by using ArcMap and PythonWin. This week was pretty much straightforward with a few minor exceptions (such as forgetting to change print statements to arcpy.AddMessage() statement and accepting the error I get since the final result runs successfully in ArcMap).

I completed this task by following these basic steps to turning a stand-alone script into a script tool:



1.       Created a toolbox in ArcMap for the stand-alone script to go in.
2.       Change the parameters to the tool and set the appropriate properties (ex: Input file location, Clip boundary feature, etc.).
3.       In PythonWin, edit the values of the variables and change the filepaths/filenames with Get Parameter function.
4.       Add the str() function
5.       Replace print with arcpy.AddMessage() statements (will print successfully in ArcMap).
6.       Toolbox and Script saved to a zipped folder for sharing.

Below is my Part 2 screenshot after parameters are set.
Below is my Part 3 screenshot of my results which have been ran successfully through ArcMap.

Looking forward to only working on one more module for this course!

Tuesday, July 25, 2017

Module 9: Working with Rasters




This week I used raster objects in geoprocessing, map algebra in operators, and work with classes to define raster tool parameters. Module 9 focused on the rasters 'elevation' and 'landcover' data to help create the final raster result. There were minor errors to fix in order to get my result, so that was a relief.

I completed this task by completing the following steps:

import arcpy
from arcpy import env
from arcpy.sa import *
env.overwriteOutput = True
env.workspace = "S:/.."

if  statement

arcpy.CheckExtension
arcpy.sa.Reclassify
arcpy.sa.Raster
arcpy.sa.Slope
arcpy.sa.Aspect

elev slope < 20
elev slope > 5
elevaspect < 270
elevaspect > 150

Combine all 5 temp rasters
.save() method

else statement

Monday, July 24, 2017

Peer-review Assignment#2


Below is the link to the article, article summary/critique, and citation.
https://www.researchgate.net/publication/220274811_Marine_Geospatial_Ecology_Tools_An_integrated_framework_for_ecological_geoprocessing_with_ArcGIS_Python_R_MATLAB_and_C

Once you get into the website click on "Download full-text PDF".




Marine Geospatial Ecology Tools: An integrated framework for ecological geoprocessing with ArcGIS, Python, R, MATLAB, and C++
Marine Ecologists are in need of keeping up with the rapid advancement in technology and software used to manipulate and analyze data.  The Duke University Marine Geospatial Ecology Laboratory created an ‘easy-to-use’ software to better prepare marine ecologists with the skills needed to keep up with these continuously growing software’s. This software is called Marine Geospatial Ecology Tools (MGET) and consists of many tools. The tools included within the MGET program are the following: ArcGIS, Python, R, MATLAB, and C++. To test the accuracy of the study they focused on ecologists and analysts with moderate knowledge in geographic information systems (GIS) and minimal knowledge in computer programming. The creators of MGET have found a way to make it affordable for users by making it free for everyone. I believe making this tool affordable to all is an important factor for the growth of this tool. This paper uses a study of a predictive habitat model as an example of how useful the MGET tool can be. The study involves the Atlantic spotted dolphin (Stenella frontalis) and predicting the presence of this dolphin. The MDET tool created a statistical model and used oceanographic predictor in order to make this prediction.
I really enjoyed reading about the Marine Geospatial Ecology Tools created by the Duke University Marine Geospatial Ecology Laboratory. This caught my interest since it would be a useful tool to use at my Environmental Protection county internship, where these programs are often used for the water samples collected within my county. Python was used as the main language for the development of the MGET tool which is also what caught my attention when reading this article, since we are taking a Python programming course. ArcGIS and Python are being used more frequently for environmental science data entry which is in my field of study. I thought this paper was very interesting to me because a university took the time to create a tool to help better scientists with the lack of knowledge in ArcGIS, Python, R, MATLAB, and C++. Understanding how to use these software’s is becoming an important skill to acquire for environmental science fields.

Works Cited
Roberts, J.J.,  Best, B.D., Dunn, D.C., Treml, E.A., & Halpin, P.N. (2010). Marine Geospatial Ecology Tools: An integrated framework for ecological geoprocessing with ArcGIS, Python, R, MATLAB, and C++. Environmental Modelling & Software, 25. 1197-1207

Wednesday, July 19, 2017

Module 8: Working with Geometrics

This week we worked with geometries in python. This was by the far the most difficult module to complete. After some guidance I was able to complete the following tasks:

1) Importing all modules
2) Enabling overwriteOutput
3) Setting the workspace
4) Creating a Search Cursor(OID, SHAPE, NAME)
5) Create (open) .txt file and enable write mode
6) Create for loop to itterate row/feature in shapefile's attribute table
7) Create variable for vertex ID
8) Create another for loop to iterate point in the array for feature/row
-add .getPart() method to access points/vertices in each array
9) Close the text file, delete the row and cursor variable outside of loop

Below is the image of a part of my result in the .txt file I created:


This is my pseudocode:



Start
    import modules
    overwriteOutput
    set workspace

    Variable = fc = "rivers.shp"
    Set variables: "OID@", "NAME", “SHAPE”
    Set outpath to txt: “rivers_edelatorre.txt”

    Search Cursor to retrieve: "OID@", "NAME", “SHAPE” full geometry object
    Create (open) writable text file "rivers_edelatorre.txt" in S:\GISProgramming\Module7\Data

    begin for loop for row in cursor:
                set index vertexID equal to zero
                for loop for point in row with .getPart function
                        add +=1 to vertexID
                        write to text file row's OID, Vertex ID, X coordinate, Y coordinate, and name
                        print OID, Vertex ID, X coordinate, Y coordinate, and name
  close text
  delete cursor
  delete row

End