Why Python is the Future of Web GIS?
- Programming languages in GIS are here to stay
Over the last six months, a broader adoption of programming languages in the GIS industry has taken place. Someone at the Esri DevSummit summed it up perfectly by saying that Esri has embraced multiple programming languages in one single workflow. What does this mean? It means that you can do your work with one or multiple programming languages (or extend it if you prefer a GUI). Of course, you don´t have to do this. I recently received an email from someone asking me about the possibilities of using Python for doing GIS and if it was really necessary to learn it. The answer is no: Python is not a replacement for a GIS, but an extension. And so are R and JavaScript. However, many geospatial jobs require you to build applications and/or master multiple programming languages. It certainly does not hurt to know some simple scripting or have application development skills.
- Python now transcends the scripting/programming dichotomy
My first article on Python for this blog was called “Python programming: a beginners guide”. Someone asked me if using preconfigured tools applied to GIS data made you a programmer. Fairly, I don´t think so. Using a buffer tool in arcpy doesn´t make you a programmer, but if you use such a tool inside a larger application script, this qualifies as writing an application instead of a script. And creating applications is what programming is all about. However, with regards to Python as a language, the distinction between scripting and programming may not always be very clear.
What is interesting though is that over the last six months, I´ve been starting using Python tools that surpass desktop GIS (and therefore the scripting/programming dichotomy). Especially Esri´s Python API combined with Jupyter Notebooks has been a great new tool that is much more than a series of preconfigured GIS tools and offers a great introduction to Esri´s concept of web GIS, whether that´s ArcGIS Online or Portal for ArcGIS. Which brings me to the next point:
- Python is great for system operations, data management, analysis and visualization
What I mean by this is that you can use Python as you would use Window´s File Explorer to manage data, load it, process it and visualize it as you want. After working with Jupyter Notebooks, which let you do all these operations through a browser, I asked myself the question if these were the new IDEs for writing scripts and applications. Jupyter Notebooks offer impressive capabilities that surpass those of IDEs, mainly because they integrate code with visuals, such as graphs and, in the case of Esri´s Python API, 2D and 3D maps. They´re great for organizing and testing code in small chunks and have the results returned instantly, literally on the same page as where you write the code. This is not possible with an IDE, that returns code results in a shell and cannot be deleted unless you restart the IDE. (That being said, I don´t think Jupyter Notebooks will replace Python IDEs as they don´t allow you to create complex applications.)
- GIS has embraced Python 3
One major difference between arcpy for ArcMap and arcpy for ArcGIS Pro is the Python version used in the background. Most discussions about the differences between the two ignore the fact that Python 3 is really a redesign of certain parts of the language, which is why it has a different version number and is considered a major upgrade. This explains why a site package as arcpy for ArcMap (that uses Python 2.7) has such idiosyncratic commands and tools, while the new Python API for ArcGIS is structured and reads more like pure Python, making it more accessible for Python developers new to GIS to use and learn it. This may help Esri to attract more non-GIS developers to using their platform and tools.
- GIS has embraced Anaconda
Let´s face it, version control and package management with Python is a challenge. Having an application that does this for you makes your life easier– and this is what Anaconda does. It also provides you with the Jupyter Notebook app that was mentioned before. While at first I was suspicious about its usefulness, I now prefer Anaconda to using virtualenv whenever using Python 3. It also works fine if you have Python 2.7 installed, which comes with ArcMap (the trick is not to add Anaconda to you PythonPath as not to mix up both environments on the same machine). Esri also realized it would be more convenient to offer arcpy through Anaconda rather than shipping it directly with ArcMap or Pro. This will be taken care of in upcoming software releases.
- GIS has embraced the SciPy stack
Esri now ships the SciPy stack with each install of ArcMap and Pro so that you don´t have to install the packages yourself. Although the individual packages of this stack are geared towards the scientific community, GIS analysts and cartographers can use them to their advantage, for example by including simple plots from the matplotlib library. If you use pandas and Numpy together, you have a something similar to what the R language offers. Again, Jupyter Notebooks are the perfect environment to write all your code, comments, results and graphs.
Marketing-wise, it´s interesting to see that Esri has adopted the slogan “The Science of Where” to emphasize its scientific roots. The partnership with Continuum Analytics (the company behind Anaconda), shipment of the SciPy stack with ArcGIS and the creation of the ArcGIS bridge for R users are all recent initiatives to bring different communities together through technology.
- GeoPython is an exciting new event for geospatial Python developers
GeoPython is a European Python conference for the geospatial community. Here, new projects from the open source community, as well as proprietary vendors, are shared. If you didn´t visit the event, you might be interested in the Github repository that shows all projects that were presented at the last edition, earlier this year in May.
- Open source extends proprietary GIS and vice versa
This is mainly a repetition of the last two points, but there´s more: there are many open source tools that extend commercial GIS. Many of these are distributed through the PyPI Python Package Index, although Github is taking its place slowly. You will be amazed by the amount of search results when you search for “GIS”, “Geo”, or “esri”. An open source package called ArcREST offers a set of python tools to assist working with ArcGIS REST API for ArcGIS Server (AGS), ArcGIS Online (AGOL), and ArcGIS WebMap JSON. In addition, if you use Anaconda as a package manager, you can search for packages by using Anaconda cloud or browse through the 1000+ default packages that come with its installation.
- Python enables Web GIS
Although desktop GIS will not disappear anytime soon, web GIS is the wave of the future. Python is a great tool for creating workflows using Web GIS, which is another reason to start learning it. Instead of relying on desktop applications, you can reproduce much of its functionality outside such an application, for example by using a Jupyter Notebook and take the functionality, data and tools you need by using web APIs, create your own workflows and share these with others. Python can be used as the language that ties all of this together and the possibilities are endless.