1.3 Software for geocomputation

R is a powerful language for geocomputation but there are many other options for geographic data analysis providing thousands of geographic functions.Awareness of other languages for geocomputation will help decide when a different tool may be more appropriate for a specific task, and place R in the wider geospatial ecosystem.This section briefly introduces the languages C++, Java and Python for geocomputation, in preparation for Chapter 9.

An important feature of R (and Python) is that it is an interpreted language.This is advantageous because it enables interactive programming in a Read–Eval–Print Loop (REPL):code entered into the console is immediately executed and the result is printed, rather than waiting for the intermediate stage of compilation.On the other hand, compiled languages such as C++ and Java tend to run faster (once they have been compiled).

C++ provides the basis for many GIS packages such as QGIS, GRASS and SAGA so it is a sensible starting point.Well-written C++ is very fast, making it a good choice for performance-critical applications such as processing large geographic datasets, but is harder to learn than Python or R.C++ has become more accessible with the Rcpp package, which provides a good ‘way in’ to C programming for R users.Proficiency with such low-level languages opens the possibility of creating new, high-performance ‘geoalgorithms’ and a better understanding of how GIS software works (see Chapter 10).

Java is another important and versatile language for geocomputation.GIS packages gvSig, OpenJump and uDig are all written in Java.There are many GIS libraries written in Java, including GeoTools and JTS, the Java Topology Suite (GEOS is a C++ port of JTS).Furthermore, many map server applications use Java including Geoserver/Geonode, deegree and 52°North WPS.

Java’s object-oriented syntax is similar to that of C++.A major advantage of Java is that it is platform-independent (which is unusual for a compiled language) and is highly scalable, making it a suitable language for IDEs such as RStudio, with which this book was written.Java has fewer tools for statistical modeling and visualization than Python or R, although it can be used for data science (Brzustowicz 2017).

Python is an important language for geocomputation especially because many Desktop GIS such as GRASS, SAGA and QGIS provide a Python API (see Chapter 9).Like R, it is a popular tool for data science.Both languages are object-oriented, and have many areas of overlap, leading to initiatives such as the reticulate package that facilitates access to Python from R and the Ursa Labs initiative to support portable libraries to the benefit of the entire open source data science ecosystem.

In practice both R and Python have their strengths and to some extent which you use is less important than the domain of application and communication of results.Learning either will provide a head-start in learning the other.However, there are major advantages of R over Python for geocomputation.This includes its much better support of the geographic data models vector and raster in the language itself (see Chapter 2) and corresponding visualization possibilities (see Chapters 2 and 8).Equally important, R has unparalleled support for statistics, including spatial statistics, with hundreds of packages (unmatched by Python) supporting thousands of statistical methods.

The major advantage of Python is that it is a general-purpose programming language.It is used in many domains, including desktop software, computer games, websites and data science.Python is often the only shared language between different (geocomputation) communities and can be seen as the ‘glue’ that holds many GIS programs together.Many geoalgorithms, including those in QGIS and ArcMap, can be accessed from the Python command line, making it well-suited as a starter language for command-line GIS.3

For spatial statistics and predictive modeling, however, R is second-to-none.This does not mean you must choose either R or Python: Python supports most common statistical techniques (though R tends to support new developments in spatial statistics earlier) and many concepts learned from Python can be applied to the R world.Like R, Python also supports geographic data analysis and manipulation with packages such as osgeo, Shapely, NumPy and PyGeoProcessing(Garrard 2016).