Working with shapefiles, projections and world maps in ggplot – R Psychologist

In this post I will show some different examples of how to work with map projections and how to plot the maps using ggplot. Many maps that are shown using their default projection are in the longlat-format, which is far from optimal. For plotting world maps I prefer to use either Robinson or Winkel Tripel projection—but many more are available—and I will show how to use both these projections. Before we get started you need to download a couple of shapefiles that we will use. You can find them here: Put them directly inside your working directory. We will use functions from the rgdal-package to read the shapefiles into R, so if you do not have it, you need to install it before you continue. However, the Caspian sea is missing. This is because of how ggplot handles polygon holes. Ggplot will plot polygon holes as a separate polygon, thus we need to make it pseudo-transparent by changing its fill color. If we want we can also add a graticule and a bounding box. The bounding box is useful if we want to make the sea blue—especially when using some form of curved projection. Here I have added a graticule and bounding box to the longlat-map. Bubble plots are a popular way of displaying information on maps. Here I used project() to reproject the bubbles' coordinates into the Robinson projection. Lastly, here is an example of the Winkel tripel projection. This projection became popular after 1998 when the National Geographic Society choose to use it for their world maps—using it to replace the Robinson projection, which they previously used. I'm a PhD-student and a clinical psychologist from Sweden with a passion for research and statistics. This is my personal blog about psychological research and statistical programming with R. Designed and built by Kristoffer Magnusson. Powered by Pelican, which takes great advantage of Python, and Bootstrap. Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 4.0 International license. Source.

Яндекс.Метрика Рейтинг Free Web Counter
page counter
Last Modified:
Fatal error: Call to undefined function mdv_last_modified() in /home1/wacedu0abjm6/public_html/wp-content/themes/CherryFramework/footer.php on line 121