Tag Archives: mapping

Visualizing data with ggplot from Python

Using my rudimentary knowledge of Python, I was interested in exploring the use of rpy2 to eventually be able to bring together spatial data analysis done in Python, with some higher level tools in R – in this case the powerful graphics library ggplot2 to visualize the results.

My setup is Mac OS 10.7.3, Python 2.7, R 2.14. (R needs to be compiled with ‘–enable-R-shlib’, which the official CRAN binary for Mac is). Also required are Xcode and NumPy.

There is no binary for rpy2 for my configuration available, so I downloaded the source (2.2.3). Extract somewhere, change into the rpy2-2.2.3 directory and install with:

sudo python setup.py build install

The Python code below takes a csv file (output from a some prior geoprocessing done with ArcPy) and produces a graphic with a map and a scatterplot – see the comments for further details.

Data can be downloaded here.

Continue reading

Great circles on a recentered worldmap, in ggplot

Even though several examples of great circle visualizations exist by now, I had not seen the code of one made with ggplot2. Both solutions offered, here using plot and here using lattice, basically loop through the great circle lines ordered from low to high number of flights and overplot the lines with fewer counts, which are plotted in a light color with those with higher counts, which are plotted in a dark color.

In ggplot we can simply use the alpha parameter for transparency in combination with scale_colour_gradient to obtain a similar effect.

I am also addressing another issue here, namely the ability to flexibly recenter the world map to any longitude (not just 0 and 180) and to avoid the problem of split polygons.

Example data are all flights out of Beijing, China, downloaded from openflights.org.

Beijing - outgoing flights

Continue reading

The Future of Mapping with Drupal

Recently I went over the page kindly maintained by jeffschuler to get a sense of the status of the Drupal Geospatial Modules. If I consider investing in developing a Drupal Webmapping, how much can I rely on modules to exist in the future?

The graph below shows that many more geospatial modules exist in versions for Drupal 6 than Drupal 7 — Drupal 7 looking more similar to Drupal 5. However, there are two new modules that exist only for Drupal 7, Geofield (alpha release, seeking co-maintainers) and Address field (beta release, actively maintained).

Continue reading