Wednesday, May 28, 2025

Module 2 - Python Fundamentals

 

Results of the Module 2 Script
Results of the Module 2 Script. 
 
Flowchart for Creation of the Module 2 Script


GIS programming has proven to be the utmost challenge yet! We are here to rise to the challenge. This week introduced us to GIS basics, from syntax to while and for loops; we dove in deep. 

The initial steps of the assignment were fairly intuitive; it was not until step 3 that the fun really began. A description of my processes for steps 3 and 4 is seen below. 

Step 3: Create a loop that adds 20 random numbers between zero (0) and ten (10) to a list

 

The first step was to import the random module because the instructions specifically asked for a random number. **Like rolling dice.

Assign the lucky list to be empty so that it can be filled in later.

Next is the while loop-

Set counter as indicated, start at zero,

We used the append function because that would instruct us to add the numbers to the empty luckyList. 

We set the while i < 20 because this is how many iterations we want until the loop equals false and stops

Then we used the append method to add the random integers, from ranges 0-10, to the empty list.

We really did not need to, but the instructions asked us to, so we included an if and break statement that would prevent the list from going further than 20 iterations.

 

Then we hit print luckyList so that we could print out a list as requested.

 

***Using a for loop would have been a better, more concise option.

 

Step 4: Create a loop that removes an unlucky number from the list generated in step 3.

 

For this step, I began by copying luckyList, generated in step 3, into the cell.

Then an integer is assigned to the variable x.

Created an if statement where if it was not equal to x, it would say that it was not in the loop. However, if it were, the else statement could invoke the count method to count how many times that integer occurred in the list

Then, creating a print statement that mentioned how many times a specific number was to be removed was rather confusing, and I had to do some external research. I first had to write out the statement with parentheses and variables within, for example, (x) and (count). I had to write a count assignment statement just like I did for x.

Finally, the creation of the while loop using the remove method was used to remove the unlucky variable x from the previously generated list.  I struggled with the creation of this loop because I did not write the remove method on the same line that mentioned the lucky list. Therefore, every time I tried to print the while loop, an error would appear saying that x did not appear in the list.

Finally, the updated luckyList with no variable x was printed.

 

Saturday, May 17, 2025

Module 1 - Flowcharts and IDLE

ssfjksbsAnswer:171.89 Degrees

 Figure 1. Flowchart depicting Conversion of Radians to Degrees


 

   Process Summary

Part 1: Using a Python Script to Organize the S Drive Folders.

 In the Intro to GIS course, a crucial step was to organize our digital folders and filepaths; this was typically a manual, zip, copy, and paste operation. Over time, it became second nature. However, in this course, we were introduced to the concept of automatically copying folders from the repository into our S drive using a premade script that was copied and executed into IDLE. This will make the digital fordel organization endeavors efficient and straightforward.  

Steps-

Identified the GIS Programming folder in the repository.

Copied the corresponding script to the S drive root.

Opened Windows icon on the left-hand corner and typed in “python command prompt”.

 Clicked open

Typed in IDLE at the end of the prompt to launch the interactive environment

Clicked on new file, opened at the top left-hand corner, then navigated to the S drive and clicked on the pre-written script.

Clicked on the “run” at the top of the IDLE environment- Confirmed execution.

To verify, open the S drive and find the GISProgramming folder and all its corresponding modules in the drive.

 

Other Thoughts-

            This was challenging as the Intro to GIS class drilled into me the zip file, copy and paste technique to organize folders.

 

I ran the script a few times before I finally succeeded. What caused issues was that I was not sure “what root of your S:\ drive.” was. Then I realized it was literally just copy and paste into the S drive. Then, I had forgotten that I had to click “run” at the top of the IDLE for the script to run. These were all silly simple mistakes. This method of copying the folder from the R drive is such a time saver. I look forward to using this again.

 

Over all, opening python, opening IDLE, ect all seems to be very straightforward and almost naturally intuitive.

 

Part 2: Flowcharting: Convert 3 radians to degrees

                        Steps

                        Establish Formula: degrees = radians*180/pi

Write Pseudocode: Remember indentation, starts, stops, and which steps are dependent on others. **Remember to write the 3 as 3.0

 

#This program converts radians to degrees

Start

Radians = 3.0

pi = 3.14159

Degrees = radians * 180 / pi

Print Degrees

End

 

                      Manually check calculation is correct.

                                    Use pseudocode to create a flowchart.

Open app.diagram.net

                                    Use Standardized symbols snip from the Python Scripting for ARCGIS pro as                                        reference.

                                    Save and export flowchart as png file  

 

 

Other Notes

 

I was beginning to think about the term’s “script” and “source code” as interchangeable, but they are not. I had to do a little side quest to find the difference.


Source Code- Written in programing language. Compiled.

Script- sort of like a stepchild to the program code. Interpreted, not compiled.

 

Useful Websites for more information on GIS Notebooks and IDLE

https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/pro-notebooks.htm

https://gis.stackexchange.com/questions/225585/differences-between-python-window-and-idle-for-scripting-with-arcgis-desktop

            **Feedback from the GIS community.

 

Overall, the most difficult task during this lab was deconstructing the individual processes that we all know, such as a simple equation, into individual steps that make sense, are sequential, all while following standard symbols. 


 Zen of Python

The first thought that comes to mind is that “The Zen of Python” is not about Python at all but rather a deep insight into the soul; but of course, it can’t be, or can it?

Despite my eagerness to dig deeper into the connotation of this text, I believe the author is trying to convey that…

A)    Python is straightforward.

B)     The process should not be incredibly complex.

C) Be sure to take the time to revise and weed out errors.

D)    To not worry, if you’re persistent, you will find a solution to the pickle you find yourself in.

Additionally, lines 3 to 7 might refer to the imputed code's structure; it should not be dense, simple, straight to the point, neat, etc.

There are several lines, specifically towards the end of the passage, that nod to the idea of “don’t overcomplicate it, the solution should be simple and odds are that this is not the first time it happens”.

This is in theme with the whole branding of Python; an easy-to-use and learn, fast, efficient technology that is here to make daunting tasks better.

 Ultimately, the reader is encouraged to find solace in the fact that the world of Python is only as difficult as they make it. These are my first thoughts, might also be completely wrong, but I digress.

Overall, a very interesting passage. I have come to realize that the tech community has a lot more fun with their naming conventions, and now also writing passages, than I had previously thought. 


Module 5- Exploring and Manipulating Data

Figures 1-4: Creating a File geodatabase and copying data into it. Flow chart denoting the cradle to grave process of creating a file geodat...