根据调查类型的 ggmap 颜色

ggmap colour according to survey type

我正在尝试创建一个地图来显示我的所有 Lat/Long 数据点,每种调查类型都用不同的颜色表示。

setwd("/Users/Jon/Desktop")
Total_Surveys=read.csv("Survey_Map.csv")
library(RgoogleMaps)
library(ggmap)
attach(Total_Surveys)

Finalmap<- get_map(location = c(lon = -23.17, lat = 15.2), zoom = 11,  
                   maptype = "hybrid", scale = 2)

ggmap(Finalmap) +
    geom_point(data = Total_Surveys,
               aes(x = Longitude,
                   y = Latitude,
                   fill = "red",
                   alpha = 0.8), 
               size = 5,
               shape = 21) +
    guides(fill=FALSE, alpha=FALSE, size=FALSE)

数据:已修改 GPS 点 我正在添加这行文本,因为我不能 post 不写它。有一条消息说我的消息主要是代码,需要更多信息。真的很愚蠢。

    structure(list(Survey_Type = structure(c(1L, 1L, 1L, 1L, 1L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
    2L, 2L, 2L, 2L, 2L, 2L, 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("Boat Survey", "BRUVs 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)), .Names = c("Survey_Type", 
    "Latitude", "Longitude"), class = "data.frame", row.names = c(NA, 
    -137L))

正如@divibisan 所说,将 fill 美学更改为 Survey_Type 应该可以满足您的要求:

ggmap(Finalmap) +
    geom_point(data = Total_Surveys,
               aes(x = Longitude,
                   y = Latitude,
                   fill = Survey_Type,
                   alpha = 0.8), 
               size = 5,
               shape = 21) +
    guides(fill=FALSE, alpha=FALSE, size=FALSE)

给我