Automation with Python: the only snake welcome in our office

Learning Python may seem like a bit of a steep learning curve to those of us not familiar with programming languages, but it’s become the go-to timesaver for the Onward Spatial Services team. Spatial analyst and environmental project manager Melania Massingham shares her learnings about the only snake welcome in our offices.

If you have a repetitive process in your operating environment, it could be ripe for automation. Part of a spatial analyst’s role involves interpreting geographic information system (GIS) data and applying it to reports such as due diligence desktop assessments. This process typically involves the repetitive method: read GIS data and manually input into a report.

Introducing Python

This kind of process is perfect for a computer language called Python. Python is a popular programming language especially useful for data management. The advantage with this programming language is the plethora of pre-written code for specific tasks called libraries. The Python libraries I’ve found to be especially relevant to our work are Arcpy, pandas and python-docx.

Arcpy reads, analyses or creates geospatial data, pandas manipulates data (especially tabular data), while python-docx aids with manipulation of Word documents. The use of these libraries allow us to populate a Word report with the relevant GIS data, all with a click of a button (Figure 1).

This allows us to focus on maintaining the GIS project as our point of truth, therefore reducing double handling of data.

We can even combine drone-derived spatial data with Python-based automation to improve our efficiency, reduce manual processing, and deliver high-quality outputs faster.

Using large language models to create skeleton code

Large language models (LLMs) or artificial intelligence platforms like ChatGPT can be an invaluable tool to generate the ‘skeleton code’ to kick-start a scripting project. A skeleton code defines the overall structure and key components of a script and allows us to flesh out the code into something more useful.

If the script is not working as intended, ChatGPT is also super helpful with debugging. Note when debugging code, do not cut and paste your specific code into ChatGPT; refer to the skeleton code ChatGPT provided you and prompt the AI to find what could be the issue. Be specific in your prompts - refer to the issue you found, and most times ChatGPT will correctly amend the skeleton code to remove the issue.

Note we don’t recommend sharing data with public LLMs. You only want to prompt the LLM to give you skeleton code to work with within your local environment i.e. an environment that is controlled and you know data cannot be shared with external sources.

LLMs use statistical analysis to determine the most likely answer to a prompt, so while using LLMs allow us coding hobbyists to stand on the shoulders of giants, maintaining the safety of our clients’ data is critical.

Reflections

Learning Python has proven a huge timesaver in the work of our spatial services team. While it can be daunting at first, it is quite an intuitive language, and with the help of LLMs, programming with Python is more accessible to us than you might think.

I would encourage those curious enough to try it out; you may be pleasantly surprised at how addictive it can be!

A computer screen displaying code

Figure 1

Next
Next

Why we should care about assessing cumulative impacts on major projects