Showing posts with label GIS Programming. Show all posts
Showing posts with label GIS Programming. Show all posts

Monday, August 5, 2013

GIS Programming, Lab 11: Sharing Tools

Screen shot of the tool dialog box and resulting map in ArcMap 

This week we learned how to share custom tools.  We were given a script where we needed to make a few edits.  Once those edits were done, the script was embedded into the script tool.  This was done because it makes it easier to share.  We also learned how to password protect the tool.  The above screen shot is of the tool dialog box and the resulting map in ArcMap.

This was our last lab and I am grateful.  This course was definitely challenging but I did learn a lot.  Overall, it was a good experience and I can see how I can take away a lot from it and use in the GIS work industry.    

Wednesday, July 17, 2013

GIS Programming, Lab 9: Debugging and Error Handling

This week we worked on debugging and handling errors that I (tirelessly) encounter.  This lab was super helpful and I almost wish it came earlier in the semester.  

We were provided with two script templates which were littered with (okay, maybe not littered but had several) errors.  These errors were both syntax errors and and exceptions.  The first one, we had to fix these issues to allow the script to write the names of all the airports in the airport shape file from week six. 

Screen shot of my list of airports.

In the second script, again, we had to locate and fix errors that we came across while checking, debugging and attempting to run.  Once everything was fixed, the script printed each data frame's name and the layers it contained within the Austin_TX.mxd we worked with last week.

Screenshot of the data frames listed and the layer names they contain.

Overall, a very helpful lab!

GIS Programming, Participation #2

Title: Application of web-GIS approach for climate change study

Summary:

This article is about climate change and how much data and information is required to study it.  Because this is the case, dealing with that much data can be cumbersome and be detrimental to the outcome.  That is why a web-GIS system has been created.  The article states that some of these single datasets can contain up to tens terabyes!  This system was created for “analysis of georeferenced climatological and meteorological data.”  One of the solutions that is included in this system is object-oriented programming, which is essential to analyzing meteorological data.  The enormous benefit of this system is that the output that is created is a basic binary code that can be produced on any regular computer with an Internet connection.  This allows for more opportunities to analyze the data. 

Since this system doesn’t require much from the computer, it is being used in educational purposes as well.  It is a user-friendly system so that even a computer layman can compute and produce complex analyses.  From my experience using large datasets, it can significantly slow down my computer.  I think creating a system like this is a great idea and will be able to take data analysis so much further, not only in the meteorological industry, but many others.

Tuesday, July 16, 2013

GIS Programming, Lab 7: Geometry & Rasters

This week we had to write two scripts.  The first one was to create a text file that would print out the Object ID and coordinates of the vertices of each shape.  In this case, it was a "rivers" shapefile in Hawaii. 


A screenshot of my text file which displays the ObjectID, coordinates and name of the river/stream.

The second script we had to write created a new raster based on specific criteria pulled from an elevation raster and a landcover raster.  In this case, we pulled out specific forested areas.  This script took a lot of time to figure out and used various modules including relcass, slope and raster and used the spatial analyst extension.

Final raster created from taking specific criteria from two other rasters and saving it into a newly created gdb

This week took a lot of patience, trial and error and aid from classmates and the professor.  It was definitely rewarding once I was successful though.

Wednesday, July 3, 2013

GIS Programming, Lab 6: Explore & Manipulate Spatial Data

This week definitely tested my sanity! We had to write a script that created a new file geodatabase, copied all the files from our data folder and pasted them, in correct format, into the new .gdb and then create a blank dictionary and then populate it with the names and population of the cities that are categorized as "County Seats."  The toughest hurdle I had was figuring out how to insert the list variable into the print message.  Of course, it was a simple fix and was the ONE option I did not try.  I also struggled with the searchCursor. 

Screenshot of the results of my script - created new gdb, copied the files and printed the cities/populations.

With the help from the instructors and TA's I was able to figure out the issues I was encountering and move forward.  I have had very little experience with programming in my past and am finding it difficult to grasp, but hopefully in the (near) future, things will start clicking.

Sunday, June 30, 2013

GIS Programming, Lab 5: Geoprocessing with Python

This week in lab, we learned about geoprocessing with Python.  I found this lab to be a little stressful, but very rewarding once I was able to figure it out.  The outline of it was to create a script that would add XY coordinates to the hospitals shapefile, create a 1000 meter buffer around each hospital point and then dissolve the buffer layer.  Below is a screenshot of the Interactive Window using PythonWin once my code was successfully run.



