Skip to content
Prev 23272 / 29559 Next

problem plotting elevational map of New Zealand

Hi - I've been making elevational maps of several countries, but for some
reason the code won't work for New Zealand:

library(raster)
x <- getData('alt', country = "NZ")
plot(x)
colfunc <- colorRampPalette(c("black", "white"))
plot(x,col=(colfunc(50)), cex.axis=1, las=1)
title(xlab = "Longitude (degrees E)", ylab="Latitude (degrees S)")

This makes perfectly good maps of plenty of countries (e.g. Australia,
Spain, France) but when I write "country = "NZ"  " on line 2, here's what
happens:
trying URL 'http://biogeo.ucdavis.edu/data/diva/msk_alt/NZL_msk_alt.zip'
Content type 'application/zip' length 649397 bytes (634 Kb)
opened URL
downloaded 634 Kb

returning a list of RasterLayer objects
Error in xy.coords(x, y, xlabel, ylabel, log) :
  'x' is a list, but does not have components 'x' and 'y'
Error in xy.coords(x, y, xlabel, ylabel, log) :
  'x' is a list, but does not have components 'x' and 'y'
I'd really appreciate advice on how to fix this, or other approaches that
might work for NZ. As you can see above, R found the data, but didn't make
the map.

thanks

Chris