Get Started with Python in ArcGIS Pro
In this course I learned how to write code to determine the number of features for all the feature classes in a workspace. This course also introduced some of the basics of Python syntax as I wrote code into the Python window in ArcGIS Pro.
In order to begin this project I had to download data from ESRI’s website. I really enjoyed this course and chose to do it because of the downloadable data that I could use as I followed along, unlike the book which did not provide downloadable datasets for it’s walkthroughs.
The course provided a few shapefiles to work out of, but for this exercise I used the Ambulances.shp.
First, I ran a tool using Python. In Arc there are many ways and routes to complete one task. This task was to find the count of the items in the shapefile. You can do this in the attribute table or by using the Get Count tool in the Toolbox. You can also find the count by running a script in the Python window.
To do this you take go to the toolbox history > right click the Get Count tool > Send to Python Window. After sending the window, I manually entered “Ambulances” since that’s the shapefile I want to be working out of. The script looked like this:
After completing this task, I learned that when completing a script in the Python window, the history is updated to include the task.
The next task that I practiced was inputing an assignment statement.
y = 73
x = 37
x * y
Then, after pressing enter, the Python window answered with 2701
Next, I did a similar thing but with Temperature.
temp_c = 17
temp_f = temp_c * 9 / 5 + 32
The Python window responded with 62.6
The next assignment was learning how to use the Python window as a tool to help you when writing code. You can do this by hovering over the prompt and reading the information that the window provides.
There is also a system of code completion. For example, if you want the “Get Count” tool, you can typer “Get” in the Python Window and suggestions will pop up to help you finish the prompt easier.
I really enjoyed this tutorial. I thought that it was very easy to follow and was helpful. I see myself using more of ESRI’s resources in the future if or when needed when writing scripts. I think that if any student was interested in this course in the future these tutorials would be a better resource than the book we used.
I had some screen shots from this assignment but they did not get added into the blog format. If you would like me to send those over to you. let me know.