[R-sig-Geo] problem plotting elevational map of New Zealand

Tim Appelhans tim.appelhans at gmail.com
Tue Aug 25 12:32:27 CEST 2015


Chris,
the downloaded data is a list of two entries. First entry is for 
'main-land' NZ, second for Chatham Islands.

So, plot(x[[1]],  col=(colfunc(50)), cex.axis=1, las=1)

should work as expected for main-land NZ.

Best
Tim


On 25.08.2015 12:23, Christopher Lusk wrote:
> 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:
>
>> x <- getData('alt', country = "NZ")
> 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
>> plot(x)
> Error in xy.coords(x, y, xlabel, ylabel, log) :
>    'x' is a list, but does not have components 'x' and 'y'
>> colfunc <- colorRampPalette(c("black", "white"))
>> plot(x,col=(colfunc(50)), cex.axis=1, las=1)
> Error in xy.coords(x, y, xlabel, ylabel, log) :
>    'x' is a list, but does not have components 'x' and 'y'
>> title(xlab = "Longitude (degrees E)", ylab="Latitude (degrees S)")
> 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
>

-- 
#####################################
Tim Appelhans
Department of Geography
Environmental Informatics
Philipps Universität Marburg
Deutschhausstraße 12
35032 Marburg (Paketpost: 35037 Marburg)
Germany

Tel +49 (0) 6421 28-25957

http://environmentalinformatics-marburg.de/



More information about the R-sig-Geo mailing list