Jun 18, 2025
  • Dakota Betz1
  • 1ucsd
  • Rouse Lab
Icon indicating open access to content
QR code linking to this content
Protocol CitationDakota Betz 2025. Maps. protocols.io https://dx.doi.org/10.17504/protocols.io.3byl4k4zzvo5/v1
License: This is an open access protocol distributed under the terms of the Creative Commons Attribution License,  which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited
Protocol status: Working
We use this protocol and it's working
Created: August 23, 2021
Last Modified: June 18, 2025
Protocol Integer ID: 52641
Keywords: maps basic marmap instruction, plotting map
Abstract
Basic MarMap instructions for plotting maps in R studio.
Troubleshooting
Programs and Dependencies

Once you have R and R Studio installed, install marmap
Marmap depends on some other packages, and you may encounter errors if they're not up to date.

Getting Started-Quick Maps
Before making any maps, be sure that you have the marmap package loaded. Run the following code:

Command
new command name
library(marmap)

To start with, you'll want to make some quick/rough maps to make sure you've got your desired geographic range, etc. To make a map, R will first have to query the NOAA database for data for a given geographic range that you provide. Visualizing this by creating maps is really helpful for deciding on the exact range that you want, but you don't want to waste time creating high-quality maps at this stage.

To query the NOAA database, use the following code:
Command
Where a and b are your chosen longitudes (forming a range) and c and d are your chosen latitudes. Keep the resolution at 10 (poor) for now to make map generation fast. Change the antimeridean setting if it applies to you (you have points spanning that longitude)
new command name
map1 <- getNOAA.bathy(lon1 = a, lon2 = b, lat1 = c lat2 = d, resolution = 10, 
                      keep = TRUE, antimeridian = FALSE)
To see a quick summary of your plot and generate a quick map in black and white:

Command
new command name
summary(map1)
plot(map1)

Color Maps
This is my favorite color scheme:


Command
new command name
plot(map1, image = TRUE, bpal = blues(100),
     deep = c(-10000, -5000, 0),
     shallow = c(-7000, -10, 0),
     step = c(3000, 3000, 3000),
     lwd = c(0.8, 0.8, 0), lty = c(1, 1, 0),
     col = c("steelblue4", "steelblue", "seashell3"),
     drawlabel = c(FALSE, FALSE, FALSE))
# Creating a custom palette of blues
# USE THIS ONE FOR WINDOWS:
blues <- c("lightsteelblue4", "lightsteelblue3",
           "lightsteelblue2", "lightsteelblue1")
# Plotting the bathymetry with different colors for land and sea
plot(map1, image = TRUE, land = TRUE, lwd = 0, lty=0,
     bpal = list(c(0, max(map1), "seashell3"),
                 c(min(wrld),0,blues)))

Troubleshooting Errors
Message:
Error in if (ncol(x) == 3 & !exists("bathy", inherits = FALSE)) { : argument is of length zero
This error occurs when the packages rgdal and raster are not up to date. Update them using

Command
The package name goes inside the parentheses, surrounded by quotes, eg update.packages("rgdal")
new command name
update.packages()