1

所以我目前有一张地图(它很丑,见附件)

地图和点

我找到了一种将它们绘制在自上而下视图上的方法,但我想附加不同的颜色并将其作为图例(可能放大),而不是第一张图片中显示的点顶部的字母。谁能帮我这个?这是理想的图片,但带有图例和不同的颜色:

理想的画面,但带有传说和不同的颜色

#libraries

  library(readr)
  library(sp)
  library(rgdal)
  library(raster)
  library(GISTools)
  library(sf)

#col_coor points to be plotted
 SUB        POP      LON   LAT
   <chr>      <chr>  <dbl> <dbl>
 1 mandtii    AK    -156.   71.2
 2 ultimus    NU     -82.5  65.9
 3 ultimus    GR     -70.2  76.5
 4 arcticus   LB     -61.7  56.6
 5 arcticus   NF     -53.6  47.3
 6 arcticus   ST     -69.7  47.8
 7 arcticus   NS     -61.5  45.1
 8 arcticus   NB     -66.8  44.6
 9 arcticus   ME     -68.2  44.2
10 islandicus IC     -22.9  65.4
11 grylle     FI      19.3  60.2

# Convert Lat & Lon data into a SPDF            
col_loc <- sp::SpatialPointsDataFrame(col_coor[,3:4], col_coor)

# Assign a coordinate reference system 
crs(col_loc) <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"

 radius <- 75000
  ColBuff<-raster::buffer(col_loc, width=(radius), filename='1000', doEdge=FALSE)


# Plot maximum flight radius polygons on base raster with continent boundaries
  data("wrld_simpl", package = "maptools")                                                                            
  world_map <- crop(wrld_simpl, extent(-180, 180, 35, 90))                                                                   
  plot(world_map, col="grey") 
  plot(ColBuff, pch=20, col="red",add=TRUE)

# Convert WGS84 to Arctic polar stereographic projection (STERE)  
  proj <- "+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs"
  wm_stere <- spTransform(world_map, CRSobj = CRS(proj))
  plot(wm_stere, col="grey")
  cb_stere <- spTransform(ColBuff, CRSobj = CRS(proj))
  plot(cb_stere, pch=20, col="red",add=TRUE)
4

1 回答 1

1

我不是 100% 确定我理解你的问题,但你想创造这样的东西吗?

# packages
library(sf)
#> Linking to GEOS 3.6.1, GDAL 2.2.3, PROJ 4.9.3
library(magrittr)
library(tmap)

# points data
col_coor <- data.frame(
  SUB = c(
    "mandtii", "ultimus", "ultimus", "arcticus", "arcticus", "arcticus",
    "arcticus", "arcticus", "arcticus", "islandicus", "grylle"
  ),
  POP = c("AK", "NU", "GR", "LB", "NF", "ST", "NS", "NB", "ME", "IC", "FI"),
  LON = c(-156, -82.5, -70.2, -61.7, -53.6, -69.7, -61.5, -66.8, -68.2, -22.9, 19.3),
  LAT = c(71.2, 65.9, 76.5, 56.6, 47.3, 47.8, 45.1, 44.6, 44.2, 65.4, 60.2),
  stringsAsFactors = FALSE
)

new_crs <- "+proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs"

col_coor <- col_coor %>% 
  st_as_sf(coords = c("LON", "LAT"), crs = 4326) %>%
  st_transform(crs = new_crs)

# world data
data("wrld_simpl", package = "maptools")
wrld_simpl <- st_as_sf(wrld_simpl) %>%
  st_crop(xmin = -180, xmax = 180, ymin = 35, ymax = 90) %>%
  st_transform(crs = new_crs)
#> although coordinates are longitude/latitude, st_intersection assumes that they are planar
#> Warning: attribute variables are assumed to be spatially constant throughout all
#> geometries

# plot
tm_shape(wrld_simpl) +
  tm_polygons() +
  tm_shape(col_coor) +
  tm_dots(col = "POP", size = 0.33) +
  tm_layout(legend.outside = TRUE, legend.text.size = 1.25, legend.title.size = 1.25)
#> Warning: The shape wrld_simpl is invalid. See sf::st_is_valid

reprex 包(v0.3.0)于 2020 年 2 月 14 日创建

您可以在此处阅读有关 tmap 的更多详细信息:https ://geocompr.robinlovelace.net/adv-map.html

于 2020-02-14T20:55:30.337 回答