Hi Sherri,
There are examples of topographic maps which you have been pointed to, however,
I suspect that you want to know where you can obtain topographic data from
rather than a canned example.
There are quite a few intricacies to the process so I will go through them for
you.
(1)
Topography files can be found in the geomapdata library. You will probably want
to use the maps package too (if you want to display coastlines). If you are
zoomed in on a certain area, you will probably want to use the hi res coastline
data found in the mapdata package. In the following code, I have also used the
mapproj library which provides the map.grid function for drawing lat/lon lines
on map projections.
rm(list=ls())
library(maps)
library(mapdata)
library(geomapdata)
library(mapproj)
(2) Load the variables
data(ETOPO5)
xf <- attr(ETOPO5,'lon') # all lon
yf <- attr(ETOPO5,'lat') # all lat
zf <- ETOPO5 # elevation
(3) The topography data has to be flipped horizontally and vertically and you
also require the data to be placed on a regular grid and you need to specify
limits,
xn <- which(xf>=your_lon_low_limit & xf<=your_lon_high_limit)
yn <- which(yf>=your_lat_low_limit & yf<=your_lat_high_limit )
x <- xf[xn]
y <- yf[yn]
z <- zf[xn,yn]
za <- apply(z,1,rev)
zb <- t(za)
yb <- -rev(y)
xb <- x
nx <- length(xb)
dx <- (xb[nx]-xb[1])/(nx-1)
ny <- length(yb)
dy <- (yb[ny]-yb[1])/(ny-1)
mf <- 5
xo <- seq(xb[1],xb[nx],by=dx/mf)
yo <- seq(yb[1],yb[ny],by=dy/mf)
nxo <- length(xo)
nyo <- length(yo)
zo1 <- matrix(NA,nrow=nxo,ncol=nyo)
(4) Fill your matrix with the data
io <- 1
for (i in 1:nx) {
jo <- 1
for (j in 1:ny) {
zo1[io,jo] <- zb[i,j]
jo <- jo+mf
}
io <- io+mf
}
(5) Smooth the image
zo <- image.smooth(zo1,theta=1.75) (you should try different values of theta)
image(xo,yo,zo$z) will produce a topographic map for you.
contour(xo,yo,zo$z) will produce contour plots of the data for you (which you
can overlay if you like).
map('worldHires',...) will draw coastlines for you
Hope this helps.
Cheers,
Justin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Justin Peter
Research Scientist
Earth System Modelling and Radar Applications Group
Centre for Australian Weather and Climate Research (CAWCR),
A partnership between the Australian Bureau of Meteorology and CSIRO
email: j.peter@bom.gov.au<mailto:j.peter@bom.gov.au>
phone: +61 (0) 3 9669 4838
fax: +61 (0) 3 9669 4660
mail: GPO Box 1289K, Melbourne, Victoria 3001, Australia
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[[alternative HTML version deleted]]