Reputation: 71
I trying to create a bathymetry map of Papua New Guinea in R, but when I plot the map, it looks very busy with all the contour. I want to just make the land one color, and the water a second color, so the map looks very simple. I have attached my r code and the map created when I use it.
Best, Shannon
library(marmap)
PNG_Map <- getNOAA.bathy(lon1 = 144, lon2 = 158, lat1 = -14, lat2 = -8,
resolution = 1)
summary(PNG_Map)
library(zoom)
white <- ("white")
black <- ("black")
par(mfrow=c(1,1))
plot(PNG_Map, image = TRUE, land = TRUE, xlim=c(148.75,154),
ylim=c(-14, -8.75), xaxs = "i", yaxs = "i", lty = c(1, 1, 1), lwd =
c(0.6, 0.6, 1.2), bpal = list(c(0, max(PNG_Map), black),
c(min(PNG_Map),0 , white)))
Upvotes: 2
Views: 1530
Reputation: 1234
I strongly advise you to create your map by calling the plot.bathy()
function several times to draw what you want element by element. That way, you can add as many or as few isobaths as you want. Here are two examples based on your code (I've deleted unnecessary lines and arguments):
library(marmap)
PNG_Map <- getNOAA.bathy(lon1 = 144, lon2 = 158, lat1 = -14, lat2 = -8, resolution = 1)
# --- Black and white ---
plot(PNG_Map, image = TRUE, land = TRUE, xlim=c(148.75,154), ylim=c(-14, -8.75), n=100, lwd = 0.03, bpal = list(c(0, max(PNG_Map), grey(.3)), c(min(PNG_Map),0 , "white")))
plot(PNG_Map, deep=0, shallow=0, lwd = 0.6, add=T) # Add coastline
plot(PNG_Map, deep=-200, shallow=-200, lwd = 0.4, drawlabels=T, add=T) # Add -200m isobath
plot(PNG_Map, deep=-2000, shallow=-2000, lwd = 0.4, drawlabels=T, add=T) # Add -2000m isobath
# --- With colors ---
# Creating color palettes
blues <- c("lightsteelblue4", "lightsteelblue3", "lightsteelblue2", "lightsteelblue1")
greys <- c(grey(0.6), grey(0.93), grey(0.99))
plot(PNG_Map, image = TRUE, land = TRUE, xlim=c(148.75,154), ylim=c(-14, -8.75), lwd = 0.03, bpal = list(c(0, max(PNG_Map), greys), c(min(PNG_Map),0 , blues)))
plot(PNG_Map, deep=0, shallow=0, lwd = 1, add=T) # Add coastline
plot(PNG_Map, deep=-200, shallow=-200, lwd = 0.4, drawlabels=T, add=T) # Add -200m isobath
plot(PNG_Map, deep=-2000, shallow=-2000, lwd = 0.4, drawlabels=T, add=T) # Add -2000m isobath
The key arguments to play with when calling plot.bathy()
for the first time are:
n=
: specifies a rough number of isobaths to plotlwd=
: specifies the width of isobath linesAs suggested by lukeA, check ?plot.bathy
but also vignette("marmap")
and vignette("marmap-DataAnalysis")
. A whole lot of examples are presented there.
Upvotes: 1
Reputation: 54237
I guess you could try it like this:
pal1 <- list(
c(min(PNG_Map), 0, "purple", "blue", "lightblue"),
c(0, max(PNG_Map), "yellow", "brown"))
pal2 <- list(
c(min(PNG_Map), 0, "blue"),
c(0, max(PNG_Map), "yellow"))
plot_it <- function(pal, n, ...) {
plot(PNG_Map, image=TRUE, land = TRUE, bpal = pal, n = n,
xlim=c(148.75,154), ylim=c(-14, -8.75), ...)
}
par(mfrow = c(3, 1), mar = c(0,0,0,0), bty="n", xaxt="n", yaxt="n")
plot_it(pal1, 1)
plot_it(pal2, 10)
plot_it(pal2, 10, deep=min(PNG_Map), shallow=0, step = 1000)
Also check ?plot.bathy
for the documentation.
Upvotes: 0