Tuesday, May 28, 2024

GIS 5103 Module 2 - Python Fundamentals

 


Module 2 of GIS Programming was an opportunity to dive deeper into the fundamentals of Python script coding. We were introduced into the different object / data types, syntax, functions, methods, loops, and conditions. While I am no where near a Python expert, I am one hundred times more comfortable typing small scripts in IDLE and ArcGIS Pro. 

The assignment for this module was broken down into four parts, and then compiling those four parts into one Python script; the result of the script can be seen in the image above. 

The first part of the script was creating a string data type that consisted of our entire name, using the split method to divide our full name into its individual names, and to use indexing to print ONLY our last name to the output. This can be seen in the first line of the output [blue lettering]. This part of the assignment was very easy and did not present any issues.

The second part of the assignment was to troubleshoot a block of code that was provided. Essentially, the code is a dice game that takes a list of players, and each player tries to score higher than the number of letters in their name. For example, if a player's name is made up of four letters, they have to score a five to win, a four to tie, and anything lower than four is a loss. The errors found within this code were simple syntax errors that were easy to fix. The first issue was to import the random module, the second was concatenating an integer with a string data type [the solution is to temporarily convert the integer into a string], and the third was a case-sensitive typographical error. Once these errors were corrected, the game was run effortlessly. The results of the game can be viewed on lines two through seventeen of the output [blue lettering].

The third part of this assignment was to generate a list of twenty random numbers that lie within a range of zero to ten. This was accomplished by creating an empty list, generating random integers, and using the append method to add these random integers to the list. Also, a counter variable was defined that counted up by one each time an integer was added to the list. Once the counter equaled twenty, the loop was stopped by executing the break command. The result of this part of the script can be seen in the eighteenth line of the output above.

Finally, we were tasked with creating our own script that chose an 'unlucky' number and deleted it from the list created in step three. A conditional if statement was used to print a statement to the output; if the unlucky number was present, a message appears that states "Unlucky number [x] will be removed [y] number of times from the list." If the unlucky number was not present, a message appears that states "Unlucky number [x] did not appear in the list." Lastly, the remove method was executed to delete all instances of the unlucky number from the randomly generated list. The result can be viewed in the last two lines of the output. 

I am extremely pleased with the outcome of this script, and I look forward to expanding my knowledge base of this programming language.

Tuesday, May 21, 2024

GIS 5103 Module 1 - Intro to Python / Flowcharting


 Module 1 of GIS Programming was an introduction to the Python scripting language, which we will be utilizing this semester to automate geoprocessing tasks to make the workflow more efficient. The exercise and lab assignment for this module focused on opening the Integrated Development Environments [or IDE's], familiarizing ourselves with the interface, writing a couple one-line scripts, and importing / running a script that was written by another person. I was able to follow this code line-by-line with a moderate understanding of what was taking place, but the syntax of this language is completely new to me. Ultimately, the script created a file system on our personal S: drive for our files / data to be saved to throughout the remainder of the semester. It was really neat to just run a program that created all of these folders instantaneously. Manually, this process would have taken at least a few minutes opposed to the second it took to run the script. This was an excellent illustration of how Python scripts can be used to automate redundant and time-intensive tasks. 

The second half of this module's lab assignment was to create a flowchart of a script that would convert [3] radians to degrees and print the output. We did not actually write the code, but the process we would undertake if we were to write it in Python. Essentially, we used conventional symbology to begin / end the script [ovals are used for termination processes], define the variables such as radians [3] and Pi [3.14159] [rectangles are used for assignment and computational processes], print the output of the calculation [parallelograms are used for input / output processes], and terminate the script [oval shape again]. The flowchart for this script can be viewed in the picture above. 

I am highly excited to dive deeper into the Python programming language and use it to create a more efficient and streamlined workflow in ArcGIS. 

Thursday, May 2, 2024

GIS 5007 Module 7 - Google Earth

 


The final Module of GIS 5007L was an exercise that solely focused on Google Earth. Using ArcGIS Pro, we imported the data provided for this exercise and converted it into a KML [Keyhole Markup Language] file; this file type is mainly used in Google Earth to create interactive 3D maps. I use these functions almost daily at work because most of our clients do not utilize the same GIS software that our company does, and KML files can be viewed on any computer with Google Earth Pro installed [this program can be downloaded for free here].

As shown in the screenshot above, we created a dot density map of southern Florida that also featured some polygonal layers that illustrated the locations of many large lakes, marshes / swamps, and streams throughout the southern half of the state. The legend was provided as a JPG file, so I imported this image into ArcGIS prior to the KML conversion, and utilized the eyedropper tool to match the colors of the polygons to the colors in the legend perfectly. 

After the KML file was created, we added the legend to the screen so the map viewer can see it through the Google Earth interface. Per the lab instructions, we were to insert the legend as a graphic overlay; this essentially assigns it a geographic location and forms it against the surface of the Earth, causing some distortion within the legend. One of the student leaders offered some excellent advice on how to insert the legend as a screen overlay, which places it at a particular location on the screen [as opposed to a geographical location]. This gave the legend its original appearance and did not cause any distortion; I was very pleased with the outcome. 

The second half of the exercise was creating a 3D tour of southern Florida. In my tour, I begin with a global shot of Earth's western hemisphere and then it zooms into the southern Florida region, bringing up the layers of the KML created in the first half of the lab. Then, it zooms in further to the Miami metropolitan area, displaying Jupiter, Florida all the way south to Homestead, Florida. After this shot, the camera zooms into a 3D view of downtown Miami, and the layers / legend are removed from the screen. There is an orbit around the Miami central business district and then the camera flies over to Ft. Lauderdale, followed by an orbit of the central business district of this city. Next, the computer zooms back out to satellite view over the Tampa Bay metropolitan district [Layers / legend are turned on for this shot]. The camera then zooms back in to 3D view and orbits around Tampa Bay and then St. Petersburg before zooming back out to the entire southern Florida shot again. Finally, the computer zooms all the way back out to the original view of the global western hemisphere that began this 3D tour. Anyone that has Google Earth Pro installed on their computer can download and view the tour by clicking the link below; once the KML is loaded, just double click the '3d Tour' link in the pane on the left side of the screen [Make sure the 3D Buildings layer is turned on].


This lab assignment presented no major obstacles but was an enjoyable way to end this semester and a great opportunity to explore the capabilities of Google Earth that I do not get to utilize often. 

GIS 5935 Module 2.2 - Surface Interpolation

  Post in progress - please check back soon...