Today, I will make a bathymetric map using R. We can easily change the color of the map and plot our data on the map using R. 

(QGIS is also very useful!!)


Data source: Compositional Data Analysis (CoDA) of Clinopyroxene from Abyssal Peridotites

Map: ETOPO1 Bedrock

Reference: Benjamin Bell blog




Library

library(sp)
library(raster)
library(rgdal)
library(RColorBrewer)
library(tidyverse)



1 Download the ETOPO map and save it on a PC.

2 Import ETOPO1 data (map)

etopo <- raster("/Path HERE/ETOPO1_Bed_g_geotiff.tif")


3 Import sample data (abyssal peridotites)

data <- read.csv("/Path HERE/residual_abyssal_peridotites.csv")



4.1 Vizualization (default)

plot(etopo)


4.2 Change color (using color palette) 

plot(etopo, col=rev(brewer.pal(n = 11, name = "RdBu")))

4.3 Plot abyssal peridotites data on the map

plot(etopo, col=rev(brewer.pal(n = 11, name = "RdBu")))
points(data$Long, data$Lat)


4.4 Adding colors for abyssal peridotites data based on the locations/Ridges

Data preparation 
I remove DMM from the dataset and create the dataset for each Ridge.

data_new <- data %>% filter(!(Ridge == "DMM"))
aar <- data_new %>% filter(Ridge == "AAR")
epr <- data_new %>% filter(Ridge == "EPR")
cir <- data_new %>% filter(Ridge == "CIR")
mar <- data_new %>% filter(Ridge == "MAR")
swir <- data_new %>% filter(Ridge == "SWIR")
lt <- data_new %>% filter(Ridge == "LT")
gak <- data_new %>% filter(Ridge == "GAK")

Vizualization

plot(etopo, col=rev(brewer.pal(n = 11, name = "RdBu")))
points(aar$Long, aar$Lat, pch = 21, col= "black", bg = "green4")
points(epr$Long, epr$Lat, pch = 21, col= "black", bg = "sienna4")
points(cir$Long, cir$Lat, pch = 21, col= "black", bg = "orangered1")
points(mar$Long, mar$Lat, pch = 21, col= "black", bg = "orange1")
points(swir$Long, swir$Lat, pch = 21, col= "black", bg = "royalblue4")
points(lt$Long, lt$Lat, pch = 21, col= "black", bg = "lightskyblue3")
points(gak$Long, gak$Lat, pch = 21, col= "black", bg = "royalblue1")
legend("bottomleft", inset=.02, title="Ridge",
  legend = c("AAR","EPR","CIR","MAR","SWIR","LT","GAK"), pch = c(16,16,16,16,16,16), col = c("green4","sienna4","orangered1","orange1","royalblue4","lightskyblue3","royalblue1"), cex = 0.8)



4.5 Changing the color palette of the map

Data preparation I want to make lands black-colored to highlight the ocean. I prepare the original color palette.

# Colour scheme
blue.col <- colorRampPalette(c("darkblue", "lightblue"))
black.col <- colorRampPalette(c("black"))
# Break points
br <- seq(from=-12000, to=8000, by=1000)


Vizualization with the new color palette and adjusting axes

plot(etopo, col=c(blue.col(12), black.col(8)), breaks=br, xaxt = "n", yaxt = "n")
axis(1, at = c(-180, -120, -60, 0, 60, 120, 180)) 
axis(2, at = c(-90, -60, -30, 0, 30, 60, 90)) 



Vizualization (adding abyssal peridotites data)

plot(etopo, col=c(blue.col(12), black.col(8)), breaks=br, xaxt = "n", yaxt = "n")
axis(1, at = c(-180, -120, -60, 0, 60, 120, 180))
axis(2, at = c(-90, -60, -30, 0, 30, 60, 90)) 
points(aar$Long, aar$Lat, pch = 21, col= "black", bg = "green4")
points(epr$Long, epr$Lat, pch = 21, col= "black", bg = "sienna4")
points(cir$Long, cir$Lat, pch = 21, col= "black", bg = "orangered1")
points(mar$Long, mar$Lat, pch = 21, col= "black", bg = "orange1")
points(swir$Long, swir$Lat, pch = 21, col= "black", bg = "royalblue4")
points(lt$Long, lt$Lat, pch = 21, col= "black", bg = "lightskyblue3")
points(gak$Long, gak$Lat, pch = 21, col= "black", bg = "royalblue1")
legend("bottomleft", inset=.02, title="Ridge",
  legend = c("AAR","EPR","CIR","MAR","SWIR","LT","GAK"), pch = c(16,16,16,16,16,16), col = c("green4","sienna4","orangered1","orange1","royalblue4","lightskyblue3","royalblue1"), cex = 0.8)





keywords: abyssal peridotites, clinopyroxene, spinel, clinopyroxene, rstats, r, plot, Geochemistry, Geology, Petrology, using R, r bloggers, bathymetric map, QGIS