Minimalist Maps

This week, I mentioned a series of maps, on Twitter,

Friday evening, just before leaving the office to pick-up the kids after their first week back in class, Matthew Champion (aka ) sent me an email, asking for more details. He wanted to know if I did produce those graphs, and if he could mention then, in a post. The truth is, I have no idea who produced those graphs, but I told him one can easily reproduce them. For instance, for the cities, in R, use

> library(maps)
> data("world.cities")
> plot(world.cities$lon,world.cities$lat,
+ pch=19,cex=.7,axes=FALSE,xlab="",ylab="")

It is possible to get a more minimalist one by plotting only cities with more than 100,000 unhabitants, e.g.,

> world.cities2 = world.cities[
+ world.cities$pop>100000,]
> plot(world.cities2$lon,world.cities2$lat,
+ pch=19,cex=.7,axes=FALSE,xlab="",ylab="")

For the airports, it was slightly more complex since on http://openflights.org/data.html#airport, 6,977 airports  are mentioned. But on http://www.naturalearthdata.com/, I found another dataset with only 891 airports.

> library(maptools)
> shape <- readShapePoints(
+ "~/data/airport/ne_10m_airports.shp")
> plot(shape,pch=19,cex=.7)

On the same website, one can find a dataset for ports,

> shape <- readShapePoints(
+ "~/data/airport/ne_10m_ports.shp")
> plot(shape,pch=19,cex=.7)

This is for graphs based on points. For those based on lines, for instance rivers, shapefiles can be downloaded from https://github.com/jjrom/hydre/tree/, and then, use

> require(maptools)
> shape <- readShapeLines(
+ "./data/river/GRDC_687_rivers.shp")
> plot(shape,col="blue")

For roads, the shapefile can be downloaded from http://www.naturalearthdata.com/

> shape <- readShapeLines(
+ "./data/roads/ne_10m_roads.shp")
> plot(shape,lwd=.5)

Last, but not least, for lakes, we need the polygons,

> shape <- readShapePoly(
+ "./data/lake/ne_10m_lakes.shp")
> plot(shape,col="blue",border="blue",lwd=2)

Nice, isn’t it? See See the world differently with these minimalist maps for ‘s post.


10 thoughts on “Minimalist Maps”

  1. Yes, you’re right. However, for my personal taste, I usually prefer to have a complete match as I refer to data variables, since the code seems neater to me. In any case, well done to point it out.

  2. Hello and thank you for a very nice post and some very interesting maps

    I am learning R and love cartography so i thought i would play a little with this, but i have run into a wall and hope you can help

    I am trying to get a visualization limited by country

    > library(maps)
    > data(“world.cities”)
    > world.cities2 = world.cities[
    + world.cities$country==”sweden”]
    > plot(world.cities2$lon,world.cities2$lat,
    + pch=19,cex=.7,axes=FALSE,xlab=””,ylab=””)

    I believe the selection work but the plot gives an error
    Error in plot.window(…) : need finite ‘xlim’ values
    In addition: Warning messages:
    1: In min(x) : no non-missing arguments to min; returning Inf
    2: In max(x) : no non-missing arguments to max; returning -Inf
    3: In min(x) : no non-missing arguments to min; returning Inf
    4: In max(x) : no non-missing arguments to max; returning -Inf

    I have searched for a fix but can’t get through it, any help would be highly appreciated

    Thank you

    1. I think it is only because a comma is missing (you select some rows from the original dataset) and the capital S

      > world.cities2 = world.cities[world.cities$country==”Sweden”, ]

        1. Hi all,
          the problems are in the variable name you want to filter – which is called country.etc – and in the attribute value you are looking for – Sweden. So, a possible solution could be:
          world.cities2 = world.cities[ world.cities$country.etc ==’Sweden’,]
          Please, note the comma before the ‘]’ as highlighted by Arthur.
          Hope it will be useful.

          1. Thanks a lot, that works.
            And i do feel pretty stupid, i saw the “.etc” part while checking the source but managed to overlook it…

            Thank you

          2. “world.cities$country” works, you don’t need the “etc” part. What was wrong in the original question was the small “s” in “sweden”.

Leave a Reply

Your email address will not be published. Required fields are marked *