# 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)
+ "~/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)
+ "./data/river/GRDC_687_rivers.shp")
> plot(shape,col="blue")```

```> shape <- readShapeLines(
> 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.

OpenEdition suggests that you cite this post as follows:
Arthur Charpentier (September 5, 2015). Minimalist Maps. Freakonometrics. Retrieved July 18, 2024 from https://doi.org/10.58079/ov0c

## 10 thoughts on “Minimalist Maps”

1. LuPi says:

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. love lindstrand says:

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
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. love lindstrand says:

I tried with and without the comma but get the same error

1. LuPi says:

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. love lindstrand says:

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. but sometimes R does not care..

> list(abc=1)\$abc
[1] 1
> list(abc=1)\$a
[1] 1

3. Dag Hjermann says:

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.