Why Python is the Future of Web GIS?
- Programming languages in GIS are here to stay
- 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.
Do you know how maps of Game of Thrones were created?
Jonathan Roberts was only 31 when he received the fateful email in early 2012. It came from Random House, the publisher of the Song of Ice and Fire epic fantasy saga that the blockbuster TV series Games of Thrones is based on. They wanted to know if he would be interested in doing the artwork for the official Game of Thrones map collection that author George R. R. Martin wanted in his book The Lands of Ice and Fire.
Jonathan, who was a theoretical physicist at the time, said yes and went out to buy the books – it had been more than a decade since he last read them. The publishers wanted 12 maps, each 2 feet by 3 feet in size and detailed to perfection. And they wanted all 72 feet of Westeros in 3 months – a deadline which would require Jonathan to complete one map per week.
Getting started was not an issue. At Jonathan’s disposal were 5,700 pages of text and the map sketches created by Martin to pinpoint accuracy. The sketches were beautifully rendered on A4-size paper sheets with HB pencil. Martin had even highlighted the different map components in different colors – forests were drawn in green, major locations were denoted by a symbol to tell if they were big keeps or small towns, etc.
What’s more, voluminous paragraphs of notes had been written about each of these areas. One of Martin’s final notes read: “I need to stop mapping for a while. If I had to come up with one more name, I think my head would explode. Then the Dothraki would name my neck, ‘the place of the bloody stump.’”
So, Jonathan created a rough composite sketch of the known world, fusing the lands of the Seven Kingdoms and the lands across the Narrow Sea, had Random House clear it, and painstakingly started working on the style and the visual details. First came the coastlines, then the mountains and the rivers, followed by the forests, roads and all the other things.
The city of Braavos had never been mapped before, even by Martin; all he had done was prepare a rough sketch. And in 2012, there were only a few references of the city that were known to the public, like the Iron Bank. The rest of the locations were only mentioned in the books. Which meant Jonathan spent a lot of time leafing through the text, page by page, figuring out where everything should land up on a map.
The sheer volume of names and labels on these maps was so enormous that it became impossible for Jonathan to keep track of accuracy. So, Elio and Linda from Westeros.org – the largest Internet repository for Game of Thrones information – were roped in to fact-check every single name on the maps.
With the labels and lines OK-ed by Martin, Jonathan finally began transforming the raw maps into multihued visual treats. The author’s super specific vision for his fantasy world meant that Jonathan would need to navigate through a blizzard of post-it note edits and three color revisions before the maps could be sent to the printers.
When The Lands of Ice and Fire was finally published, it showed Martin’s universe at a scale so exhaustive, it had never been depicted before. The collection features the complete map of the known world; a map that tracks the movements of the protagonists; a full map of Westeros; a map of the Dothraki Sea and the Red Wastes; the Braavos city map; maps of King’s Landing; The Wall and Beyond the Wall; the Free Cities; and Slaver’s Bay, Valyria, and Sothyros.
Check out these 13 incredible facts about the Game of Thrones maps:
- The Game of Thrones maps do not follow any specific mathematical projection
- All the maps (except one) have been drawn by author George R. R. Martin from the point of view of one of the Citadel masters
- The first ever map of the city Braavos was created by Jonathan Roberts for The Lands of Ice and Fire
- There are five different distinct color and styles for the arable lands across the Westeros world map
- The mountains in have been inspired by the Argentinean Andes because they were drawn in the back of a conference hall in Pampas whilst listening to talks on ultra-high energy cosmic ray astrophysics
- King’s Landing is almost as rectangular as Manhattan, New York
- In Braavos, each of the blocks is a block; like a single building. In contrast, King’s Landing is made up of thousands upon thousands of tiny little buildings
- King’s Landing has three big hills: One with the dragon pit on the top right, the Great Sept of Baelor on the bottom left, and the hill that the Red Keep sits on
- The Summer Sea, where Daenerys Targaryen had been sailing right before she got to the Slaver’s Bay, is supposed to have a Mediterranean feel
- Jonathan got an earful for making the old roads of Old Valyria ‘wandery’. They are supposed to be ultra straight because they were created by dragons
- Jonathan got really specific instructions for the coastlines: This should be like small islets and islands coming off at this place. This should be much more jagged. This is a coastline you can’t land in. This is smoother. This has a beach. That beach should be this color
- The Journeys map shows the path of every character through every book to the end of the published books
- The final version of Westeros maps was made more inviting by using warmer shades of the colors used
Think we missed out on something? Let us know in the comments below!