The Future of GIS with ChatGPT; will we require humans to write Python Scripts?

Morad Ouasti
5 min readFeb 6, 2023

--

Many Geographical Information System (GIS) professionals lack GIS coding skills while those are becoming a growing important part of GIS. Those like me who have been using traditional GIS tools and who want to be involved in more advanced functionalities and automated geospatial analysis methods require programming skills. I wondered if ChatGPT would be able to help me by producing simple python scripts that I could just paste into a GIS and run. while I know that we are still in the beginning of AI and that we can not ask for complicated programming codes because this would require human intervention to adjust and correct the gaps and inaccuracies in the code.

I want to share with you my experience using ChatGPT for creating and using python scripts in a GIS with no intervention, no editing from me on the code.

I imported a shapefile of the map of Africa in shapefile format and I asked ChatGPT to do an extraction of Senegal and export in shapefile format, using QGIS.

Here are the steps that I went trough;

I first asked Chat GPT to write a python script that will extract Senegal from the map of Africa in shapefile format and export it as a new shapefile, using QGIS.

ChatGPT started generating a python script,

It also provided a note at the end of script with guidelines on replacing the paths with the right ones stored in C drive.

As many of you I am really not an IT development literate and I know that if I miss a point or a comma white editing the script it will affect the whole process, I therefore decided to provide ChatGPT with the actual paths and I asked it to replace them itself. And ChatGPT did it!

As I am not familiar with programming I asked ChatGPT to tell me where I should insert this code and it drove me through the steps.

Then I copied the code and pasted it in the Python console as explained by ChatGPT

And as a result it extracted and created a shapefile of Senegal, it also created another layer of the Map of Africa for a reason I don’t know :-), however this is not important, the most crucial result here is that it extracted and created our shapefile of Senegal without any code writing or editing by a human and just by using python script and guidelines provided by ChatGPT.

I tried this experience a couple of times and sometimes the Python Console would come back with error messages that I would just copy and paste into ChatGPT. The latter would fix the errors and write a new code that would then work and produce the expected result.

Some benefits and drawbacks of using it to get python scripts for GIS

Benefits:

Quick Code Generation: ChatGPT can quickly generate code snippets for common GIS tasks, such as reading, writing and manipulating geospatial data.

Syntax Assistance: ChatGPT can assist with the syntax of GIS-related Python packages, such as ArcPy, Fiona, or PyQGIS, making it easier for users to write scripts.

Knowledge Sharing: ChatGPT can provide answers to GIS-related questions and explain concepts, helping users to understand the code better and make informed decisions.

Time-saving: Using ChatGPT can save time compared to manually writing code or searching through documentation, allowing users to focus on the analysis and interpretation of the data.

Improved Accuracy: ChatGPT can reduce the likelihood of syntax errors, improving the accuracy of the scripts, and the results they produce.

Drawbacks:

Limited Understanding: ChatGPT can provide code snippets, but it does not have a deep understanding of GIS concepts and data. This means that it may not always provide the most appropriate solution to a given problem.

Dependence on Input: ChatGPT’s output is based on the input provided, and it may generate code that is incorrect or inefficient if the input is incorrect or incomplete.

Lack of Context: ChatGPT may not have access to the specific context of a user’s project, meaning that it may not always be able to generate code that is suitable for a particular scenario.

No Debugging Capabilities: ChatGPT cannot debug code and may not be able to identify issues with the generated code, leaving it up to the user to test and troubleshoot any problems.

No Customization: ChatGPT provides generic solutions and does not offer customization options. This means that users may need to modify the generated code to fit their specific needs.

ChatGPT has produced an amazing result, although I asked for a very simple GIS operation that can certainly be accomplished with existing GIS tools. However the purpose was to see if there are some perspectives in the future when AIs like ChatGPT will be more robust and more mature to produce more complicated codes. I believe that it’s already a great achievement while we know that human GIS developers will still be needed in the future. Who knows how ChatGPT and other AIs will evolve and how they will be capable of solving some of our problems.

To view the video click here.

I encourage you to do your own experience of using ChatGPT for GIS and to share it with the GIS community.

--

--