First, I added my comments to the script.  Those included my name, the date, the script name and a brief description of what the end result should turn up.  I imported arcpy and set the environments.  I made sure I was able to run the script more than once using overwriteOutput.  The next step was to use the AddXY tool.  I used the Help section of ArcGIS to look at a sample code and syntax for the AddXY function.  After that, I turned, once again, to the Help section to look at sample code and syntax for the Buffer tool.  Here I needed to write a code that would create a 1000 meter buffer around each hospital point.  Once that was done, I needed to dissolve the buffers together.  Using the ArcGIS Help section, I reviewed sample code and the syntax for the dissolve function.  Finally, I made sure that the comments appeared after each step of code, letting me know it was run successfully.

This lab definitely helped me get a better grasp and understanding of using the tools in Python.

Tuesday, June 11, 2013

GIS Programming, Participation #1

The GIS Institute is a non-profit with many focuses.  One is on reducing, preventing and eliminating plastic waste in our oceans.  This post first outlines the problem and where it is occurring the most.  The epicenter of marine debris is the North Pacific gyre convergence zone, or better known as the “Pacific Garbage Patch (PGP).”  The way the ocean currents run, most marine debris (mostly plastic) is brought to this area and can never leave.  Recently, the PGP has gained national and world attention, along with the need to clean it up.  It is such a massive undertaking but ideas are flying. 

GIS is being introduced in the efforts.  This post outlines how GIS can help.  Once the data is gathered, it can be mapped and analyzed in ArcGIS.  There is so much data and information attached to a collection of marine debris (along with GPS info) that it would need to be organized.  With GIS, maps can be made to organize beach clean ups, create models depicting how it ends up out there, how we can prevent/reduce that, make future projections based on past events (like the 2011 tsunami).  This information can be shared with the public and, perhaps, progress can be made. 

Another aspect in which, GIS is being used in relation to marine conservation, is studying the impact on marine life.  Sea turtles are common victims, but they are easily tracked!  Attaching a tracking device to the shell of a sea turtle provides a wealth of data.  That data can then be analyzed using ArcGIS.  Steps can be taken, lessons can be learned and turtles can be saved!


Source:  Stephens, Drew. “Gyres and Marine Debris.” The GIS Institute; Connecting People, Planet and Geotechnology. WordPress. Blog. May 30, 2013.

Wednesday, June 5, 2013

GIS Programming, Lab 4: Python Fundamentals - Part 2

This weeks lab was a little more difficult.  We focused on modules, conditional statements, loops (for and while) and learned how to leave comments and instructions in a script.  We were given a partial script (with numerous errors) and we had to figure out what was wrong, correct it and then write a loop.

Results of a dice game
The result of the corrected script was a dice game.  It took into account the length of the players names, a random "die roll" and that determined whether the players won, lost or tied.   It ran through all of the players, giving them each a turn.  At the end we had to create a loop that printed the numbers 0-5.

Thursday, May 30, 2013

GIS Programming, Lab 3: Python Fundamentals, Part 1

This week we learned more about the Python language, different functions and different methods that it has to offer.  I learned ways to make writing scripts more accurate and how let Python help you along.  We went more into depth with strings, variables, statements & expressions.



For this weeks lab, we had to write our own script that would eventually result in a number that is triple the length of our last names.  We initially started with our full name.  After writing/running MY script, I came up with 21.  Johnson = 7 letters. 7 x 3 = 21.  Success! The above image is simply the result of running my script in PythonWin.

Thursday, May 23, 2013

GIS Programming, Lab 2: Geoprocessing in ArcGIS



This week we played around with ModelBuilder in ArcMaps, writing scripts using various ArcGIS tools and we created our own toolbox.  It was interesting and fun learning these things.  I can definitely see how they'll be helpful in the future - especially the batch processing!

The above figure is a screen shot of the resulting shapefile that was created by the Model I built.  Using ModelBuilder, I narrowed down the types of soil to those that are "not prime farmland" and then erased those from the basin shapefile.  The result leaves the soils that are prime farmlands.

We also learned how to share toolboxes and what is required in doing so.

Wednesday, May 15, 2013

GIS Programming, Lab 1: Intro to Python


Starting a new semester, my first lab of GIS Programming was a basic introduction to the Python programming language.  It is a more basic and easier to use language than something like C++ or Visual Basic.  It allows users to express code in fewer lines and commands.  Our first experience was using the interface PythonWin.  Opening the previously written script and running the program created folders for this class for the entire semester.  In one quick click - this was created.


As you can see, located in the S: drive, a folder named GISProgramming was created.  Inside that folder, additional folders were created to contain all of the work for the next 12 weeks.  

I have little experience with programming and the experience I did have was not a pleasant one.  I am encouraged, however, that Python is simpler than C++.  I look forward to having a more enjoyable experience with Python and using it in my future GIS career.