::cityview("Christchurch") rcityviews
1 Introduction
City maps in a particular minimalist style have become quite trendy recently. You’ve probably seen them all over the internet, with sellers on platforms like Etsy charging anywhere from $5 to $20 for a digital download, and even more for printed versions.
But here’s a little secret… they’re super easy to create in R.
There’s an R package called rcityviews
that allows you to make these maps with just one line of code:
Pretty cool, right? But it doesn’t stop there. The rcityviews
package offers a range of themes and border options. And if coding isn’t your thing, the package author has even provided a ShinyApp that lets you create custom maps for cities all over the world without writing a single line of R code.
2 New Zealand urban areas
To show you just how easy these are to create, I wrote a small for loop that iterates over the names and locations of New Zealand’s 150 largest urban areas to generate maps for each one. The process is highly efficient and requires minimal effort once the loop is set up. With just a few lines of code, you can create a comprehensive collection of maps that visually capture the essence of these diverse urban landscapes. This method not only saves time but also allows for consistent styling across all maps, ensuring that each map adheres to the same aesthetic standards.
Show the code
library(rcityviews)
library(sf)
library(dplyr)
# read cities
<- st_read("posts/city-maps/cities.shp") |>
cities mutate(
Longitude = st_coordinates(geometry)[, 1],
Latitude = st_coordinates(geometry)[, 2]
|>
) st_drop_geometry() |>
::arrange(desc(Population))
dplyr
<- list(
myTheme colors = list(
background = "#ffffff",
water = "#9ddffb",
landuse = c("#f2f4cb", "#d0f1bf", "#64b96a"),
contours = "#eeefc9",
streets = "#2f3737",
rails = c("#2f3737", "#eeefc9"),
buildings = c("#8e76a4", "#a193b1", "#db9b33", "#e8c51e", "#ed6c2e"),
text = "#2f3737",
waterlines = "#9ddffb"
),font = list(
"family" = "Imbue",
"face" = "plain",
"scale" = 3,
append = "\u2014"
),size = list(
borders = list(
contours = 0.15,
water = 0.4,
canal = 0.5,
river = 0.6
),streets = list(
path = 0.2,
residential = 0.3,
structure = 0.35,
tertiary = 0.4,
secondary = 0.5,
primary = 0.6,
motorway = 0.8,
rails = 0.65,
runway = 3
)
)
)
# do one individually
# city <- new_city(name = "Hokitika", country = "New Zealand", lat = -42.717507, long = 170.973959)
#
# p <- cityview(name = city, license = FALSE, border = "circle", theme = myTheme)
#
# ggplot2::ggsave(filename = "posts/city-maps/output/Hokitika.jpg",
# plot = p,
# height = 500,
# width = 500,
# units = "mm",
# dpi = 300)
# Loop through each city in the data frame
for (i in 1:nrow(cities)) {
# Extract city details
<- cities$Urban.Area[i]
city_name <- cities$Latitude[i]
city_lat <- cities$Longitude[i]
city_long
# Create a new city object
<- new_city(name = city_name, country = "New Zealand", lat = city_lat, long = city_long)
city
# Generate a filename for the output
<- paste0("posts/city-maps/output/", city_name, ".jpg")
output_filename
# Produce the cityview
<- cityview(name = city, license = FALSE, border = "circle",
p theme = myTheme) # replace myTheme with "vintage" or another
::ggsave(filename = output_filename,
ggplot2plot = p,
height = 500,
width = 500,
units = "mm",
dpi = 300)
}
Here are a few of my favourites: (more below)
3 Download links
You can download1 high resolution versions from this repo or the table below. I hope your town or city is among them!
City | Link |
---|---|
Alexandra | View Map |
Amberley | View Map |
Arrowtown | View Map |
Ashburton | View Map |
Ashhurst | View Map |
Auckland | View Map |
Balclutha | View Map |
Beachlands-Pine Harbour | View Map |
Blenheim | View Map |
Bluff | View Map |
Brightwater | View Map |
Bulls | View Map |
Cambridge | View Map |
Carterton | View Map |
Christchurch | View Map |
Clive | View Map |
Coromandel | View Map |
Cromwell | View Map |
Dannevirke | View Map |
Darfield | View Map |
Dargaville | View Map |
Dunedin | View Map |
Edgecumbe | View Map |
Eltham | View Map |
Featherston | View Map |
Feilding | View Map |
Foxton Beach | View Map |
Foxton | View Map |
Geraldine | View Map |
Gisborne | View Map |
Gore | View Map |
Greymouth | View Map |
Greytown | View Map |
Hamilton | View Map |
Hastings | View Map |
Havelock North | View Map |
Helensville | View Map |
Hibiscus Coast | View Map |
Hokitika | View Map |
Huntly | View Map |
Hāwera | View Map |
Inglewood | View Map |
Invercargill | View Map |
Kaiapoi | View Map |
Kaikohe | View Map |
Kaikōura | View Map |
Kaitaia | View Map |
Katikati | View Map |
Kawerau | View Map |
Kerikeri | View Map |
Kihikihi | View Map |
Kumeū-Huapai | View Map |
Lake Hāwea | View Map |
Leeston | View Map |
Levin | View Map |
Lincoln | View Map |
Lower Hutt | View Map |
Lyttelton | View Map |
Mangawhai Heads | View Map |
Maraetai | View Map |
Martinborough | View Map |
Marton | View Map |
Masterton | View Map |
Matamata | View Map |
Methven | View Map |
Milton | View Map |
Moerewa | View Map |
Morrinsville | View Map |
Mosgiel | View Map |
Motueka | View Map |
Murupara | View Map |
Napier | View Map |
Nelson | View Map |
New Plymouth | View Map |
Ngongotahā | View Map |
Ngāruawāhia | View Map |
Oamaru | View Map |
One Tree Point | View Map |
Oxford | View Map |
Paekākāriki | View Map |
Paeroa | View Map |
Pahiatua | View Map |
Palmerston North | View Map |
Paraparaumu | View Map |
Pegasus | View Map |
Picton | View Map |
Porirua | View Map |
Prebbleton | View Map |
Pukekohe | View Map |
Putāruru | View Map |
Pōkeno | View Map |
Queenstown | View Map |
Raglan | View Map |
Rangiora | View Map |
Renwick | View Map |
Richmond | View Map |
Riverhead | View Map |
Rolleston | View Map |
Rotorua | View Map |
Ruakākā | View Map |
Snells Beach | View Map |
Stratford | View Map |
Taihape | View Map |
Taumarunui | View Map |
Taupō | View Map |
Tauranga | View Map |
Te Anau | View Map |
Te Aroha | View Map |
Te Awamutu | View Map |
Te Kauwhata | View Map |
Te Kūiti | View Map |
Te Puke | View Map |
Temuka | View Map |
Thames | View Map |
Timaru | View Map |
Tokoroa | View Map |
Tuakau | View Map |
Twizel | View Map |
Tūrangi | View Map |
Upper Hutt | View Map |
Waiheke Island | View Map |
Waihi Beach-Bowentown | View Map |
Waihi | View Map |
Waikanae | View Map |
Waimate | View Map |
Waipawa | View Map |
Waipukurau | View Map |
Wairoa | View Map |
Waitara | View Map |
Waiuku | View Map |
Wakefield | View Map |
Warkworth | View Map |
Wellington | View Map |
Wellsford | View Map |
West Melton | View Map |
Westport | View Map |
Whakatāne | View Map |
Whanganui | View Map |
Whangārei | View Map |
Whitianga | View Map |
Winton | View Map |
Woodend | View Map |
Wānaka | View Map |
Ōhope | View Map |
Ōmokoroa | View Map |
Ōpōtiki | View Map |
Ōtaki Beach | View Map |
Ōtaki | View Map |
Ōtorohanga | View Map |
Footnotes
Feel free to print these, share them, or use them as you please. Just maybe don’t start selling them without asking me first.↩︎