I made a map last year of survey points using Rgooglemaps in R. It was a simple map displaying points at which different surveys were conducted. Since google have updated their licence I want to re-create this map using the getNOAA function using marmap.
Here is my old map
[![Survey Map using Google Maps][1]][1]
This is the current code I am using, but I am getting somewhat confused by the new system.
library(marmap)
library(ggplot2)
Survey_Map<- getNOAA.bathy(lon1 = -26, lon2 = -15, lat1 = 22, lat2 =
19, resolution = 1)
Survey_Points<-autoplot(Survey_Map, geom = c("raster", "contour")) +
scale_fill_etopo()
Map<-Survey_Points+geom_point(data = Survey_Map, aes(x=Longitude,
y=Latitude), size = 1.3, colour= Survey_Type)
Map
and here is the data I am using
structure(list(Survey_Type = structure(c(2L, 2L, 2L, 2L, 2L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L), .Label = c("BRUVs Survey", "Fishermen Survey",
"Snorkel Survey 2014", "Snorkel Survey 2015"), class = "factor"),
Latitude = c(16.73194, 16.73274, 15.33520907, 15.33486, 15.3316,
15.33568, 15.33568, 15.3458, 15.3458, 15.33301, 15.33301,
15.34517, 15.34517, 15.08846, 15.11057, 15.11057, 15.11228,
15.11228, 15.2832, 15.2832, 15.29262, 15.29262, 15.22394,
15.22394, 15.24419, 15.24419, 15.22698, 15.22698, 15.25396,
15.25396, 15.11008, 15.11008, 15.10803, 15.10803, 15.19545,
15.17862, 15.11457, 15.09544, 15.09544, 15.11015, 15.11015,
15.28835, 15.2752, 15.16301, 15.16301, 15.11597, 15.1107,
15.11036, 15.23928, 15.26985, 15.11055, 15.11055, 15.10636,
15.10636, 15.26554, 15.26554, 15.22398, 15.17643, 15.17643,
15.19829, 15.19829, 14.93243, 15.25434, 15.25428, 15.3304,
15.3304, 15.29193, 15.29193, 15.36435, 15.27594, 15.27594,
15.30885, 15.30885, 15.14253, 15.14253, 15.16037, 15.16037,
15.11021, 15.11121, 15.11121, 15.2726, 15.28601, 15.1433,
15.1433, 15.16446, 15.16446, 15.27095, 15.22856, 15.22856,
15.22529, 15.22529, 15.3303, 15.32407, 15.12321, 15.0802,
15.31593, 15.31559, 15.31693, 15.31729, 15.31674, 15.31674,
15.31709, 15.109374, 15.10863, 15.10827, 15.12663, 15.2719,
15.2698, 15.31164, 15.31172, 15.31215, 15.31457, 15.31857,
15.11158, 15.11055, 15.27275, 15.15893, 15.16213, 15.11035,
15.10915, 15.10344, 15.10923, 15.11025, 15.11104, 15.10917,
15.10687, 15.11028, 15.11004, 15.11876, 15.11755, 15.11565,
15.1089, 15.11058, 15.11012, 15.11027, 15.22524, 15.22644
), Longitude = c(-27.0132, -27.0112, -16.9656, -23.19415,
-23.18153, -23.14718, -23.14718, -23.16627, -23.16627, -23.19646,
-23.19646, -23.19459, -23.19459, -23.16098, -23.11927, -23.11927,
-23.11406, -23.11406, -23.24286, -23.24286, -23.23423, -23.23423,
-23.27888, -23.27888, -23.24419, -23.24419, -23.08382, -23.08382,
-23.08812, -23.08812, -23.18041, -23.18041, -23.14643, -23.14643,
-23.25713, -23.24797, -23.10995, -23.17202, -23.17202, -23.15479,
-23.15479, -23.2331, -23.24257, -23.07842, -23.07842, -23.20737,
-23.19075, -2311970, -23.09255, -23.10476, -23.11863, -23.11863,
-23.13563, -23.13563, -23.0757, -23.0757, -23.0857, -23.25823,
-23.25823, -23.25384, -23.25384, -22.22907, -23.22907, -23.23523,
-23.20714, -23.20714, -23.23079, -23.23079, -23.20673, -23.23527,
-23.23527, -23.21675, -23.21675, -23.09247, -23.09247, -23.08146,
-23.08146, -23.11954, -23.18338, -23.18338, -23.2411, -23.24536,
-23.09274, -23.09274, -23.08542, -23.08542, -23.24192, -23.27364,
-23.27364, -23.26522, -23.26522, -23.1819, -23.1738, -23.2068,
-23.1558, -23.18878, -23.1883, -23.18521, -23.18542, -23.1845,
-23.1845, -23.18621, -23.1265, -23.1221, -23.12294, -23.13424,
-23.1035, -23.1039, -23.14203, -23.14224, -23.1434, -23.14557,
-23.18595, -23.1205, -23.12284, -23.1016, -23.06118, -23.06145,
-23.11963, -23.12103, -23.13235, -23.12047, -23.11879, -23.1178,
-23.12014, -23.1244, -23.12028, -23.12266, -23.13638, -23.13973,
-23.13559, -23.12061, -23.1147, -23.11508, -23.11559, -23.21706,
-23.22154)), class = "data.frame", row.names = c(NA, -137L))
This is the error I get when trying to create the map.
Error: Aesthetics must be either length 1 or the same as the data
(217800): x, y
With getNOAA.bathy()
from the marmap
package, here is what you could do:
# Load packages
library(marmap)
library(ggplot2)
# Download bathymetry from NOAA
# Be careful to download an area large enough to cover all you survey points
# Add keep = TRUE to avoid re-downloading the same dataset from NOAA every time you call this command
bathy_data <- getNOAA.bathy(lon1 = -28,
lon2 = -15,
lat1 = 14,
lat2 = 17,
resolution = 1,
keep = TRUE)
# Load the location and type of surveys
location <- structure(list(Survey_Type = structure(c(2L, 2L, 2L, 2L, 2L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L,
3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L), .Label = c("BRUVs Survey", "Fishermen Survey",
"Snorkel Survey 2014", "Snorkel Survey 2015"), class = "factor"),
Latitude = c(16.73194, 16.73274, 15.33520907, 15.33486, 15.3316,
15.33568, 15.33568, 15.3458, 15.3458, 15.33301, 15.33301,
15.34517, 15.34517, 15.08846, 15.11057, 15.11057, 15.11228,
15.11228, 15.2832, 15.2832, 15.29262, 15.29262, 15.22394,
15.22394, 15.24419, 15.24419, 15.22698, 15.22698, 15.25396,
15.25396, 15.11008, 15.11008, 15.10803, 15.10803, 15.19545,
15.17862, 15.11457, 15.09544, 15.09544, 15.11015, 15.11015,
15.28835, 15.2752, 15.16301, 15.16301, 15.11597, 15.1107,
15.11036, 15.23928, 15.26985, 15.11055, 15.11055, 15.10636,
15.10636, 15.26554, 15.26554, 15.22398, 15.17643, 15.17643,
15.19829, 15.19829, 14.93243, 15.25434, 15.25428, 15.3304,
15.3304, 15.29193, 15.29193, 15.36435, 15.27594, 15.27594,
15.30885, 15.30885, 15.14253, 15.14253, 15.16037, 15.16037,
15.11021, 15.11121, 15.11121, 15.2726, 15.28601, 15.1433,
15.1433, 15.16446, 15.16446, 15.27095, 15.22856, 15.22856,
15.22529, 15.22529, 15.3303, 15.32407, 15.12321, 15.0802,
15.31593, 15.31559, 15.31693, 15.31729, 15.31674, 15.31674,
15.31709, 15.109374, 15.10863, 15.10827, 15.12663, 15.2719,
15.2698, 15.31164, 15.31172, 15.31215, 15.31457, 15.31857,
15.11158, 15.11055, 15.27275, 15.15893, 15.16213, 15.11035,
15.10915, 15.10344, 15.10923, 15.11025, 15.11104, 15.10917,
15.10687, 15.11028, 15.11004, 15.11876, 15.11755, 15.11565,
15.1089, 15.11058, 15.11012, 15.11027, 15.22524, 15.22644
), Longitude = c(-27.0132, -27.0112, -16.9656, -23.19415,
-23.18153, -23.14718, -23.14718, -23.16627, -23.16627, -23.19646,
-23.19646, -23.19459, -23.19459, -23.16098, -23.11927, -23.11927,
-23.11406, -23.11406, -23.24286, -23.24286, -23.23423, -23.23423,
-23.27888, -23.27888, -23.24419, -23.24419, -23.08382, -23.08382,
-23.08812, -23.08812, -23.18041, -23.18041, -23.14643, -23.14643,
-23.25713, -23.24797, -23.10995, -23.17202, -23.17202, -23.15479,
-23.15479, -23.2331, -23.24257, -23.07842, -23.07842, -23.20737,
-23.19075, -23.11970, -23.09255, -23.10476, -23.11863, -23.11863,
-23.13563, -23.13563, -23.0757, -23.0757, -23.0857, -23.25823,
-23.25823, -23.25384, -23.25384, -22.22907, -23.22907, -23.23523,
-23.20714, -23.20714, -23.23079, -23.23079, -23.20673, -23.23527,
-23.23527, -23.21675, -23.21675, -23.09247, -23.09247, -23.08146,
-23.08146, -23.11954, -23.18338, -23.18338, -23.2411, -23.24536,
-23.09274, -23.09274, -23.08542, -23.08542, -23.24192, -23.27364,
-23.27364, -23.26522, -23.26522, -23.1819, -23.1738, -23.2068,
-23.1558, -23.18878, -23.1883, -23.18521, -23.18542, -23.1845,
-23.1845, -23.18621, -23.1265, -23.1221, -23.12294, -23.13424,
-23.1035, -23.1039, -23.14203, -23.14224, -23.1434, -23.14557,
-23.18595, -23.1205, -23.12284, -23.1016, -23.06118, -23.06145,
-23.11963, -23.12103, -23.13235, -23.12047, -23.11879, -23.1178,
-23.12014, -23.1244, -23.12028, -23.12266, -23.13638, -23.13973,
-23.13559, -23.12061, -23.1147, -23.11508, -23.11559, -23.21706,
-23.22154)), class = "data.frame", row.names = c(NA, -137L))
# Create the map
Survey_Map <- autoplot(bathy_data, geom = c("raster", "contour")) +
scale_fill_etopo()
# Add survey points
Map <- Survey_Map +
geom_point(data = location,
aes(x = Longitude,
y = Latitude,
color = Survey_Type),
size = 1.6)
# Display the result
Map
Here is what it looks like on my machine: