New Zealand · R

The right map projection

You know how people say it is important to use the right map projection?

What they said, illustrated.

library(maps)
library(mapproj)

png(filename="default.png", width = 320, height = 320)
map("nz")
dev.off()

projec <- "mercator"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "sinusoidal"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "cylequalarea"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec, par=-41.3)
dev.off()

projec <- "cylindrical"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "gall"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec, par=-41.3)
dev.off()

projec <- "mollweide"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "gilbert"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "azequidistant"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "azequalarea"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "gnomonic"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "orthographic"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "conic"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec, par=-41.3)
dev.off()

projec <- "gall"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec, par=-41.3)
dev.off()

projec <- "bonne"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec, par=-41.3)
dev.off()

projec <- "polyconic"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "aitoff"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "lagrange"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "bicentric"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec, par=174.8)
dev.off()

projec <- "elliptic"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec, par=174.8)
dev.off()

projec <- "globular"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "vandergrinten"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "eisenlohr"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "guyou"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "square"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "tetra"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

projec <- "hex"
png(filename=paste(projec ,"png", sep="."), width = 320, height = 320)
map("nz", proj=projec)
dev.off()

Which look something like (in no particular order, so you can play guess the projection):

and if you have ever wondered what a composite of the above would look like (and you probably hadn’t)

list_of_files <- list.files(pattern=".png")
library(png)
composite <- readPNG(list_of_files[1])
#changing 0 to 1 range to -1 to 0 so I can 
#accumulate the black
#rather than the white
composite <- composite - 1

for (i in 2:24){
 composite <- composite + (readPNG(list_of_files[i]) -1)
}

composite[composite < -1] <- -1
composite <- composite + 1
writePNG(composite, target="composite.png")

which gives:

composite

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s